instead of using regular OpenSSL API names.
int n;
int ret = 0;
EVP_CIPHER_CTX ctx;
- EVP_CIPHER_CTX_init(&ctx);
+ FIPS_cipher_ctx_init(&ctx);
for(n=0 ; n < 1 ; ++n)
{
}
ret = 1;
err:
- EVP_CIPHER_CTX_cleanup(&ctx);
+ FIPS_cipher_ctx_cleanup(&ctx);
if (ret == 0)
FIPSerr(FIPS_F_FIPS_SELFTEST_AES,FIPS_R_SELFTEST_FAILED);
return ret;
printf("Invalid key size: %d\n", akeysz);
return 0;
}
- if (EVP_CipherInit_ex(ctx, cipher, NULL, aKey, iVec, dir) <= 0)
+ if (FIPS_cipherinit(ctx, cipher, aKey, iVec, dir) <= 0)
return 0;
if(!strcasecmp(amode,"CFB1"))
M_EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS);
if (dir)
- EVP_Cipher(ctx, ciphertext, plaintext, len);
+ FIPS_cipher(ctx, ciphertext, plaintext, len);
else
- EVP_Cipher(ctx, plaintext, ciphertext, len);
+ FIPS_cipher(ctx, plaintext, ciphertext, len);
return 1;
}
int i, j, n, n1, n2;
int imode = 0, nkeysz = akeysz/8;
EVP_CIPHER_CTX ctx;
- EVP_CIPHER_CTX_init(&ctx);
+ FIPS_cipher_ctx_init(&ctx);
if (len > 32)
{
{
if (dir == XENCRYPT)
{
- EVP_Cipher(&ctx, ctext[j], ptext[j], len);
+ FIPS_cipher(&ctx, ctext[j], ptext[j], len);
memcpy(ptext[j+1], ctext[j], len);
}
else
{
- EVP_Cipher(&ctx, ptext[j], ctext[j], len);
+ FIPS_cipher(&ctx, ptext[j], ctext[j], len);
memcpy(ctext[j+1], ptext[j], len);
}
}
{
if (dir == XENCRYPT)
{
- EVP_Cipher(&ctx, ctext[j], ptext[j], len);
+ FIPS_cipher(&ctx, ctext[j], ptext[j], len);
memcpy(ptext[j+1], ctext[j-1], len);
}
else
{
- EVP_Cipher(&ctx, ptext[j], ctext[j], len);
+ FIPS_cipher(&ctx, ptext[j], ctext[j], len);
memcpy(ctext[j+1], ptext[j-1], len);
}
}
else
{
if (dir == XENCRYPT)
- EVP_Cipher(&ctx, ctext[j], ptext[j], len);
+ FIPS_cipher(&ctx, ctext[j], ptext[j], len);
else
- EVP_Cipher(&ctx, ptext[j], ctext[j], len);
+ FIPS_cipher(&ctx, ptext[j], ctext[j], len);
}
if (dir == XENCRYPT)
{
else
{
if (dir == XENCRYPT)
- EVP_Cipher(&ctx, ctext[j], ptext[j], len);
+ FIPS_cipher(&ctx, ctext[j], ptext[j], len);
else
- EVP_Cipher(&ctx, ptext[j], ctext[j], len);
+ FIPS_cipher(&ctx, ptext[j], ctext[j], len);
}
if(dir == XENCRYPT)
unsigned char ciphertext[2048];
char *rp;
EVP_CIPHER_CTX ctx;
- EVP_CIPHER_CTX_init(&ctx);
+ FIPS_cipher_ctx_init(&ctx);
if (!rqfile || !(*rqfile))
{
unsigned char *ct = NULL, *pt = NULL;
EVP_CIPHER_CTX ctx;
const EVP_CIPHER *gcm;
- EVP_CIPHER_CTX_init(&ctx);
+ FIPS_cipher_ctx_init(&ctx);
while(fgets(buf,sizeof buf,stdin) != NULL)
{
if (encrypt && pt && aad && (iv || encrypt==1))
{
tag = OPENSSL_malloc(taglen);
- EVP_CipherInit_ex(&ctx, gcm, NULL, NULL, NULL, 1);
+ FIPS_cipherinit(&ctx, gcm, NULL, NULL, 1);
/* Relax FIPS constraints for testing */
M_EVP_CIPHER_CTX_set_flags(&ctx, EVP_CIPH_FLAG_NON_FIPS_ALLOW);
- EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, ivlen, 0);
+ FIPS_cipher_ctx_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, ivlen, 0);
if (encrypt == 1)
{
static unsigned char iv_fixed[4] = {1,2,3,4};
if (!iv)
iv = OPENSSL_malloc(ivlen);
- EVP_CipherInit_ex(&ctx, NULL, NULL, key, NULL, 1);
- EVP_CIPHER_CTX_ctrl(&ctx,
+ FIPS_cipherinit(&ctx, NULL, key, NULL, 1);
+ FIPS_cipher_ctx_ctrl(&ctx,
EVP_CTRL_GCM_SET_IV_FIXED,
4, iv_fixed);
- if (!EVP_CIPHER_CTX_ctrl(&ctx,
+ if (!FIPS_cipher_ctx_ctrl(&ctx,
EVP_CTRL_GCM_IV_GEN, 0, iv))
{
fprintf(stderr, "IV gen error\n");
OutputValue("IV", iv, ivlen, stdout, 0);
}
else
- EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, 1);
+ FIPS_cipherinit(&ctx, NULL, key, iv, 1);
if (aadlen)
- EVP_Cipher(&ctx, NULL, aad, aadlen);
+ FIPS_cipher(&ctx, NULL, aad, aadlen);
if (ptlen)
{
ct = OPENSSL_malloc(ptlen);
- rv = EVP_Cipher(&ctx, ct, pt, ptlen);
+ rv = FIPS_cipher(&ctx, ct, pt, ptlen);
}
- EVP_Cipher(&ctx, NULL, NULL, 0);
- EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_GET_TAG,
+ FIPS_cipher(&ctx, NULL, NULL, 0);
+ FIPS_cipher_ctx_ctrl(&ctx, EVP_CTRL_GCM_GET_TAG,
taglen, tag);
OutputValue("CT", ct, ptlen, stdout, 0);
OutputValue("Tag", tag, taglen, stdout, 0);
}
if (!encrypt && tag)
{
- EVP_CipherInit_ex(&ctx, gcm, NULL, NULL, NULL, 0);
+ FIPS_cipherinit(&ctx, gcm, NULL, NULL, 0);
/* Relax FIPS constraints for testing */
M_EVP_CIPHER_CTX_set_flags(&ctx, EVP_CIPH_FLAG_NON_FIPS_ALLOW);
- EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, ivlen, 0);
- EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, 0);
- EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_TAG, taglen, tag);
+ FIPS_cipher_ctx_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, ivlen, 0);
+ FIPS_cipherinit(&ctx, NULL, key, iv, 0);
+ FIPS_cipher_ctx_ctrl(&ctx, EVP_CTRL_GCM_SET_TAG, taglen, tag);
if (aadlen)
- EVP_Cipher(&ctx, NULL, aad, aadlen);
+ FIPS_cipher(&ctx, NULL, aad, aadlen);
if (ptlen)
{
pt = OPENSSL_malloc(ptlen);
- rv = EVP_Cipher(&ctx, pt, ct, ptlen);
+ rv = FIPS_cipher(&ctx, pt, ct, ptlen);
}
- rv = EVP_Cipher(&ctx, NULL, NULL, 0);
+ rv = FIPS_cipher(&ctx, NULL, NULL, 0);
if (rv < 0)
printf("FAIL\n");
else
{
int n, ret = 0;
EVP_CIPHER_CTX ctx;
- EVP_CIPHER_CTX_init(&ctx);
+ FIPS_cipher_ctx_init(&ctx);
/* Encrypt/decrypt with 2-key 3DES and compare to known answers */
for(n=0 ; n < 2 ; ++n)
{
}
ret = 1;
err:
- EVP_CIPHER_CTX_cleanup(&ctx);
+ FIPS_cipher_ctx_cleanup(&ctx);
if (ret == 0)
FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED);
EXIT(1);
}
- if (EVP_CipherInit_ex(ctx, cipher, NULL, aKey, iVec, dir) <= 0)
+ if (FIPS_cipherinit(ctx, cipher, aKey, iVec, dir) <= 0)
return 0;
if(!strcasecmp(amode,"CFB1"))
M_EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS);
- EVP_Cipher(ctx, out, in, len);
+ FIPS_cipher(ctx, out, in, len);
return 1;
}
int kp=akeysz/64;
unsigned char old_iv[8];
EVP_CIPHER_CTX ctx;
- EVP_CIPHER_CTX_init(&ctx);
+ FIPS_cipher_ctx_init(&ctx);
fprintf(rfp,"\nCOUNT = %d\n",i);
if(kp == 1)
else
{
memcpy(old_iv,ctx.iv,8);
- EVP_Cipher(&ctx,text,text,len);
+ FIPS_cipher(&ctx,text,text,len);
}
if(j == 9999)
{
char *rp;
EVP_CIPHER_CTX ctx;
int numkeys=1;
- EVP_CIPHER_CTX_init(&ctx);
+ FIPS_cipher_ctx_init(&ctx);
if (!rqfile || !(*rqfile))
{
EVP_MD_CTX mctx;
DSA_SIG *dsig = NULL;
- EVP_MD_CTX_init(&mctx);
+ FIPS_md_ctx_init(&mctx);
dsa = FIPS_dsa_new();
DSA_generate_key(dsa);
- if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL))
+ if (!FIPS_digestinit(&mctx, EVP_sha1()))
goto err;
- if (!EVP_DigestUpdate(&mctx, str1, 20))
+ if (!FIPS_digestupdate(&mctx, str1, 20))
goto err;
dsig = FIPS_dsa_sign_ctx(dsa, &mctx);
if (!dsig)
goto err;
- if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL))
+ if (!FIPS_digestinit(&mctx, EVP_sha1()))
goto err;
- if (!EVP_DigestUpdate(&mctx, str1, 20))
+ if (!FIPS_digestupdate(&mctx, str1, 20))
goto err;
if (FIPS_dsa_verify_ctx(dsa, &mctx, dsig) != 1)
goto err;
ret = 1;
err:
- EVP_MD_CTX_cleanup(&mctx);
+ FIPS_md_ctx_cleanup(&mctx);
if (dsa)
FIPS_dsa_free(dsa);
if (dsig)
DSA_SIG *s;
unsigned char dig[EVP_MAX_MD_SIZE];
unsigned int dlen;
- EVP_DigestFinal_ex(ctx, dig, &dlen);
+ FIPS_digestfinal(ctx, dig, &dlen);
s = dsa->meth->dsa_do_sign(dig,dlen,dsa);
OPENSSL_cleanse(dig, dlen);
return s;
int ret=-1;
unsigned char dig[EVP_MAX_MD_SIZE];
unsigned int dlen;
- EVP_DigestFinal_ex(ctx, dig, &dlen);
+ FIPS_digestfinal(ctx, dig, &dlen);
ret=dsa->meth->dsa_do_verify(dig,dlen,s,dsa);
OPENSSL_cleanse(dig, dlen);
return ret;
BN_GENCB cb;
EVP_MD_CTX mctx;
BN_GENCB_set(&cb, dsa_cb, stderr);
- EVP_MD_CTX_init(&mctx);
+ FIPS_md_ctx_init(&mctx);
fips_set_error_print();
if(!FIPS_mode_set(1))
}
DSA_generate_key(dsa);
- if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL))
+ if (!FIPS_digestinit(&mctx, EVP_sha1()))
goto end;
- if (!EVP_DigestUpdate(&mctx, str1, 20))
+ if (!FIPS_digestupdate(&mctx, str1, 20))
goto end;
sig = FIPS_dsa_sign_ctx(dsa, &mctx);
if (!sig)
goto end;
- if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL))
+ if (!FIPS_digestinit(&mctx, EVP_sha1()))
goto end;
- if (!EVP_DigestUpdate(&mctx, str1, 20))
+ if (!FIPS_digestupdate(&mctx, str1, 20))
goto end;
if (FIPS_dsa_verify_ctx(dsa, &mctx, sig) != 1)
goto end;
if (sig)
DSA_SIG_free(sig);
if (dsa != NULL) FIPS_dsa_free(dsa);
- EVP_MD_CTX_cleanup(&mctx);
+ FIPS_md_ctx_cleanup(&mctx);
#if 0
CRYPTO_mem_leaks(bio_err);
#endif
int n;
EVP_MD_CTX mctx;
DSA_SIG *sig;
- EVP_MD_CTX_init(&mctx);
+ FIPS_md_ctx_init(&mctx);
n=hex2bin(value,msg);
exit(1);
pbn("Y",dsa->pub_key);
- EVP_DigestInit_ex(&mctx, md, NULL);
- EVP_DigestUpdate(&mctx, msg, n);
+ FIPS_digestinit(&mctx, md);
+ FIPS_digestupdate(&mctx, msg, n);
sig = FIPS_dsa_sign_ctx(dsa, &mctx);
pbn("R",sig->r);
pbn("S",sig->s);
putc('\n',stdout);
DSA_SIG_free(sig);
- EVP_MD_CTX_cleanup(&mctx);
+ FIPS_md_ctx_cleanup(&mctx);
}
}
if (dsa)
{
EVP_MD_CTX mctx;
int r;
- EVP_MD_CTX_init(&mctx);
+ FIPS_md_ctx_init(&mctx);
sig->s=hex2bn(value);
- EVP_DigestInit_ex(&mctx, md, NULL);
- EVP_DigestUpdate(&mctx, msg, n);
+ FIPS_digestinit(&mctx, md);
+ FIPS_digestupdate(&mctx, msg, n);
no_err = 1;
r = FIPS_dsa_verify_ctx(dsa, &mctx, sig);
no_err = 0;
- EVP_MD_CTX_cleanup(&mctx);
+ FIPS_md_ctx_cleanup(&mctx);
printf("Result = %c\n", r == 1 ? 'P' : 'F');
putc('\n',stdout);
unsigned int siglen;
DSA_SIG *dsig = NULL;
EVP_MD_CTX mctx;
- EVP_MD_CTX_init(&mctx);
+ FIPS_md_ctx_init(&mctx);
if ((pkey->type == EVP_PKEY_RSA)
&& ((size_t)RSA_size(pkey->pkey.rsa) > sizeof(sigtmp)))
if (tbslen == -1)
tbslen = strlen((char *)tbs);
- if (!EVP_DigestInit_ex(&mctx, digest, NULL))
+ if (!FIPS_digestinit(&mctx, digest))
goto error;
- if (!EVP_DigestUpdate(&mctx, tbs, tbslen))
+ if (!FIPS_digestupdate(&mctx, tbs, tbslen))
goto error;
if (pkey->type == EVP_PKEY_RSA)
{
if (kat && ((siglen != katlen) || memcmp(kat, sig, katlen)))
goto error;
- if (!EVP_DigestInit_ex(&mctx, digest, NULL))
+ if (!FIPS_digestinit(&mctx, digest))
goto error;
- if (!EVP_DigestUpdate(&mctx, tbs, tbslen))
+ if (!FIPS_digestupdate(&mctx, tbs, tbslen))
goto error;
if (pkey->type == EVP_PKEY_RSA)
{
DSA_SIG_free(dsig);
if (sig != sigtmp)
OPENSSL_free(sig);
- EVP_MD_CTX_cleanup(&mctx);
+ FIPS_md_ctx_cleanup(&mctx);
if (ret != 1)
{
FIPSerr(FIPS_F_FIPS_PKEY_SIGNATURE_TEST,FIPS_R_TEST_FAILURE);
if (fail_str)
- ERR_add_error_data(2, "Type=", fail_str);
+ FIPS_add_error_data(2, "Type=", fail_str);
return 0;
}
return 1;
unsigned char pltmp[FIPS_MAX_CIPHER_TEST_SIZE];
unsigned char citmp[FIPS_MAX_CIPHER_TEST_SIZE];
OPENSSL_assert(len <= FIPS_MAX_CIPHER_TEST_SIZE);
- if (EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 1) <= 0)
+ if (FIPS_cipherinit(ctx, cipher, key, iv, 1) <= 0)
return 0;
- EVP_Cipher(ctx, citmp, plaintext, len);
+ FIPS_cipher(ctx, citmp, plaintext, len);
if (memcmp(citmp, ciphertext, len))
return 0;
- if (EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 0) <= 0)
+ if (FIPS_cipherinit(ctx, cipher, key, iv, 0) <= 0)
return 0;
- EVP_Cipher(ctx, pltmp, citmp, len);
+ FIPS_cipher(ctx, pltmp, citmp, len);
if (memcmp(pltmp, plaintext, len))
return 0;
return 1;
unsigned char key[16] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
unsigned char plaintext[16] = "etaonrishdlcu";
EVP_CIPHER_CTX ctx;
- EVP_CIPHER_CTX_init(&ctx);
- if (EVP_CipherInit_ex(&ctx, EVP_aes_128_ecb(),NULL, key, NULL, 1) <= 0)
+ FIPS_cipher_ctx_init(&ctx);
+ if (FIPS_cipherinit(&ctx, EVP_aes_128_ecb(), key, NULL, 1) <= 0)
goto err;
- EVP_Cipher(&ctx, citmp, plaintext, 16);
- if (EVP_CipherInit_ex(&ctx, EVP_aes_128_ecb(),NULL, key, NULL, 0) <= 0)
+ FIPS_cipher(&ctx, citmp, plaintext, 16);
+ if (FIPS_cipherinit(&ctx, EVP_aes_128_ecb(), key, NULL, 0) <= 0)
goto err;
- EVP_Cipher(&ctx, pltmp, citmp, 16);
+ FIPS_cipher(&ctx, pltmp, citmp, 16);
if (memcmp(pltmp, plaintext, 16))
goto err;
ret = 1;
err:
- EVP_CIPHER_CTX_cleanup(&ctx);
+ FIPS_cipher_ctx_cleanup(&ctx);
return ret;
}
19,20,21,22,23,24};
unsigned char plaintext[] = { 'e', 't', 'a', 'o', 'n', 'r', 'i', 's' };
EVP_CIPHER_CTX ctx;
- EVP_CIPHER_CTX_init(&ctx);
- if (EVP_CipherInit_ex(&ctx, EVP_des_ede3_ecb(),NULL, key, NULL, 1) <= 0)
+ FIPS_cipher_ctx_init(&ctx);
+ if (FIPS_cipherinit(&ctx, EVP_des_ede3_ecb(), key, NULL, 1) <= 0)
goto err;
- EVP_Cipher(&ctx, citmp, plaintext, 8);
- if (EVP_CipherInit_ex(&ctx, EVP_des_ede3_ecb(),NULL, key, NULL, 0) <= 0)
+ FIPS_cipher(&ctx, citmp, plaintext, 8);
+ if (FIPS_cipherinit(&ctx, EVP_des_ede3_ecb(), key, NULL, 0) <= 0)
goto err;
- EVP_Cipher(&ctx, pltmp, citmp, 8);
+ FIPS_cipher(&ctx, pltmp, citmp, 8);
if (memcmp(pltmp, plaintext, 8))
goto err;
ret = 1;
err:
- EVP_CIPHER_CTX_cleanup(&ctx);
+ FIPS_cipher_ctx_cleanup(&ctx);
return ret;
}
DSA_SIG *sig = NULL;
ERR_clear_error();
- EVP_MD_CTX_init(&mctx);
+ FIPS_md_ctx_init(&mctx);
dsa = FIPS_dsa_new();
if (!dsa)
goto end;
if (bad)
BN_add_word(dsa->pub_key, 1);
- if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL))
+ if (!FIPS_digestinit(&mctx, EVP_sha1()))
goto end;
- if (!EVP_DigestUpdate(&mctx, dgst, sizeof(dgst) - 1))
+ if (!FIPS_digestupdate(&mctx, dgst, sizeof(dgst) - 1))
goto end;
sig = FIPS_dsa_sign_ctx(dsa, &mctx);
if (!sig)
goto end;
- if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL))
+ if (!FIPS_digestinit(&mctx, EVP_sha1()))
goto end;
- if (!EVP_DigestUpdate(&mctx, dgst, sizeof(dgst) - 1))
+ if (!FIPS_digestupdate(&mctx, dgst, sizeof(dgst) - 1))
goto end;
r = FIPS_dsa_verify_ctx(dsa, &mctx, sig);
end:
if (sig)
DSA_SIG_free(sig);
- EVP_MD_CTX_cleanup(&mctx);
+ FIPS_md_ctx_cleanup(&mctx);
if (dsa)
FIPS_dsa_free(dsa);
if (r != 1)
int r = 0;
ERR_clear_error();
- EVP_MD_CTX_init(&mctx);
+ FIPS_md_ctx_init(&mctx);
key = FIPS_rsa_new();
bn = BN_new();
if (!key || !bn)
if (bad)
BN_add_word(key->n, 1);
- if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL))
+ if (!FIPS_digestinit(&mctx, EVP_sha1()))
goto end;
- if (!EVP_DigestUpdate(&mctx, input_ptext, sizeof(input_ptext) - 1))
+ if (!FIPS_digestupdate(&mctx, input_ptext, sizeof(input_ptext) - 1))
goto end;
if (!FIPS_rsa_sign_ctx(key, &mctx, RSA_PKCS1_PADDING, 0, NULL, buf, &slen))
goto end;
- if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL))
+ if (!FIPS_digestinit(&mctx, EVP_sha1()))
goto end;
- if (!EVP_DigestUpdate(&mctx, input_ptext, sizeof(input_ptext) - 1))
+ if (!FIPS_digestupdate(&mctx, input_ptext, sizeof(input_ptext) - 1))
goto end;
r = FIPS_rsa_verify_ctx(key, &mctx, RSA_PKCS1_PADDING, 0, NULL, buf, slen);
end:
- EVP_MD_CTX_cleanup(&mctx);
+ FIPS_md_ctx_cleanup(&mctx);
if (key)
FIPS_rsa_free(key);
if (r != 1)
unsigned char md[SHA_DIGEST_LENGTH];
ERR_clear_error();
- if (!EVP_Digest(str,sizeof(str) - 1,md, NULL, EVP_sha1(), NULL)) return 0;
+ if (!FIPS_digest(str,sizeof(str) - 1,md, NULL, EVP_sha1())) return 0;
if (memcmp(md,digest,sizeof(md)))
return 0;
return 1;
unsigned char md[SHA256_DIGEST_LENGTH];
ERR_clear_error();
- if (!EVP_Digest(str,sizeof(str) - 1,md, NULL, EVP_sha256(), NULL)) return 0;
+ if (!FIPS_digest(str,sizeof(str) - 1,md, NULL, EVP_sha256())) return 0;
if (memcmp(md,digest,sizeof(md)))
return 0;
return 1;
unsigned char md[SHA512_DIGEST_LENGTH];
ERR_clear_error();
- if (!EVP_Digest(str,sizeof(str) - 1,md, NULL, EVP_sha512(), NULL)) return 0;
+ if (!FIPS_digest(str,sizeof(str) - 1,md, NULL, EVP_sha512())) return 0;
if (memcmp(md,digest,sizeof(md)))
return 0;
return 1;
{
unsigned int md_len, rv;
unsigned char md[EVP_MAX_MD_SIZE];
- EVP_DigestFinal_ex(ctx, md, &md_len);
+ FIPS_digestfinal(ctx, md, &md_len);
rv = FIPS_rsa_sign_digest(rsa, md, md_len,
M_EVP_MD_CTX_md(ctx),
rsa_pad_mode, saltlen,
{
unsigned int md_len, rv;
unsigned char md[EVP_MAX_MD_SIZE];
- EVP_DigestFinal_ex(ctx, md, &md_len);
+ FIPS_digestfinal(ctx, md, &md_len);
rv = FIPS_rsa_verify_digest(rsa, md, md_len, M_EVP_MD_CTX_md(ctx),
rsa_pad_mode, saltlen, mgf1Hash,
sigbuf, siglen);
if (!sigbuf)
goto error;
- EVP_MD_CTX_init(&ctx);
+ FIPS_md_ctx_init(&ctx);
if (Saltlen >= 0)
pad_mode = RSA_PKCS1_PSS_PADDING;
else
pad_mode = RSA_PKCS1_PADDING;
- if (!EVP_DigestInit_ex(&ctx, dgst, NULL))
+ if (!FIPS_digestinit(&ctx, dgst))
goto error;
- if (!EVP_DigestUpdate(&ctx, Msg, Msglen))
+ if (!FIPS_digestupdate(&ctx, Msg, Msglen))
goto error;
if (!FIPS_rsa_sign_ctx(rsa, &ctx, pad_mode, Saltlen, NULL,
sigbuf, (unsigned int *)&siglen))
goto error;
- EVP_MD_CTX_cleanup(&ctx);
+ FIPS_md_ctx_cleanup(&ctx);
fputs("S = ", out);
if (!rsa_pubkey->n || !rsa_pubkey->e)
goto error;
- EVP_MD_CTX_init(&ctx);
+ FIPS_md_ctx_init(&ctx);
if (Saltlen >= 0)
pad_mode = RSA_PKCS1_PSS_PADDING;
else
pad_mode = RSA_PKCS1_PADDING;
- if (!EVP_DigestInit_ex(&ctx, dgst, NULL))
+ if (!FIPS_digestinit(&ctx, dgst))
goto error;
- if (!EVP_DigestUpdate(&ctx, Msg, Msglen))
+ if (!FIPS_digestupdate(&ctx, Msg, Msglen))
goto error;
no_err = 1;
no_err = 0;
- EVP_MD_CTX_cleanup(&ctx);
+ FIPS_md_ctx_cleanup(&ctx);
if (r < 0)
goto error;
{
unsigned char md[SHA_DIGEST_LENGTH];
- EVP_Digest(test[n],strlen(test[n]),md, NULL, EVP_sha1(), NULL);
+ FIPS_digest(test[n],strlen(test[n]),md, NULL, EVP_sha1());
if(memcmp(md,ret[n],sizeof md))
{
FIPSerr(FIPS_F_FIPS_SELFTEST_SHA1,FIPS_R_SELFTEST_FAILED);
{
int i, mdlen;
unsigned char md[EVP_MAX_MD_SIZE];
- if (!EVP_Digest(Msg, Msglen, md, (unsigned int *)&mdlen, emd, NULL))
+ if (!FIPS_digest(Msg, Msglen, md, (unsigned int *)&mdlen, emd))
{
fputs("Error calculating HASH\n", stderr);
return 0;
unsigned char *m1, *m2, *m3, *p;
unsigned int mlen, m1len, m2len, m3len;
- EVP_MD_CTX_init(&ctx);
+ FIPS_md_ctx_init(&ctx);
if (SeedLen > EVP_MAX_MD_SIZE)
mlen = SeedLen;
{
for (i = 0; i < 1000; i++)
{
- EVP_DigestInit_ex(&ctx, md, NULL);
- EVP_DigestUpdate(&ctx, m1, m1len);
- EVP_DigestUpdate(&ctx, m2, m2len);
- EVP_DigestUpdate(&ctx, m3, m3len);
+ FIPS_digestinit(&ctx, md);
+ FIPS_digestupdate(&ctx, m1, m1len);
+ FIPS_digestupdate(&ctx, m2, m2len);
+ FIPS_digestupdate(&ctx, m3, m3len);
p = m1;
m1 = m2;
m1len = m2len;
m2 = m3;
m2len = m3len;
m3 = p;
- EVP_DigestFinal_ex(&ctx, m3, &m3len);
+ FIPS_digestfinal(&ctx, m3, &m3len);
}
fprintf(out, "COUNT = %d\n", j);
fputs("MD = ", out);
if (m3)
OPENSSL_free(m3);
- EVP_MD_CTX_cleanup(&ctx);
+ FIPS_md_ctx_cleanup(&ctx);
return ret;
}
/* This call frees resources associated with the context */
int FIPS_md_ctx_cleanup(EVP_MD_CTX *ctx)
{
- /* Don't assume ctx->md_data was cleaned in EVP_Digest_Final,
+ /* Don't assume ctx->md_data was cleaned in FIPS_digest_Final,
* because sometimes only copies of the context are ever finalised.
*/
if (ctx->digest && ctx->digest->cleanup