diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2016-03-15 03:57:39 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2016-03-15 03:57:39 +0000 |
commit | 26d978a556ae9099f6610ace9834991636e4a71b (patch) | |
tree | d8789c5afbe3920f3f7ef46ad73aa34f48173591 /third_party/srtp/crypto/include/sha1.h | |
parent | 8b9358503884ec1901d807ff56c2fc588be896a2 (diff) |
Close #1847: Upgraded libsrtp version to 1.5.4 and added support for AES-CM-256 crypto.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5261 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party/srtp/crypto/include/sha1.h')
-rw-r--r-- | third_party/srtp/crypto/include/sha1.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/third_party/srtp/crypto/include/sha1.h b/third_party/srtp/crypto/include/sha1.h index e3af4d4b..f1744ced 100644 --- a/third_party/srtp/crypto/include/sha1.h +++ b/third_party/srtp/crypto/include/sha1.h @@ -47,7 +47,49 @@ #ifndef SHA1_H #define SHA1_H +#ifdef HAVE_CONFIG_H + #include <config.h> +#endif + #include "err.h" +#ifdef OPENSSL +#include <openssl/evp.h> +#include <stdint.h> + +typedef EVP_MD_CTX sha1_ctx_t; + +/* + * sha1_init(&ctx) initializes the SHA1 context ctx + * + * sha1_update(&ctx, msg, len) hashes the len octets starting at msg + * into the SHA1 context + * + * sha1_final(&ctx, output) performs the final processing of the SHA1 + * context and writes the result to the 20 octets at output + * + * Return values are ignored on the EVP functions since all three + * of these functions return void. + * + */ + +static inline void sha1_init (sha1_ctx_t *ctx) +{ + EVP_MD_CTX_init(ctx); + EVP_DigestInit(ctx, EVP_sha1()); +} + +static inline void sha1_update (sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg) +{ + EVP_DigestUpdate(ctx, M, octets_in_msg); +} + +static inline void sha1_final (sha1_ctx_t *ctx, uint32_t *output) +{ + unsigned int len = 0; + + EVP_DigestFinal(ctx, (unsigned char*)output, &len); +} +#else #include "datatypes.h" typedef struct { @@ -104,5 +146,7 @@ sha1_final(sha1_ctx_t *ctx, uint32_t output[5]); void sha1_core(const uint32_t M[16], uint32_t hash_value[5]); + +#endif /* else OPENSSL */ #endif /* SHA1_H */ |