Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1337)

Unified Diff: srtp/crypto/include/sha1.h

Issue 889083003: Update libsrtp to upstream 1.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libsrtp@master
Patch Set: Updated to libsrtp 1.5.1 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « srtp/crypto/include/rdbx.h ('k') | srtp/crypto/include/xfm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: srtp/crypto/include/sha1.h
diff --git a/srtp/crypto/include/sha1.h b/srtp/crypto/include/sha1.h
index e3af4d4b4b8836675a64022a2e39b4cf70efe540..9b6cfed7e374e5c653bc0eb3849dd8a7155c460f 100644
--- a/srtp/crypto/include/sha1.h
+++ b/srtp/crypto/include/sha1.h
@@ -48,6 +48,44 @@
#define SHA1_H
#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 +142,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 */
« no previous file with comments | « srtp/crypto/include/rdbx.h ('k') | srtp/crypto/include/xfm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698