diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-11-09 19:27:30 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-11-09 19:27:30 +0000 |
commit | 3851feb7d149b628e742cab988df537ac3b64d63 (patch) | |
tree | 68ab95c8600ab912f023a31c6bc444462cb277fb /lib | |
parent | f8aedc0ef90954d6a0cedd699feb3c6bbf2649a5 (diff) |
Rename internal yet public key_{un,}wrap_crypto_pro symbols by prepending a
`gost_' prefix to them, so that we do not pollute the global namespace too
much.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libssl/src/crypto/gost/gost89_keywrap.c | 25 | ||||
-rw-r--r-- | lib/libssl/src/crypto/gost/gost_locl.h | 31 | ||||
-rw-r--r-- | lib/libssl/src/crypto/gost/gostr341001_pmeth.c | 6 |
3 files changed, 32 insertions, 30 deletions
diff --git a/lib/libssl/src/crypto/gost/gost89_keywrap.c b/lib/libssl/src/crypto/gost/gost89_keywrap.c index 8f641b6cef6..fa7698d3f76 100644 --- a/lib/libssl/src/crypto/gost/gost89_keywrap.c +++ b/lib/libssl/src/crypto/gost/gost89_keywrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gost89_keywrap.c,v 1.1 2014/11/09 19:17:13 miod Exp $ */ +/* $OpenBSD: gost89_keywrap.c,v 1.2 2014/11/09 19:27:29 miod Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> * Copyright (c) 2005-2006 Cryptocom LTD @@ -59,14 +59,15 @@ #include "gost_locl.h" -static void key_diversify_crypto_pro(GOST2814789_KEY * ctx, const unsigned char *inputKey, - const unsigned char *ukm, unsigned char *outputKey) +static void +key_diversify_crypto_pro(GOST2814789_KEY *ctx, const unsigned char *inputKey, + const unsigned char *ukm, unsigned char *outputKey) { - unsigned long k, s1, s2; int i, mask; unsigned char S[8]; unsigned char *p; + memcpy(outputKey, inputKey, 32); for (i = 0; i < 8; i++) { /* Make array of integers from key */ @@ -86,13 +87,15 @@ static void key_diversify_crypto_pro(GOST2814789_KEY * ctx, const unsigned char l2c (s2, p); Gost2814789_set_key(ctx, outputKey, 256); mask = 0; - Gost2814789_cfb64_encrypt(outputKey, outputKey, 32, ctx, S, &mask, 1); + Gost2814789_cfb64_encrypt(outputKey, outputKey, 32, ctx, S, + &mask, 1); } } -int key_wrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, - const unsigned char *ukm, const unsigned char *sessionKey, - unsigned char *wrappedKey) +int +gost_key_wrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, + const unsigned char *ukm, const unsigned char *sessionKey, + unsigned char *wrappedKey) { GOST2814789_KEY ctx; unsigned char kek_ukm[32]; @@ -109,9 +112,9 @@ int key_wrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, return 1; } -int key_unwrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, - const unsigned char *wrappedKey, - unsigned char *sessionKey) +int +gost_key_unwrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, + const unsigned char *wrappedKey, unsigned char *sessionKey) { unsigned char kek_ukm[32], cek_mac[4]; GOST2814789_KEY ctx; diff --git a/lib/libssl/src/crypto/gost/gost_locl.h b/lib/libssl/src/crypto/gost/gost_locl.h index b616005dc5e..202ba39688c 100644 --- a/lib/libssl/src/crypto/gost/gost_locl.h +++ b/lib/libssl/src/crypto/gost/gost_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gost_locl.h,v 1.1 2014/11/09 19:17:13 miod Exp $ */ +/* $OpenBSD: gost_locl.h,v 1.2 2014/11/09 19:27:29 miod Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> * Copyright (c) 2005-2006 Cryptocom LTD @@ -88,22 +88,21 @@ extern void Gost2814789_decrypt(const unsigned char *in, unsigned char *out, extern void Gost2814789_cryptopro_key_mesh(GOST2814789_KEY *key); /* GOST 28147-89 key wrapping */ -extern int key_unwrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, - const unsigned char *wrappedKey, - unsigned char *sessionKey); -extern int key_wrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, - const unsigned char *ukm, const unsigned char *sessionKey, - unsigned char *wrappedKey); +extern int gost_key_unwrap_crypto_pro(int nid, + const unsigned char *keyExchangeKey, const unsigned char *wrappedKey, + unsigned char *sessionKey); +extern int gost_key_wrap_crypto_pro(int nid, + const unsigned char *keyExchangeKey, const unsigned char *ukm, + const unsigned char *sessionKey, unsigned char *wrappedKey); /* Pkey part */ -extern int gost2001_compute_public(GOST_KEY * ec); -extern ECDSA_SIG *gost2001_do_sign(BIGNUM * md, GOST_KEY * eckey); -extern int gost2001_do_verify(BIGNUM * md, ECDSA_SIG * sig, GOST_KEY * ec); -extern int gost2001_keygen(GOST_KEY * ec); -extern void VKO_compute_key(BIGNUM * X, BIGNUM * Y, - const GOST_KEY * pkey, GOST_KEY * priv_key, - const BIGNUM * ukm); -extern BIGNUM *GOST_le2bn(const unsigned char * buf, size_t len, BIGNUM * bn); -extern int GOST_bn2le(BIGNUM * bn, unsigned char * buf, int len); +extern int gost2001_compute_public(GOST_KEY *ec); +extern ECDSA_SIG *gost2001_do_sign(BIGNUM *md, GOST_KEY *eckey); +extern int gost2001_do_verify(BIGNUM *md, ECDSA_SIG *sig, GOST_KEY *ec); +extern int gost2001_keygen(GOST_KEY *ec); +extern void VKO_compute_key(BIGNUM *X, BIGNUM *Y, const GOST_KEY *pkey, + GOST_KEY *priv_key, const BIGNUM *ukm); +extern BIGNUM *GOST_le2bn(const unsigned char *buf, size_t len, BIGNUM *bn); +extern int GOST_bn2le(BIGNUM *bn, unsigned char *buf, int len); /* GOST R 34.10 parameters */ extern int GostR3410_get_md_digest(int nid); diff --git a/lib/libssl/src/crypto/gost/gostr341001_pmeth.c b/lib/libssl/src/crypto/gost/gostr341001_pmeth.c index 910c0b9c45d..c7001fc1fa0 100644 --- a/lib/libssl/src/crypto/gost/gostr341001_pmeth.c +++ b/lib/libssl/src/crypto/gost/gostr341001_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_pmeth.c,v 1.2 2014/11/09 19:24:30 miod Exp $ */ +/* $OpenBSD: gostr341001_pmeth.c,v 1.3 2014/11/09 19:27:29 miod Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> * Copyright (c) 2005-2006 Cryptocom LTD @@ -396,7 +396,7 @@ int pkey_gost01_decrypt(EVP_PKEY_CTX * pctx, unsigned char *key, OPENSSL_assert(gkt->key_info->imit->length == 4); memcpy(wrappedKey + 40, gkt->key_info->imit->data, 4); gost01_VKO_key(peerkey, priv, wrappedKey, sharedKey); - if (!key_unwrap_crypto_pro(nid, sharedKey, wrappedKey, key)) { + if (!gost_key_unwrap_crypto_pro(nid, sharedKey, wrappedKey, key)) { GOSTerr(GOST_F_PKEY_GOST01_DECRYPT, GOST_R_ERROR_COMPUTING_SHARED_KEY); goto err; @@ -478,7 +478,7 @@ int pkey_gost01_encrypt(EVP_PKEY_CTX * pctx, unsigned char *out, if (out) { gost01_VKO_key(pubk, sec_key, ukm, shared_key); - key_wrap_crypto_pro(nid, shared_key, ukm, key, crypted_key); + gost_key_wrap_crypto_pro(nid, shared_key, ukm, key, crypted_key); } gkt = GOST_KEY_TRANSPORT_new(); if (!gkt) { |