- rename sha1_init / sha1_update / sha1_free with prefix srtp_ to resolve multiple symbol error with libzmq

This commit is contained in:
Dmytro Bogovych 2024-11-10 13:21:10 +03:00
parent 5bf8d665e2
commit f0c37b1bb1
3 changed files with 18 additions and 18 deletions

View File

@ -137,10 +137,10 @@ hmac_init(hmac_ctx_t *state, const uint8_t *key, int key_len) {
debug_print(mod_hmac, "ipad: %s", octet_string_hex_string(ipad, 64)); debug_print(mod_hmac, "ipad: %s", octet_string_hex_string(ipad, 64));
/* initialize sha1 context */ /* initialize sha1 context */
sha1_init(&state->init_ctx); srtp_sha1_init(&state->init_ctx);
/* hash ipad ^ key */ /* hash ipad ^ key */
sha1_update(&state->init_ctx, ipad, 64); srtp_sha1_update(&state->init_ctx, ipad, 64);
memcpy(&state->ctx, &state->init_ctx, sizeof(sha1_ctx_t)); memcpy(&state->ctx, &state->init_ctx, sizeof(sha1_ctx_t));
return err_status_ok; return err_status_ok;
@ -161,7 +161,7 @@ hmac_update(hmac_ctx_t *state, const uint8_t *message, int msg_octets) {
octet_string_hex_string(message, msg_octets)); octet_string_hex_string(message, msg_octets));
/* hash message into sha1 context */ /* hash message into sha1 context */
sha1_update(&state->ctx, message, msg_octets); srtp_sha1_update(&state->ctx, message, msg_octets);
return err_status_ok; return err_status_ok;
} }
@ -179,7 +179,7 @@ hmac_compute(hmac_ctx_t *state, const void *message,
/* hash message, copy output into H */ /* hash message, copy output into H */
hmac_update(state, (const uint8_t*)message, msg_octets); hmac_update(state, (const uint8_t*)message, msg_octets);
sha1_final(&state->ctx, H); srtp_sha1_final(&state->ctx, H);
/* /*
* note that we don't need to debug_print() the input, since the * note that we don't need to debug_print() the input, since the
@ -189,16 +189,16 @@ hmac_compute(hmac_ctx_t *state, const void *message,
octet_string_hex_string((uint8_t *)H, 20)); octet_string_hex_string((uint8_t *)H, 20));
/* re-initialize hash context */ /* re-initialize hash context */
sha1_init(&state->ctx); srtp_sha1_init(&state->ctx);
/* hash opad ^ key */ /* hash opad ^ key */
sha1_update(&state->ctx, (uint8_t *)state->opad, 64); srtp_sha1_update(&state->ctx, (uint8_t *)state->opad, 64);
/* hash the result of the inner hash */ /* hash the result of the inner hash */
sha1_update(&state->ctx, (uint8_t *)H, 20); srtp_sha1_update(&state->ctx, (uint8_t *)H, 20);
/* the result is returned in the array hash_value[] */ /* the result is returned in the array hash_value[] */
sha1_final(&state->ctx, hash_value); srtp_sha1_final(&state->ctx, hash_value);
/* copy hash_value to *result */ /* copy hash_value to *result */
for (i=0; i < tag_len; i++) for (i=0; i < tag_len; i++)

View File

@ -77,9 +77,9 @@ void
sha1(const uint8_t *msg, int octets_in_msg, uint32_t hash_value[5]) { sha1(const uint8_t *msg, int octets_in_msg, uint32_t hash_value[5]) {
sha1_ctx_t ctx; sha1_ctx_t ctx;
sha1_init(&ctx); srtp_sha1_init(&ctx);
sha1_update(&ctx, msg, octets_in_msg); srtp_sha1_update(&ctx, msg, octets_in_msg);
sha1_final(&ctx, hash_value); srtp_sha1_final(&ctx, hash_value);
} }
@ -183,7 +183,7 @@ sha1_core(const uint32_t M[16], uint32_t hash_value[5]) {
} }
void void
sha1_init(sha1_ctx_t *ctx) { srtp_sha1_init(sha1_ctx_t *ctx) {
/* initialize state vector */ /* initialize state vector */
ctx->H[0] = 0x67452301; ctx->H[0] = 0x67452301;
@ -201,7 +201,7 @@ sha1_init(sha1_ctx_t *ctx) {
} }
void void
sha1_update(sha1_ctx_t *ctx, const uint8_t *msg, int octets_in_msg) { srtp_sha1_update(sha1_ctx_t *ctx, const uint8_t *msg, int octets_in_msg) {
int i; int i;
uint8_t *buf = (uint8_t *)ctx->M; uint8_t *buf = (uint8_t *)ctx->M;
@ -249,7 +249,7 @@ sha1_update(sha1_ctx_t *ctx, const uint8_t *msg, int octets_in_msg) {
*/ */
void void
sha1_final(sha1_ctx_t *ctx, uint32_t *output) { srtp_sha1_final(sha1_ctx_t *ctx, uint32_t *output) {
uint32_t A, B, C, D, E, TEMP; uint32_t A, B, C, D, E, TEMP;
uint32_t W[80]; uint32_t W[80];
int i, t; int i, t;

View File

@ -68,7 +68,7 @@ void
sha1(const uint8_t *message, int octets_in_msg, uint32_t output[5]); sha1(const uint8_t *message, int octets_in_msg, uint32_t output[5]);
/* /*
* sha1_init(&ctx) initializes the SHA1 context ctx * srtp_sha1_init(&ctx) initializes the SHA1 context ctx
* *
* sha1_update(&ctx, msg, len) hashes the len octets starting at msg * sha1_update(&ctx, msg, len) hashes the len octets starting at msg
* into the SHA1 context * into the SHA1 context
@ -79,13 +79,13 @@ sha1(const uint8_t *message, int octets_in_msg, uint32_t output[5]);
*/ */
void void
sha1_init(sha1_ctx_t *ctx); srtp_sha1_init(sha1_ctx_t *ctx);
void void
sha1_update(sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg); srtp_sha1_update(sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg);
void void
sha1_final(sha1_ctx_t *ctx, uint32_t output[5]); srtp_sha1_final(sha1_ctx_t *ctx, uint32_t output[5]);
/* /*
* The sha1_core function is INTERNAL to SHA-1, but it is declared * The sha1_core function is INTERNAL to SHA-1, but it is declared