Advertisement
Guest User

Prashant

a guest
May 4th, 2011
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. int32_t HASHAlgSha1::InitializeContext()
  2. {
  3.   HMAC_CTX ctx ;
  4. #if OPENSSL_VERSION_NUMBER < 0x0090700fL
  5.   HMAC_Init(&ctx, hash_key->v, hash_key->l, EVP_sha1());
  6. #else
  7.   HMAC_CTX_init(&ctx);
  8.   HMAC_Init_ex(&ctx, hash_key->v, hash_key->l, EVP_sha1(), NULL);
  9. #endif
  10. }
  11.  
  12.  
  13. int32_t CryptoInterface::CreateSelfHashInterface(HASH_Alg hash_alg,
  14.                                             syfer_vchar_t * hash_key)
  15. {
  16.     switch(hash_alg)
  17.     {
  18.       case HASH_ALG_SHA1:
  19.         {
  20.           hash_ptr_self = new HASHAlgSha1(hash_key);
  21.           break;
  22.         }
  23.       default:
  24.         {
  25.           hash_ptr_self = NULL;
  26.         }
  27.     }
  28.  
  29.     if (NULL != hash_ptr_self)
  30.     {
  31.       hash_ptr_self->InitializeContext();
  32.     }
  33.  
  34.     return 0;
  35. }
  36.  
  37. main()
  38. {
  39.   CryptoInterface * crypto_ptr = new CryptoInterface();
  40.  
  41.   syfer_vchar_t *key = syfer_alloc(20);
  42.   (key->v)[0]=0x20;
  43.  
  44.   crypto_ptr->CreateSelfHashInterface(HASH_ALG_SHA1, key);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement