Guest User

Untitled

a guest
Jun 18th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <openssl/evp.h>
  2. #include <openssl/hmac.h>
  3. #include <openssl/aes.h>
  4. int openssl_hmac_vector(const EVP_MD *type, const u8 *key,
  5. size_t key_len, size_t num_elem,
  6. const u8 *addr[], const size_t *len, u8 *mac,
  7. unsigned int mdlen)
  8. {
  9. HMAC_CTX ctx;
  10. size_t i;
  11. int res;
  12.  
  13. HMAC_CTX_init(&ctx);
  14. #if OPENSSL_VERSION_NUMBER < 0x00909000
  15. HMAC_Init_ex(&ctx, key, key_len, type, NULL);
  16. #else /* openssl < 0.9.9 */
  17. if (HMAC_Init_ex(&ctx, key, key_len, type, NULL) != 1)
  18. return -1;
  19. #endif /* openssl < 0.9.9 */
  20.  
  21. for (i = 0; i < num_elem; i++)
  22. HMAC_Update(&ctx, addr[i], len[i]);
  23.  
  24. #if OPENSSL_VERSION_NUMBER < 0x00909000
  25. HMAC_Final(&ctx, mac, &mdlen);
  26. res = 1;
  27. #else /* openssl < 0.9.9 */
  28. res = HMAC_Final(&ctx, mac, &mdlen);
  29. #endif /* openssl < 0.9.9 */
  30. HMAC_CTX_cleanup(&ctx);
  31.  
  32. return res == 1 ? 0 : -1;
  33. }
  34.  
  35. Error 12 error LNK2001: unresolved external symbol _HMAC_CTX_cleanup@4
  36. Error 13 error LNK2001: unresolved external symbol _HMAC_Final@12
  37. Error 15 error LNK2001: unresolved external symbol _HMAC_Init_ex@20
  38. Error 16 error LNK2001: unresolved external symbol _HMAC_CTX_init@4
Add Comment
Please, Sign In to add comment