本文整理汇总了C++中EVP_sha384函数的典型用法代码示例。如果您正苦于以下问题:C++ EVP_sha384函数的具体用法?C++ EVP_sha384怎么用?C++ EVP_sha384使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EVP_sha384函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isc_hmacsha384_init
void
isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
unsigned int len)
{
#ifdef HMAC_RETURN_INT
RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
(int) len, EVP_sha384()) == 1);
#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha384());
#endif
}
示例2: setup
static EVP_MD_CTX *
setup(jose_cfg_t *cfg, const json_t *jwk, const json_t *sig, const char *alg,
init_t *func)
{
openssl_auto(EVP_PKEY) *key = NULL;
EVP_PKEY_CTX *epc = NULL;
const EVP_MD *md = NULL;
EVP_MD_CTX *emc = NULL;
const RSA *rsa = NULL;
int slen = 0;
int pad = 0;
switch (str2enum(alg, NAMES, NULL)) {
case 0: md = EVP_sha256(); pad = RSA_PKCS1_PADDING; break;
case 1: md = EVP_sha384(); pad = RSA_PKCS1_PADDING; break;
case 2: md = EVP_sha512(); pad = RSA_PKCS1_PADDING; break;
case 3: md = EVP_sha256(); pad = RSA_PKCS1_PSS_PADDING; slen = -1; break;
case 4: md = EVP_sha384(); pad = RSA_PKCS1_PSS_PADDING; slen = -1; break;
case 5: md = EVP_sha512(); pad = RSA_PKCS1_PSS_PADDING; slen = -1; break;
default: return NULL;
}
key = jose_openssl_jwk_to_EVP_PKEY(cfg, jwk);
if (!key || EVP_PKEY_base_id(key) != EVP_PKEY_RSA)
return NULL;
/* Don't use small keys. RFC 7518 3.3 */
rsa = EVP_PKEY_get0_RSA(key);
if (!rsa)
return NULL;
if (RSA_size(rsa) < 2048 / 8)
return NULL;
emc = EVP_MD_CTX_new();
if (!emc)
return NULL;
if (func(emc, &epc, md, NULL, key) <= 0)
goto error;
if (EVP_PKEY_CTX_set_rsa_padding(epc, pad) <= 0)
goto error;
if (slen != 0) {
if (EVP_PKEY_CTX_set_rsa_pss_saltlen(epc, slen) <= 0)
goto error;
}
return emc;
error:
EVP_MD_CTX_free(emc);
return NULL;
}
示例3: hsh
static jose_io_t *
hsh(const jose_hook_alg_t *alg, jose_cfg_t *cfg, jose_io_t *next)
{
jose_io_auto_t *io = NULL;
const EVP_MD *md = NULL;
io_t *i = NULL;
switch (str2enum(alg->name, "S512", "S384", "S256", "S224", "S1", NULL)) {
case 0: md = EVP_sha512(); break;
case 1: md = EVP_sha384(); break;
case 2: md = EVP_sha256(); break;
case 3: md = EVP_sha224(); break;
case 4: md = EVP_sha1(); break;
}
i = calloc(1, sizeof(*i));
if (!i)
return NULL;
io = jose_io_incref(&i->io);
io->feed = hsh_feed;
io->done = hsh_done;
io->free = hsh_free;
i->next = jose_io_incref(next);
i->emc = EVP_MD_CTX_new();
if (!i->next || !i->emc)
return NULL;
if (EVP_DigestInit(i->emc, md) <= 0)
return NULL;
return jose_io_incref(io);
}
示例4: makeecreq384
void makeecreq384(char* commonname)
{
EC_KEY *key;
EVP_PKEY *pkey;
X509_REQ *req;
FILE *out;
key = EC_KEY_new_by_curve_name(NID_secp384r1);
EC_KEY_generate_key(key);
EC_KEY_set_asn1_flag(key, OPENSSL_EC_NAMED_CURVE);
pkey = EVP_PKEY_new();
EVP_PKEY_set1_EC_KEY(pkey, key);
req = makereq(pkey, commonname, EVP_sha384());
out = fopen("ec384_req.pem", "w");
if (out == NULL)
exit(-1);
PEM_write_X509_REQ(out, req);
fclose(out);
out = fopen("ec384_req_key.pem", "w");
if (out == NULL)
exit(-1);
PEM_write_ECPrivateKey(out, key, NULL, NULL, 0, NULL, NULL);
fclose(out);
}
示例5: opensslecdsa_createctx
static isc_result_t
opensslecdsa_createctx(dst_key_t *key, dst_context_t *dctx) {
EVP_MD_CTX *evp_md_ctx;
const EVP_MD *type = NULL;
UNUSED(key);
REQUIRE(dctx->key->key_alg == DST_ALG_ECDSA256 ||
dctx->key->key_alg == DST_ALG_ECDSA384);
evp_md_ctx = EVP_MD_CTX_create();
if (evp_md_ctx == NULL)
return (ISC_R_NOMEMORY);
if (dctx->key->key_alg == DST_ALG_ECDSA256)
type = EVP_sha256();
else
type = EVP_sha384();
if (!EVP_DigestInit_ex(evp_md_ctx, type, NULL)) {
EVP_MD_CTX_destroy(evp_md_ctx);
return (dst__openssl_toresult3(dctx->category,
"EVP_DigestInit_ex",
ISC_R_FAILURE));
}
dctx->ctxdata.evp_md_ctx = evp_md_ctx;
return (ISC_R_SUCCESS);
}
示例6: tsig_get_EVP_MD
const EVP_MD *
tsig_get_EVP_MD(u8 algorithm)
{
switch(algorithm)
{
#ifndef OPENSSL_NO_MD5
case HMAC_MD5:
return EVP_md5();
#endif
#ifndef OPENSSL_NO_SHA
case HMAC_SHA1:
return EVP_sha1();
#endif
#ifndef OPENSSL_NO_SHA256
case HMAC_SHA224:
return EVP_sha224();
case HMAC_SHA256:
return EVP_sha256();
#endif
#ifndef OPENSSL_NO_SHA512
case HMAC_SHA384:
return EVP_sha384();
case HMAC_SHA512:
return EVP_sha512();
#endif
default:
return EVP_md_null();
}
}
示例7: OpenSSL_add_all_digests
void
OpenSSL_add_all_digests(void)
{
#ifndef OPENSSL_NO_MD4
EVP_add_digest(EVP_md4());
#endif
#ifndef OPENSSL_NO_MD5
EVP_add_digest(EVP_md5());
EVP_add_digest_alias(SN_md5, "ssl2-md5");
EVP_add_digest_alias(SN_md5, "ssl3-md5");
#endif
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0)
EVP_add_digest(EVP_sha());
#ifndef OPENSSL_NO_DSA
EVP_add_digest(EVP_dss());
#endif
#endif
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
EVP_add_digest(EVP_sha1());
EVP_add_digest_alias(SN_sha1, "ssl3-sha1");
EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA);
#ifndef OPENSSL_NO_DSA
EVP_add_digest(EVP_dss1());
EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2);
EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1");
EVP_add_digest_alias(SN_dsaWithSHA1, "dss1");
#endif
#ifndef OPENSSL_NO_ECDSA
EVP_add_digest(EVP_ecdsa());
#endif
#endif
#ifndef OPENSSL_NO_GOST
EVP_add_digest(EVP_gostr341194());
EVP_add_digest(EVP_gost2814789imit());
EVP_add_digest(EVP_streebog256());
EVP_add_digest(EVP_streebog512());
#endif
#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
EVP_add_digest(EVP_mdc2());
#endif
#ifndef OPENSSL_NO_RIPEMD
EVP_add_digest(EVP_ripemd160());
EVP_add_digest_alias(SN_ripemd160, "ripemd");
EVP_add_digest_alias(SN_ripemd160, "rmd160");
#endif
#ifndef OPENSSL_NO_SHA256
EVP_add_digest(EVP_sha224());
EVP_add_digest(EVP_sha256());
#endif
#ifndef OPENSSL_NO_SHA512
EVP_add_digest(EVP_sha384());
EVP_add_digest(EVP_sha512());
#endif
#ifndef OPENSSL_NO_WHIRLPOOL
EVP_add_digest(EVP_whirlpool());
#endif
}
示例8: d
CryptoBuffer::CryptoBuffer(const char *pass)
: d(new Private())
{
d->password = pass;
d->cipher = EVP_aes_256_cbc();
d->digest = EVP_sha384();
}
示例9: s2n_evp_hmac_p_hash_init
static int s2n_evp_hmac_p_hash_init(struct s2n_prf_working_space *ws, s2n_hmac_algorithm alg, struct s2n_blob *secret)
{
/* Initialize the message digest */
switch (alg) {
case S2N_HMAC_SSLv3_MD5:
case S2N_HMAC_MD5:
ws->tls.p_hash.evp_hmac.evp_digest.md = EVP_md5();
break;
case S2N_HMAC_SSLv3_SHA1:
case S2N_HMAC_SHA1:
ws->tls.p_hash.evp_hmac.evp_digest.md = EVP_sha1();
break;
case S2N_HMAC_SHA224:
ws->tls.p_hash.evp_hmac.evp_digest.md = EVP_sha224();
break;
case S2N_HMAC_SHA256:
ws->tls.p_hash.evp_hmac.evp_digest.md = EVP_sha256();
break;
case S2N_HMAC_SHA384:
ws->tls.p_hash.evp_hmac.evp_digest.md = EVP_sha384();
break;
case S2N_HMAC_SHA512:
ws->tls.p_hash.evp_hmac.evp_digest.md = EVP_sha512();
break;
default:
S2N_ERROR(S2N_ERR_P_HASH_INVALID_ALGORITHM);
}
/* Initialize the mac key using the provided secret */
notnull_check(ws->tls.p_hash.evp_hmac.mac_key = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, secret->data, secret->size));
/* Initialize the message digest context with the above message digest and mac key */
return s2n_evp_hmac_p_hash_digest_init(ws);
}
示例10: lws_genhash_init
int
lws_genhash_init(struct lws_genhash_ctx *ctx, enum lws_genhash_types type)
{
ctx->type = type;
ctx->mdctx = EVP_MD_CTX_create();
if (!ctx->mdctx)
return 1;
switch (ctx->type) {
case LWS_GENHASH_TYPE_SHA1:
ctx->evp_type = EVP_sha1();
break;
case LWS_GENHASH_TYPE_SHA256:
ctx->evp_type = EVP_sha256();
break;
case LWS_GENHASH_TYPE_SHA384:
ctx->evp_type = EVP_sha384();
break;
case LWS_GENHASH_TYPE_SHA512:
ctx->evp_type = EVP_sha512();
break;
default:
return 1;
}
if (EVP_DigestInit_ex(ctx->mdctx, ctx->evp_type, NULL) != 1) {
EVP_MD_CTX_destroy(ctx->mdctx);
return 1;
}
return 0;
}
示例11: FIPS_hmac_sha384_test
/* HMAC-SHA384: generate hash of known digest value and compare to known
precomputed correct hash
*/
static int FIPS_hmac_sha384_test()
{
unsigned char key[] = "etaonrishd";
unsigned char iv[] = "Sample text";
unsigned char kaval[EVP_MAX_MD_SIZE] =
{ 0xb2, 0x9d, 0x40, 0x58, 0x32, 0xc4, 0xe3, 0x31, 0xb6, 0x63, 0x08,
0x26, 0x99, 0xef, 0x3b, 0x10,
0xe2, 0xdf, 0xf8, 0xff, 0xc6, 0xe1, 0x03, 0x29, 0x81, 0x2a, 0x1b,
0xac, 0xb0, 0x07, 0x39, 0x08,
0xf3, 0x91, 0x35, 0x11, 0x76, 0xd6, 0x4c, 0x20, 0xfb, 0x4d, 0xc3,
0xf3, 0xb8, 0x9b, 0x88, 0x1c
};
unsigned char out[EVP_MAX_MD_SIZE];
unsigned int outlen;
ERR_clear_error();
if (!HMAC
(EVP_sha384(), key, sizeof(key) - 1, iv, sizeof(iv) - 1, out,
&outlen))
return 0;
if (memcmp(out, kaval, outlen))
return 0;
return 1;
}
示例12: switch
bool OpensslManager::HMACString(Openssl_Hash algorithm, char *key, int key_len, unsigned char *input, int input_len, unsigned char *output, unsigned int *outlength)
{
switch(algorithm)
{
case Openssl_Hash_MD5:
HMAC(EVP_md5(), key, key_len, input, input_len, output, outlength);
return true;
case Openssl_Hash_MD4:
HMAC(EVP_md4(), key, key_len, input, input_len, output, outlength);
return true;
case Openssl_Hash_SHA:
HMAC(EVP_sha(), key, key_len, input, input_len, output, outlength);
return true;
case Openssl_Hash_SHA1:
HMAC(EVP_sha1(), key, key_len, input, input_len, output, outlength);
return true;
case Openssl_Hash_SHA224:
HMAC(EVP_sha224(), key, key_len, input, input_len, output, outlength);
return true;
case Openssl_Hash_SHA256:
HMAC(EVP_sha256(), key, key_len, input, input_len, output, outlength);
return true;
case Openssl_Hash_SHA384:
HMAC(EVP_sha384(), key, key_len, input, input_len, output, outlength);
return true;
case Openssl_Hash_SHA512:
HMAC(EVP_sha512(), key, key_len, input, input_len, output, outlength);
return true;
case Openssl_Hash_RIPEMD160:
HMAC(EVP_ripemd160(), key, key_len, input, input_len, output, outlength);
return true;
}
return false;
}
示例13: FIPS_selftest_dsa
int FIPS_selftest_dsa()
{
DSA *dsa=NULL;
EVP_PKEY pk;
int ret = 0;
dsa = FIPS_dsa_new();
if(dsa == NULL)
goto err;
fips_load_key_component(dsa, p, dsa_test_2048);
fips_load_key_component(dsa, q, dsa_test_2048);
fips_load_key_component(dsa, g, dsa_test_2048);
fips_load_key_component(dsa, pub_key, dsa_test_2048);
fips_load_key_component(dsa, priv_key, dsa_test_2048);
pk.type = EVP_PKEY_DSA;
pk.pkey.dsa = dsa;
if (!fips_pkey_signature_test(FIPS_TEST_SIGNATURE, &pk, NULL, 0,
NULL, 0, EVP_sha384(), 0,
"DSA SHA384"))
goto err;
ret = 1;
err:
if (dsa)
FIPS_dsa_free(dsa);
return ret;
}
示例14: switch
const EVP_MD *get_hash(enum enum_hash hash, const unsigned char **oid, size_t *oid_len) {
switch(hash) {
case hash_arg_SHA1:
if(oid) {
*oid = sha1oid;
*oid_len = sizeof(sha1oid);
}
return EVP_sha1();
case hash_arg_SHA256:
if(oid) {
*oid = sha256oid;
*oid_len = sizeof(sha256oid);
}
return EVP_sha256();
case hash_arg_SHA384:
if(oid) {
*oid = sha384oid;
*oid_len = sizeof(sha384oid);
}
return EVP_sha384();
case hash_arg_SHA512:
if(oid) {
*oid = sha512oid;
*oid_len = sizeof(sha512oid);
}
return EVP_sha512();
case hash__NULL:
default:
return NULL;
}
}
示例15: openssl_add_all_digests_internal
void openssl_add_all_digests_internal(void)
{
#ifndef OPENSSL_NO_MD4
EVP_add_digest(EVP_md4());
#endif
#ifndef OPENSSL_NO_MD5
EVP_add_digest(EVP_md5());
EVP_add_digest_alias(SN_md5, "ssl3-md5");
EVP_add_digest(EVP_md5_sha1());
#endif
EVP_add_digest(EVP_sha1());
EVP_add_digest_alias(SN_sha1, "ssl3-sha1");
EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA);
#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
EVP_add_digest(EVP_mdc2());
#endif
#ifndef OPENSSL_NO_RMD160
EVP_add_digest(EVP_ripemd160());
EVP_add_digest_alias(SN_ripemd160, "ripemd");
EVP_add_digest_alias(SN_ripemd160, "rmd160");
#endif
EVP_add_digest(EVP_sha224());
EVP_add_digest(EVP_sha256());
EVP_add_digest(EVP_sha384());
EVP_add_digest(EVP_sha512());
#ifndef OPENSSL_NO_WHIRLPOOL
EVP_add_digest(EVP_whirlpool());
#endif
}