diff options
| author | David M. Syzdek <david@syzdek.net> | 2023-01-11 10:41:16 -0900 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2023-01-11 10:41:16 -0900 |
| commit | 1d9dfc98c0e56b30403c7ee08fa38ec65955f84a (patch) | |
| tree | b56944a7d0ae1499607ff9040ebdd684e2fe5e08 | |
| parent | d7284d78b77f5b7ed664afbbba732625cfc843ca (diff) | |
| download | otputils-1d9dfc98c0e56b30403c7ee08fa38ec65955f84a.tar.gz otputils-1d9dfc98c0e56b30403c7ee08fa38ec65955f84a.tar.bz2 otputils-1d9dfc98c0e56b30403c7ee08fa38ec65955f84a.tar.xz otputils-1d9dfc98c0e56b30403c7ee08fa38ec65955f84a.zip | |
libotputil: adding otputil_evp_md()
| -rw-r--r-- | lib/libotputil/lmisc.c | 19 | ||||
| -rw-r--r-- | lib/libotputil/lmisc.h | 8 |
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/libotputil/lmisc.c b/lib/libotputil/lmisc.c index bbaa2fa..1c60269 100644 --- a/lib/libotputil/lmisc.c +++ b/lib/libotputil/lmisc.c | |||
| @@ -95,6 +95,25 @@ otputil_err2string( | |||
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | 97 | ||
| 98 | const EVP_MD * | ||
| 99 | otputil_evp_md( | ||
| 100 | int id ) | ||
| 101 | { | ||
| 102 | switch(id) | ||
| 103 | { | ||
| 104 | case OTPUTIL_MD_MD4: return(EVP_md4()); | ||
| 105 | case OTPUTIL_MD_MD5: return(EVP_md5()); | ||
| 106 | case OTPUTIL_MD_SHA1: return(EVP_sha1()); | ||
| 107 | case OTPUTIL_MD_SHA256: return(EVP_sha256()); | ||
| 108 | case OTPUTIL_MD_SHA512: return(EVP_sha512()); | ||
| 109 | case OTPUTIL_MD_SHA3_256: return(EVP_sha3_256()); | ||
| 110 | case OTPUTIL_MD_SHA3_512: return(EVP_sha3_512()); | ||
| 111 | default: break; | ||
| 112 | }; | ||
| 113 | return(NULL); | ||
| 114 | } | ||
| 115 | |||
| 116 | |||
| 98 | char * | 117 | char * |
| 99 | otputil_getpass( | 118 | otputil_getpass( |
| 100 | const char * prompt, | 119 | const char * prompt, |
diff --git a/lib/libotputil/lmisc.h b/lib/libotputil/lmisc.h index 66926de..36d18e3 100644 --- a/lib/libotputil/lmisc.h +++ b/lib/libotputil/lmisc.h | |||
| @@ -41,6 +41,9 @@ | |||
| 41 | /////////////// | 41 | /////////////// |
| 42 | #pragma mark - Headers | 42 | #pragma mark - Headers |
| 43 | 43 | ||
| 44 | #include <openssl/evp.h> | ||
| 45 | #include <openssl/hmac.h> | ||
| 46 | |||
| 44 | #include "libotputil.h" | 47 | #include "libotputil.h" |
| 45 | 48 | ||
| 46 | 49 | ||
| @@ -51,6 +54,11 @@ | |||
| 51 | ////////////////// | 54 | ////////////////// |
| 52 | #pragma mark - Prototypes | 55 | #pragma mark - Prototypes |
| 53 | 56 | ||
| 57 | extern const EVP_MD * | ||
| 58 | otputil_evp_md( | ||
| 59 | int id ); | ||
| 60 | |||
| 61 | |||
| 54 | extern uintmax_t | 62 | extern uintmax_t |
| 55 | otputil_upow( | 63 | otputil_upow( |
| 56 | uintmax_t base, | 64 | uintmax_t base, |
