/*
- * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2000-2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Flora License, Version 1.1 (the License);
* you may not use this file except in compliance with the License.
#include <openssl/sha.h>
#include <openssl/dh.h>
#include <openssl/bn.h>
+#include <openssl/modes.h>
//2011.03.08 to verify signature
#include <openssl/x509.h>
};
BYTE generator[1] = {DH_GENERATOR_5};
- pDH->p = BN_bin2bn(prime64, 64, NULL);
- pDH->g = BN_bin2bn(generator, 1, NULL);
+ DH_set0_pqg(pDH, BN_bin2bn(prime64, 64, NULL), nullptr,
+ BN_bin2bn(generator, 1, NULL));
/* Set a to run with normal modexp and b to use constant time */
- pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
+ DH_clear_flags(pDH, DH_FLAG_NO_EXP_CONSTTIME);
// Debug
DRM_TAPPS_LOG("After Set the Prime and Generator Value");
TADC_IF_MemCpy(t_dhinfo->p, prime64, 64);
t_dhinfo->pSize = 64;
t_dhinfo->g = DH_GENERATOR_5;
- t_dhinfo->ASize = BN_bn2bin(pDH->pub_key, t_dhinfo->A);
- t_dhinfo->aSize = BN_bn2bin(pDH->priv_key, t_dhinfo->a);
+ t_dhinfo->ASize = BN_bn2bin(DH_get0_pub_key(pDH), t_dhinfo->A);
+ t_dhinfo->aSize = BN_bn2bin(DH_get0_priv_key(pDH), t_dhinfo->a);
//5. DH Free
DH_free(pDH);
}
//2.Set DH Info to pDH
- pDH->p = BN_bin2bn(t_dhinfo->p, t_dhinfo->pSize, NULL);
tempG[0] = t_dhinfo->g;
- pDH->g = BN_bin2bn(tempG, 1, NULL);
- pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
- pDH->pub_key = BN_bin2bn(t_dhinfo->A, t_dhinfo->ASize, NULL);
- pDH->priv_key = BN_bin2bn(t_dhinfo->a, t_dhinfo->aSize, NULL);
+ DH_set0_pqg(pDH, BN_bin2bn(t_dhinfo->p, t_dhinfo->pSize, NULL), nullptr,
+ BN_bin2bn(tempG, 1, NULL));
+ DH_clear_flags(pDH, DH_FLAG_NO_EXP_CONSTTIME);
+ DH_set0_key(pDH, BN_bin2bn(t_dhinfo->A, t_dhinfo->ASize, NULL),
+ BN_bin2bn(t_dhinfo->a, t_dhinfo->aSize, NULL));
//3. Set Public Key of Server
pPubKey = BN_bin2bn(t_dhinfo->B, t_dhinfo->BSize, NULL);
TADC_IF_MemSet(chain, 0, sizeof(chain));
TADC_IF_MemCpy(chain, pIV, ivLen);
- AES_ctr128_encrypt(in, out, inLen, &stKey, chain, ecount, &num);
+ CRYPTO_ctr128_encrypt(in, out, inLen, &stKey, chain, ecount, &num, (block128_f)AES_encrypt);
*pOutLen = inLen;
int TADC_IF_VerifyCertChain(unsigned char *rica, int ricaLen,
unsigned char *cert, int certLen)
{
- OpenSSL_add_all_algorithms();
-
X509_STORE *pstStore = X509_STORE_new();
if (pstStore == NULL)
/*
- * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2000-2019 Samsung Electronics Co., Ltd. All rights reserved
*
* Licensed under the Flora License, Version 1.1 (the License);
* you may not use this file except in compliance with the License.
};
-int __initialized = _UNINITIALIZED;
-
-void __init_crypto()
-{
- if (__initialized != _INITIALIZED) {
- ERR_load_crypto_strings();
- OpenSSL_add_all_algorithms();
- __initialized = _INITIALIZED;
- }
-}
-
int __get_random_bytes(char *output, int random_len)
{
FILE *fp = fopen("/dev/urandom", "r");
{
int ret = DRMTEST_SUCCESS;
DH *pDH = NULL;
+ BIGNUM *p = NULL, *g = NULL;
if ((pDH = DH_new()) == NULL) {
printf("...FAIL: DH_new() error");
goto error;
}
- BN_hex2bn(&(pDH->p), dh_key_p_hex);
- BN_hex2bn(&(pDH->g), dh_key_g_hex);
+ BN_hex2bn(&p, dh_key_p_hex);
+ BN_hex2bn(&g, dh_key_g_hex);
+ DH_set0_pqg(pDH, p, nullptr, g);
/* Set a to run with normal modexp and b to use constant time */
- pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
+ DH_clear_flags(pDH, DH_FLAG_NO_EXP_CONSTTIME);
// Generate DH Key
if (!DH_generate_key(pDH)) {
int _get_dh_hex_pubkey(const DH *pkey, char **dh_pubkey)
{
- *dh_pubkey = BN_bn2hex(pkey->pub_key);
+ *dh_pubkey = BN_bn2hex(DH_get0_pub_key(pkey));
return DRMTEST_SUCCESS;
}