summaryrefslogtreecommitdiff
path: root/lib/libssl
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2014-05-07 17:42:52 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2014-05-07 17:42:52 +0000
commit4692d42498b1c995d3d597132c948250ca65ea9e (patch)
tree03301ec5a42472a553125e115f127784ccc1230b /lib/libssl
parent93f851c4f6c86fb5285cda17df6fbb9f5810cd18 (diff)
KNF.
Diffstat (limited to 'lib/libssl')
-rw-r--r--lib/libssl/src/crypto/evp/p5_crpt.c33
-rw-r--r--lib/libssl/src/crypto/evp/p5_crpt2.c169
-rw-r--r--lib/libssl/src/crypto/evp/p_dec.c38
-rw-r--r--lib/libssl/src/crypto/evp/p_enc.c36
-rw-r--r--lib/libssl/src/crypto/evp/p_lib.c351
-rw-r--r--lib/libssl/src/crypto/evp/p_open.c83
-rw-r--r--lib/libssl/src/crypto/evp/p_seal.c59
-rw-r--r--lib/libssl/src/crypto/evp/p_sign.c94
-rw-r--r--lib/libssl/src/crypto/evp/p_verify.c73
-rw-r--r--lib/libssl/src/crypto/evp/pmeth_fn.c279
-rw-r--r--lib/libssl/src/crypto/evp/pmeth_gn.c132
-rw-r--r--lib/libssl/src/crypto/evp/pmeth_lib.c458
12 files changed, 922 insertions, 883 deletions
diff --git a/lib/libssl/src/crypto/evp/p5_crpt.c b/lib/libssl/src/crypto/evp/p5_crpt.c
index 294cc90d878..eff82e8c0bf 100644
--- a/lib/libssl/src/crypto/evp/p5_crpt.c
+++ b/lib/libssl/src/crypto/evp/p5_crpt.c
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -65,13 +65,14 @@
/* Doesn't do anything now: Builtin PBE algorithms in static table.
*/
-void PKCS5_PBE_add(void)
+void
+PKCS5_PBE_add(void)
{
}
-int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
- ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
- int en_de)
+int
+PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de)
{
EVP_MD_CTX ctx;
unsigned char md_tmp[EVP_MAX_MD_SIZE];
@@ -88,23 +89,27 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
/* Extract useful info from parameter */
if (param == NULL || param->type != V_ASN1_SEQUENCE ||
param->value.sequence == NULL) {
- EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
+ EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_DECODE_ERROR);
return 0;
}
pbuf = param->value.sequence->data;
if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) {
- EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
+ EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_DECODE_ERROR);
return 0;
}
- if (!pbe->iter) iter = 1;
- else iter = ASN1_INTEGER_get (pbe->iter);
+ if (!pbe->iter)
+ iter = 1;
+ else
+ iter = ASN1_INTEGER_get (pbe->iter);
salt = pbe->salt->data;
saltlen = pbe->salt->length;
- if(!pass) passlen = 0;
- else if(passlen == -1) passlen = strlen(pass);
+ if (!pass)
+ passlen = 0;
+ else if (passlen == -1)
+ passlen = strlen(pass);
if (!EVP_DigestInit_ex(&ctx, md, NULL))
goto err;
@@ -117,7 +122,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
goto err;
mdsize = EVP_MD_size(md);
if (mdsize < 0)
- return 0;
+ return 0;
for (i = 1; i < iter; i++) {
if (!EVP_DigestInit_ex(&ctx, md, NULL))
goto err;
@@ -130,14 +135,14 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher));
OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16);
memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)),
- EVP_CIPHER_iv_length(cipher));
+ EVP_CIPHER_iv_length(cipher));
if (!EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de))
goto err;
OPENSSL_cleanse(md_tmp, EVP_MAX_MD_SIZE);
OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH);
OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH);
rv = 1;
- err:
+err:
EVP_MD_CTX_cleanup(&ctx);
return rv;
}
diff --git a/lib/libssl/src/crypto/evp/p5_crpt2.c b/lib/libssl/src/crypto/evp/p5_crpt2.c
index fe3c6c8813c..c276cd28b82 100644
--- a/lib/libssl/src/crypto/evp/p5_crpt2.c
+++ b/lib/libssl/src/crypto/evp/p5_crpt2.c
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -68,7 +68,7 @@
/* #define DEBUG_PKCS5V2 */
#ifdef DEBUG_PKCS5V2
- static void h__dump (const unsigned char *p, int len);
+static void h__dump (const unsigned char *p, int len);
#endif
/* This is an implementation of PKCS#5 v2.0 password based encryption key
@@ -77,11 +77,10 @@
* <pgut001@cs.auckland.ac.nz> to the PKCS-TNG <pkcs-tng@rsa.com> mailing list.
*/
-int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
- const unsigned char *salt, int saltlen, int iter,
- const EVP_MD *digest,
- int keylen, unsigned char *out)
- {
+int
+PKCS5_PBKDF2_HMAC(const char *pass, int passlen, const unsigned char *salt,
+ int saltlen, int iter, const EVP_MD *digest, int keylen, unsigned char *out)
+{
unsigned char digtmp[EVP_MAX_MD_SIZE], *p, itmp[4];
int cplen, j, k, tkeylen, mdlen;
unsigned long i = 1;
@@ -94,18 +93,16 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
HMAC_CTX_init(&hctx_tpl);
p = out;
tkeylen = keylen;
- if(!pass)
+ if (!pass)
passlen = 0;
- else if(passlen == -1)
+ else if (passlen == -1)
passlen = strlen(pass);
- if (!HMAC_Init_ex(&hctx_tpl, pass, passlen, digest, NULL))
- {
+ if (!HMAC_Init_ex(&hctx_tpl, pass, passlen, digest, NULL)) {
HMAC_CTX_cleanup(&hctx_tpl);
return 0;
- }
- while(tkeylen)
- {
- if(tkeylen > mdlen)
+ }
+ while (tkeylen) {
+ if (tkeylen > mdlen)
cplen = mdlen;
else
cplen = tkeylen;
@@ -116,43 +113,38 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
itmp[1] = (unsigned char)((i >> 16) & 0xff);
itmp[2] = (unsigned char)((i >> 8) & 0xff);
itmp[3] = (unsigned char)(i & 0xff);
- if (!HMAC_CTX_copy(&hctx, &hctx_tpl))
- {
+ if (!HMAC_CTX_copy(&hctx, &hctx_tpl)) {
HMAC_CTX_cleanup(&hctx_tpl);
return 0;
- }
- if (!HMAC_Update(&hctx, salt, saltlen)
- || !HMAC_Update(&hctx, itmp, 4)
- || !HMAC_Final(&hctx, digtmp, NULL))
- {
+ }
+ if (!HMAC_Update(&hctx, salt, saltlen) ||
+ !HMAC_Update(&hctx, itmp, 4) ||
+ !HMAC_Final(&hctx, digtmp, NULL)) {
HMAC_CTX_cleanup(&hctx_tpl);
HMAC_CTX_cleanup(&hctx);
return 0;
- }
+ }
HMAC_CTX_cleanup(&hctx);
memcpy(p, digtmp, cplen);
- for(j = 1; j < iter; j++)
- {
- if (!HMAC_CTX_copy(&hctx, &hctx_tpl))
- {
+ for (j = 1; j < iter; j++) {
+ if (!HMAC_CTX_copy(&hctx, &hctx_tpl)) {
HMAC_CTX_cleanup(&hctx_tpl);
return 0;
- }
- if (!HMAC_Update(&hctx, digtmp, mdlen)
- || !HMAC_Final(&hctx, digtmp, NULL))
- {
+ }
+ if (!HMAC_Update(&hctx, digtmp, mdlen) ||
+ !HMAC_Final(&hctx, digtmp, NULL)) {
HMAC_CTX_cleanup(&hctx_tpl);
HMAC_CTX_cleanup(&hctx);
return 0;
- }
+ }
HMAC_CTX_cleanup(&hctx);
- for(k = 0; k < cplen; k++)
+ for (k = 0; k < cplen; k++)
p[k] ^= digtmp[k];
- }
- tkeylen-= cplen;
- i++;
- p+= cplen;
}
+ tkeylen -= cplen;
+ i++;
+ p += cplen;
+ }
HMAC_CTX_cleanup(&hctx_tpl);
#ifdef DEBUG_PKCS5V2
fprintf(stderr, "Password:\n");
@@ -164,15 +156,15 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
h__dump (out, keylen);
#endif
return 1;
- }
+}
-int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
- const unsigned char *salt, int saltlen, int iter,
- int keylen, unsigned char *out)
- {
- return PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, EVP_sha1(),
- keylen, out);
- }
+int
+PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, const unsigned char *salt,
+ int saltlen, int iter, int keylen, unsigned char *out)
+{
+ return PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter,
+ EVP_sha1(), keylen, out);
+}
#ifdef DO_TEST
main()
@@ -181,9 +173,8 @@ main()
unsigned char salt[] = {0x12, 0x34, 0x56, 0x78};
PKCS5_PBKDF2_HMAC_SHA1("password", -1, salt, 4, 5, 4, out);
fprintf(stderr, "Out %02X %02X %02X %02X\n",
- out[0], out[1], out[2], out[3]);
+ out[0], out[1], out[2], out[3]);
}
-
#endif
/* Now the key derivation function itself. This is a bit evil because
@@ -191,9 +182,9 @@ main()
* few of them...
*/
-int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
- ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md,
- int en_de)
+int
+PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
+ ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, int en_de)
{
const unsigned char *pbuf;
int plen;
@@ -204,22 +195,22 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
if (param == NULL || param->type != V_ASN1_SEQUENCE ||
param->value.sequence == NULL) {
- EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
+ EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_DECODE_ERROR);
goto err;
}
pbuf = param->value.sequence->data;
plen = param->value.sequence->length;
- if(!(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) {
- EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
+ if (!(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) {
+ EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_DECODE_ERROR);
goto err;
}
/* See if we recognise the key derivation function */
- if(OBJ_obj2nid(pbe2->keyfunc->algorithm) != NID_id_pbkdf2) {
+ if (OBJ_obj2nid(pbe2->keyfunc->algorithm) != NID_id_pbkdf2) {
EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
- EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION);
+ EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION);
goto err;
}
@@ -228,30 +219,31 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
cipher = EVP_get_cipherbyobj(pbe2->encryption->algorithm);
- if(!cipher) {
+ if (!cipher) {
EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
- EVP_R_UNSUPPORTED_CIPHER);
+ EVP_R_UNSUPPORTED_CIPHER);
goto err;
}
/* Fixup cipher based on AlgorithmIdentifier */
if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, en_de))
goto err;
- if(EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) {
+ if (EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) {
EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
- EVP_R_CIPHER_PARAMETER_ERROR);
+ EVP_R_CIPHER_PARAMETER_ERROR);
goto err;
}
rv = PKCS5_v2_PBKDF2_keyivgen(ctx, pass, passlen,
- pbe2->keyfunc->parameter, c, md, en_de);
- err:
+ pbe2->keyfunc->parameter, c, md, en_de);
+
+err:
PBE2PARAM_free(pbe2);
return rv;
}
-int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
- ASN1_TYPE *param,
- const EVP_CIPHER *c, const EVP_MD *md, int en_de)
+int
+PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
+ ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, int en_de)
{
unsigned char *salt, key[EVP_MAX_KEY_LENGTH];
const unsigned char *pbuf;
@@ -262,27 +254,25 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
PBKDF2PARAM *kdf = NULL;
const EVP_MD *prfmd;
- if (EVP_CIPHER_CTX_cipher(ctx) == NULL)
- {
- EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN,EVP_R_NO_CIPHER_SET);
+ if (EVP_CIPHER_CTX_cipher(ctx) == NULL) {
+ EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_NO_CIPHER_SET);
goto err;
- }
+ }
keylen = EVP_CIPHER_CTX_key_length(ctx);
OPENSSL_assert(keylen <= sizeof key);
/* Decode parameter */
- if(!param || (param->type != V_ASN1_SEQUENCE))
- {
- EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN,EVP_R_DECODE_ERROR);
+ if (!param || (param->type != V_ASN1_SEQUENCE)) {
+ EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_DECODE_ERROR);
goto err;
- }
+ }
pbuf = param->value.sequence->data;
plen = param->value.sequence->length;
- if(!(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen)) ) {
- EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN,EVP_R_DECODE_ERROR);
+ if (!(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen)) ) {
+ EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_DECODE_ERROR);
goto err;
}
@@ -290,9 +280,10 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
/* Now check the parameters of the kdf */
- if(kdf->keylength && (ASN1_INTEGER_get(kdf->keylength) != (int)keylen)){
+ if (kdf->keylength &&
+ (ASN1_INTEGER_get(kdf->keylength) != (int)keylen)){
EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN,
- EVP_R_UNSUPPORTED_KEYLENGTH);
+ EVP_R_UNSUPPORTED_KEYLENGTH);
goto err;
}
@@ -301,22 +292,20 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
else
prf_nid = NID_hmacWithSHA1;
- if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, prf_nid, NULL, &hmac_md_nid, 0))
- {
+ if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, prf_nid, NULL, &hmac_md_nid, 0)) {
EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_PRF);
goto err;
- }
+ }
prfmd = EVP_get_digestbynid(hmac_md_nid);
- if (prfmd == NULL)
- {
+ if (prfmd == NULL) {
EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_PRF);
goto err;
- }
+ }
- if(kdf->salt->type != V_ASN1_OCTET_STRING) {
+ if (kdf->salt->type != V_ASN1_OCTET_STRING) {
EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN,
- EVP_R_UNSUPPORTED_SALT_TYPE);
+ EVP_R_UNSUPPORTED_SALT_TYPE);
goto err;
}
@@ -324,11 +313,12 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
salt = kdf->salt->value.octet_string->data;
saltlen = kdf->salt->value.octet_string->length;
iter = ASN1_INTEGER_get(kdf->iter);
- if(!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, prfmd,
- keylen, key))
+ if (!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, prfmd,
+ keylen, key))
goto err;
rv = EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de);
- err:
+
+err:
OPENSSL_cleanse(key, keylen);
PBKDF2PARAM_free(kdf);
return rv;
@@ -337,8 +327,9 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
#ifdef DEBUG_PKCS5V2
static void h__dump (const unsigned char *p, int len)
{
- for (; len --; p++) fprintf(stderr, "%02X ", *p);
- fprintf(stderr, "\n");
+ for (; len --; p++)
+ fprintf(stderr, "%02X ", *p);
+ fprintf(stderr, "\n");
}
#endif
#endif
diff --git a/lib/libssl/src/crypto/evp/p_dec.c b/lib/libssl/src/crypto/evp/p_dec.c
index 4201dcbad99..e6eb56e2988 100644
--- a/lib/libssl/src/crypto/evp/p_dec.c
+++ b/lib/libssl/src/crypto/evp/p_dec.c
@@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
@@ -66,22 +66,24 @@
#include <openssl/objects.h>
#include <openssl/x509.h>
-int EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl,
- EVP_PKEY *priv)
- {
- int ret= -1;
-
+int
+EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl,
+ EVP_PKEY *priv)
+{
+ int ret = -1;
+
#ifndef OPENSSL_NO_RSA
- if (priv->type != EVP_PKEY_RSA)
- {
+ if (priv->type != EVP_PKEY_RSA) {
#endif
- EVPerr(EVP_F_EVP_PKEY_DECRYPT_OLD,EVP_R_PUBLIC_KEY_NOT_RSA);
+ EVPerr(EVP_F_EVP_PKEY_DECRYPT_OLD, EVP_R_PUBLIC_KEY_NOT_RSA);
#ifndef OPENSSL_NO_RSA
goto err;
- }
+ }
+
+ ret = RSA_private_decrypt(ekl, ek, key, priv->pkey.rsa,
+ RSA_PKCS1_PADDING);
- ret=RSA_private_decrypt(ekl,ek,key,priv->pkey.rsa,RSA_PKCS1_PADDING);
err:
#endif
- return(ret);
- }
+ return (ret);
+}
diff --git a/lib/libssl/src/crypto/evp/p_enc.c b/lib/libssl/src/crypto/evp/p_enc.c
index b5a3a84c41d..a921d729970 100644
--- a/lib/libssl/src/crypto/evp/p_enc.c
+++ b/lib/libssl/src/crypto/evp/p_enc.c
@@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
@@ -66,21 +66,21 @@
#include <openssl/objects.h>
#include <openssl/x509.h>
-int EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key, int key_len,
- EVP_PKEY *pubk)
- {
- int ret=0;
-
+int
+EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key, int key_len,
+ EVP_PKEY *pubk)
+{
+ int ret = 0;
+
#ifndef OPENSSL_NO_RSA
- if (pubk->type != EVP_PKEY_RSA)
- {
+ if (pubk->type != EVP_PKEY_RSA) {
#endif
- EVPerr(EVP_F_EVP_PKEY_ENCRYPT_OLD,EVP_R_PUBLIC_KEY_NOT_RSA);
+ EVPerr(EVP_F_EVP_PKEY_ENCRYPT_OLD, EVP_R_PUBLIC_KEY_NOT_RSA);
#ifndef OPENSSL_NO_RSA
goto err;
- }
- ret=RSA_public_encrypt(key_len,key,ek,pubk->pkey.rsa,RSA_PKCS1_PADDING);
+ }
+ ret = RSA_public_encrypt(key_len, key, ek, pubk->pkey.rsa, RSA_PKCS1_PADDING);
err:
#endif
- return(ret);
- }
+ return (ret);
+}
diff --git a/lib/libssl/src/crypto/evp/p_lib.c b/lib/libssl/src/crypto/evp/p_lib.c
index 5f5f5e328da..97d922d1bab 100644
--- a/lib/libssl/src/crypto/evp/p_lib.c
+++ b/lib/libssl/src/crypto/evp/p_lib.c
@@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
@@ -82,134 +82,138 @@
static void EVP_PKEY_free_it(EVP_PKEY *x);
-int EVP_PKEY_bits(EVP_PKEY *pkey)
- {
+int
+EVP_PKEY_bits(EVP_PKEY *pkey)
+{
if (pkey && pkey->ameth && pkey->ameth->pkey_bits)
return pkey->ameth->pkey_bits(pkey);
return 0;
- }
+}
-int EVP_PKEY_size(EVP_PKEY *pkey)
- {
+int
+EVP_PKEY_size(EVP_PKEY *pkey)
+{
if (pkey && pkey->ameth && pkey->ameth->pkey_size)
return pkey->ameth->pkey_size(pkey);
return 0;
- }
+}
-int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)
- {
+int
+EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)
+{
#ifndef OPENSSL_NO_DSA
- if (pkey->type == EVP_PKEY_DSA)
- {
- int ret=pkey->save_parameters;
+ if (pkey->type == EVP_PKEY_DSA) {
+ int ret = pkey->save_parameters;
if (mode >= 0)
- pkey->save_parameters=mode;
- return(ret);
- }
+ pkey->save_parameters = mode;
+ return (ret);
+ }
#endif
#ifndef OPENSSL_NO_EC
- if (pkey->type == EVP_PKEY_EC)
- {
+ if (pkey->type == EVP_PKEY_EC) {
int ret = pkey->save_parameters;
if (mode >= 0)
pkey->save_parameters = mode;
- return(ret);
- }
-#endif
- return(0);
+ return (ret);
}
+#endif
+ return (0);
+}
-int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
- {
- if (to->type != from->type)
- {
- EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_DIFFERENT_KEY_TYPES);
+int
+EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
+{
+ if (to->type != from->type) {
+ EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,
+ EVP_R_DIFFERENT_KEY_TYPES);
goto err;
- }
+ }
- if (EVP_PKEY_missing_parameters(from))
- {
- EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS);
+ if (EVP_PKEY_missing_parameters(from)) {
+ EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,
+ EVP_R_MISSING_PARAMETERS);
goto err;
- }
+ }
if (from->ameth && from->ameth->param_copy)
return from->ameth->param_copy(to, from);
+
err:
return 0;
- }
+}
-int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey)
- {
+int
+EVP_PKEY_missing_parameters(const EVP_PKEY *pkey)
+{
if (pkey->ameth && pkey->ameth->param_missing)
return pkey->ameth->param_missing(pkey);
return 0;
- }
+}
-int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
- {
+int
+EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
+{
if (a->type != b->type)
return -1;
if (a->ameth && a->ameth->param_cmp)
return a->ameth->param_cmp(a, b);
return -2;
- }
+}
-int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
- {
+int
+EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
+{
if (a->type != b->type)
return -1;
- if (a->ameth)
- {
+ if (a->ameth) {
int ret;
/* Compare parameters if the algorithm has them */
- if (a->ameth->param_cmp)
- {
+ if (a->ameth->param_cmp) {
ret = a->ameth->param_cmp(a, b);
if (ret <= 0)
return ret;
- }
+ }
if (a->ameth->pub_cmp)
return a->ameth->pub_cmp(a, b);
- }
+ }
return -2;
- }
+}
-EVP_PKEY *EVP_PKEY_new(void)
- {
+EVP_PKEY *
+EVP_PKEY_new(void)
+{
EVP_PKEY *ret;
- ret=(EVP_PKEY *)malloc(sizeof(EVP_PKEY));
- if (ret == NULL)
- {
- EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);
- return(NULL);
- }
- ret->type=EVP_PKEY_NONE;
- ret->save_type=EVP_PKEY_NONE;
- ret->references=1;
- ret->ameth=NULL;
- ret->engine=NULL;
- ret->pkey.ptr=NULL;
- ret->attributes=NULL;
- ret->save_parameters=1;
- return(ret);
+ ret = (EVP_PKEY *)malloc(sizeof(EVP_PKEY));
+ if (ret == NULL) {
+ EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE);
+ return (NULL);
}
+ ret->type = EVP_PKEY_NONE;
+ ret->save_type = EVP_PKEY_NONE;
+ ret->references = 1;
+ ret->ameth = NULL;
+ ret->engine = NULL;
+ ret->pkey.ptr = NULL;
+ ret->attributes = NULL;
+ ret->save_parameters = 1;
+ return (ret);
+}
/* Setup a public key ASN1 method and ENGINE from a NID or a string.
* If pkey is NULL just return 1 or 0 if the algorithm exists.
*/
-static int pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len)
- {
+static int
+pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len)
+{
const EVP_PKEY_ASN1_METHOD *ameth;
ENGINE *e = NULL;
- if (pkey)
- {
+ if (pkey) {
if (pkey->pkey.ptr)
EVP_PKEY_free_it(pkey);
/* If key type matches and a method exists then this
@@ -219,13 +223,12 @@ static int pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len)
return 1;
#ifndef OPENSSL_NO_ENGINE
/* If we have an ENGINE release it */
- if (pkey->engine)
- {
+ if (pkey->engine) {
ENGINE_finish(pkey->engine);
pkey->engine = NULL;
- }
-#endif
}
+#endif
+ }
if (str)
ameth = EVP_PKEY_asn1_find_str(&e, str, len);
else
@@ -234,57 +237,61 @@ static int pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len)
if (!pkey && e)
ENGINE_finish(e);
#endif
- if (!ameth)
- {
+ if (!ameth) {
EVPerr(EVP_F_PKEY_SET_TYPE, EVP_R_UNSUPPORTED_ALGORITHM);
return 0;
- }
- if (pkey)
- {
+ }
+ if (pkey) {
pkey->ameth = ameth;
pkey->engine = e;
pkey->type = pkey->ameth->pkey_id;
- pkey->save_type=type;
- }
- return 1;
+ pkey->save_type = type;
}
+ return 1;
+}
-int EVP_PKEY_set_type(EVP_PKEY *pkey, int type)
- {
+int
+EVP_PKEY_set_type(EVP_PKEY *pkey, int type)
+{
return pkey_set_type(pkey, type, NULL, -1);
- }
+}
-int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len)
- {
+int
+EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len)
+{
return pkey_set_type(pkey, EVP_PKEY_NONE, str, len);
- }
+}
-int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
- {
+int
+EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
+{
if (!EVP_PKEY_set_type(pkey, type))
return 0;
- pkey->pkey.ptr=key;
+ pkey->pkey.ptr = key;
return (key != NULL);
- }
+}
-void *EVP_PKEY_get0(EVP_PKEY *pkey)
- {
+void *
+EVP_PKEY_get0(EVP_PKEY *pkey)
+{
return pkey->pkey.ptr;
- }
+}
#ifndef OPENSSL_NO_RSA
-int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
+int
+EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
{
int ret = EVP_PKEY_assign_RSA(pkey, key);
- if(ret)
+ if (ret)
RSA_up_ref(key);
return ret;
}
-RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)
- {
- if(pkey->type != EVP_PKEY_RSA) {
+RSA *
+EVP_PKEY_get1_RSA(EVP_PKEY *pkey)
+{
+ if (pkey->type != EVP_PKEY_RSA) {
EVPerr(EVP_F_EVP_PKEY_GET1_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
return NULL;
}
@@ -294,17 +301,19 @@ RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)
#endif
#ifndef OPENSSL_NO_DSA
-int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
+int
+EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
{
int ret = EVP_PKEY_assign_DSA(pkey, key);
- if(ret)
+ if (ret)
DSA_up_ref(key);
return ret;
}
-DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
- {
- if(pkey->type != EVP_PKEY_DSA) {
+DSA *
+EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
+{
+ if (pkey->type != EVP_PKEY_DSA) {
EVPerr(EVP_F_EVP_PKEY_GET1_DSA, EVP_R_EXPECTING_A_DSA_KEY);
return NULL;
}
@@ -315,18 +324,19 @@ DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
#ifndef OPENSSL_NO_EC
-int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key)
+int
+EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key)
{
- int ret = EVP_PKEY_assign_EC_KEY(pkey,key);
+ int ret = EVP_PKEY_assign_EC_KEY(pkey, key);
if (ret)
EC_KEY_up_ref(key);
return ret;
}
-EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
+EC_KEY *
+EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
{
- if (pkey->type != EVP_PKEY_EC)
- {
+ if (pkey->type != EVP_PKEY_EC) {
EVPerr(EVP_F_EVP_PKEY_GET1_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);
return NULL;
}
@@ -338,17 +348,19 @@ EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
#ifndef OPENSSL_NO_DH
-int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
+int
+EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
{
int ret = EVP_PKEY_assign_DH(pkey, key);
- if(ret)
+ if (ret)
DH_up_ref(key);
return ret;
}
-DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey)
- {
- if(pkey->type != EVP_PKEY_DH) {
+DH *
+EVP_PKEY_get1_DH(EVP_PKEY *pkey)
+{
+ if (pkey->type != EVP_PKEY_DH) {
EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY);
return NULL;
}
@@ -357,8 +369,9 @@ DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey)
}
#endif
-int EVP_PKEY_type(int type)
- {
+int
+EVP_PKEY_type(int type)
+{
int ret;
const EVP_PKEY_ASN1_METHOD *ameth;
ENGINE *e;
@@ -372,89 +385,97 @@ int EVP_PKEY_type(int type)
ENGINE_finish(e);
#endif
return ret;
- }
+}
-int EVP_PKEY_id(const EVP_PKEY *pkey)
- {
+int
+EVP_PKEY_id(const EVP_PKEY *pkey)
+{
return pkey->type;
- }
+}
-int EVP_PKEY_base_id(const EVP_PKEY *pkey)
- {
+int
+EVP_PKEY_base_id(const EVP_PKEY *pkey)
+{
return EVP_PKEY_type(pkey->type);
- }
+}
-void EVP_PKEY_free(EVP_PKEY *x)
- {
+void
+EVP_PKEY_free(EVP_PKEY *x)
+{
int i;
- if (x == NULL) return;
+ if (x == NULL)
+ return;
- i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY);
- if (i > 0) return;
+ i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY);
+ if (i > 0)
+ return;
EVP_PKEY_free_it(x);
if (x->attributes)
sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
free(x);
- }
+}
-static void EVP_PKEY_free_it(EVP_PKEY *x)
- {
- if (x->ameth && x->ameth->pkey_free)
- {
+static void
+EVP_PKEY_free_it(EVP_PKEY *x)
+{
+ if (x->ameth && x->ameth->pkey_free) {
x->ameth->pkey_free(x);
x->pkey.ptr = NULL;
- }
+ }
#ifndef OPENSSL_NO_ENGINE
- if (x->engine)
- {
+ if (x->engine) {
ENGINE_finish(x->engine);
x->engine = NULL;
- }
-#endif
}
+#endif
+}
-static int unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent,
- const char *kstr)
- {
+static int
+unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent, const char *kstr)
+{
BIO_indent(out, indent, 128);
BIO_printf(out, "%s algorithm \"%s\" unsupported\n",
- kstr, OBJ_nid2ln(pkey->type));
+ kstr, OBJ_nid2ln(pkey->type));
return 1;
- }
+}
-int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,
- int indent, ASN1_PCTX *pctx)
- {
+int
+EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent,
+ ASN1_PCTX *pctx)
+{
if (pkey->ameth && pkey->ameth->pub_print)
return pkey->ameth->pub_print(out, pkey, indent, pctx);
-
+
return unsup_alg(out, pkey, indent, "Public Key");
- }
+}
-int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,
- int indent, ASN1_PCTX *pctx)
- {
+int
+EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent,
+ ASN1_PCTX *pctx)
+{
if (pkey->ameth && pkey->ameth->priv_print)
return pkey->ameth->priv_print(out, pkey, indent, pctx);
-
+
return unsup_alg(out, pkey, indent, "Private Key");
- }
+}
-int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,
- int indent, ASN1_PCTX *pctx)
- {
+int
+EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, int indent,
+ ASN1_PCTX *pctx)
+{
if (pkey->ameth && pkey->ameth->param_print)
return pkey->ameth->param_print(out, pkey, indent, pctx);
return unsup_alg(out, pkey, indent, "Parameters");
- }
+}
-int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid)
- {
+int
+EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid)
+{
if (!pkey->ameth || !pkey->ameth->pkey_ctrl)
return -2;
return pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_DEFAULT_MD_NID,
- 0, pnid);
- }
+ 0, pnid);
+}
diff --git a/lib/libssl/src/crypto/evp/p_open.c b/lib/libssl/src/crypto/evp/p_open.c
index b832ec6a6bc..88c0a455443 100644
--- a/lib/libssl/src/crypto/evp/p_open.c
+++ b/lib/libssl/src/crypto/evp/p_open.c
@@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
@@ -66,57 +66,60 @@
#include <openssl/x509.h>
#include <openssl/rsa.h>
-int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
- const unsigned char *ek, int ekl, const unsigned char *iv,
- EVP_PKEY *priv)
- {
- unsigned char *key=NULL;
- int i,size=0,ret=0;
+int
+EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
+ const unsigned char *ek, int ekl, const unsigned char *iv, EVP_PKEY *priv)
+{
+ unsigned char *key = NULL;
+ int i, size = 0, ret = 0;
- if(type) {
+ if (type) {
EVP_CIPHER_CTX_init(ctx);
- if(!EVP_DecryptInit_ex(ctx,type,NULL, NULL,NULL)) return 0;
+ if (!EVP_DecryptInit_ex(ctx, type, NULL, NULL, NULL))
+ return 0;
}
- if(!priv) return 1;
+ if (!priv)
+ return 1;
- if (priv->type != EVP_PKEY_RSA)
- {
- EVPerr(EVP_F_EVP_OPENINIT,EVP_R_PUBLIC_KEY_NOT_RSA);
+ if (priv->type != EVP_PKEY_RSA) {
+ EVPerr(EVP_F_EVP_OPENINIT, EVP_R_PUBLIC_KEY_NOT_RSA);
goto err;
- }
+ }
- size=RSA_size(priv->pkey.rsa);
- key=(unsigned char *)malloc(size+2);
- if (key == NULL)
- {
+ size = RSA_size(priv->pkey.rsa);
+ key = (unsigned char *)malloc(size + 2);
+ if (key == NULL) {
/* ERROR */
- EVPerr(EVP_F_EVP_OPENINIT,ERR_R_MALLOC_FAILURE);
+ EVPerr(EVP_F_EVP_OPENINIT, ERR_R_MALLOC_FAILURE);
goto err;
- }
+ }
- i=EVP_PKEY_decrypt_old(key,ek,ekl,priv);
- if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i))
- {
+ i = EVP_PKEY_decrypt_old(key, ek, ekl, priv);
+ if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i)) {
/* ERROR */
goto err;
- }
- if(!EVP_DecryptInit_ex(ctx,NULL,NULL,key,iv)) goto err;
+ }
+ if (!EVP_DecryptInit_ex(ctx, NULL, NULL, key, iv))
+ goto err;
+
+ ret = 1;
- ret=1;
err:
- if (key != NULL) OPENSSL_cleanse(key,size);
+ if (key != NULL)
+ OPENSSL_cleanse(key, size);
free(key);
- return(ret);
- }
+ return (ret);
+}
-int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
- {
+int
+EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
+{
int i;
- i=EVP_DecryptFinal_ex(ctx,out,outl);
+ i = EVP_DecryptFinal_ex(ctx, out, outl);
if (i)
- i = EVP_DecryptInit_ex(ctx,NULL,NULL,NULL,NULL);
- return(i);
- }
+ i = EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, NULL);
+ return (i);
+}
#endif
diff --git a/lib/libssl/src/crypto/evp/p_seal.c b/lib/libssl/src/crypto/evp/p_seal.c
index e5919b0fbf9..6147447290b 100644
--- a/lib/libssl/src/crypto/evp/p_seal.c
+++ b/lib/libssl/src/crypto/evp/p_seal.c
@@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
@@ -66,33 +66,36 @@
#include <openssl/objects.h>
#include <openssl/x509.h>
-int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
- int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk)
- {
+int
+EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
+ int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk)
+{
unsigned char key[EVP_MAX_KEY_LENGTH];
int i;
-
- if(type) {
+
+ if (type) {
EVP_CIPHER_CTX_init(ctx);
- if(!EVP_EncryptInit_ex(ctx,type,NULL,NULL,NULL)) return 0;
+ if (!EVP_EncryptInit_ex(ctx, type, NULL, NULL, NULL))
+ return 0;
}
if ((npubk <= 0) || !pubk)
return 1;
if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0)
return 0;
if (EVP_CIPHER_CTX_iv_length(ctx))
- RAND_pseudo_bytes(iv,EVP_CIPHER_CTX_iv_length(ctx));
+ RAND_pseudo_bytes(iv, EVP_CIPHER_CTX_iv_length(ctx));
- if(!EVP_EncryptInit_ex(ctx,NULL,NULL,key,iv)) return 0;
+ if (!EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv))
+ return 0;
- for (i=0; i<npubk; i++)
- {
- ekl[i]=EVP_PKEY_encrypt_old(ek[i],key,EVP_CIPHER_CTX_key_length(ctx),
- pubk[i]);
- if (ekl[i] <= 0) return(-1);
- }
- return(npubk);
+ for (i = 0; i < npubk; i++) {
+ ekl[i] = EVP_PKEY_encrypt_old(ek[i], key,
+ EVP_CIPHER_CTX_key_length(ctx), pubk[i]);
+ if (ekl[i] <= 0)
+ return (-1);
}
+ return (npubk);
+}
/* MACRO
void EVP_SealUpdate(ctx,out,outl,in,inl)
@@ -106,11 +109,13 @@ int inl;
}
*/
-int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
- {
+int
+EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
+{
int i;
- i = EVP_EncryptFinal_ex(ctx,out,outl);
- if (i)
- i = EVP_EncryptInit_ex(ctx,NULL,NULL,NULL,NULL);
+
+ i = EVP_EncryptFinal_ex(ctx, out, outl);
+ if (i)
+ i = EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, NULL);
return i;
- }
+}
diff --git a/lib/libssl/src/crypto/evp/p_sign.c b/lib/libssl/src/crypto/evp/p_sign.c
index 8afb664306e..b064ec5fb5f 100644
--- a/lib/libssl/src/crypto/evp/p_sign.c
+++ b/lib/libssl/src/crypto/evp/p_sign.c
@@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
@@ -63,37 +63,39 @@
#include <openssl/x509.h>
#ifdef undef
-void EVP_SignInit(EVP_MD_CTX *ctx, EVP_MD *type)
- {
- EVP_DigestInit_ex(ctx,type);
- }
+void
+EVP_SignInit(EVP_MD_CTX *ctx, EVP_MD *type)
+{
+ EVP_DigestInit_ex(ctx, type);
+}
-void EVP_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data,
- unsigned int count)
- {
- EVP_DigestUpdate(ctx,data,count);
- }
+void
+EVP_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data,
+ unsigned int count)
+{
+ EVP_DigestUpdate(ctx, data, count);
+}
#endif
-int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
- EVP_PKEY *pkey)
- {
+int
+EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
+ EVP_PKEY *pkey)
+{
unsigned char m[EVP_MAX_MD_SIZE];
unsigned int m_len;
- int i = 0,ok = 0,v;
+ int i = 0, ok = 0, v;
EVP_MD_CTX tmp_ctx;
EVP_PKEY_CTX *pkctx = NULL;
- *siglen=0;
+ *siglen = 0;
EVP_MD_CTX_init(&tmp_ctx);
- if (!EVP_MD_CTX_copy_ex(&tmp_ctx,ctx))
- goto err;
- if (!EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len))
+ if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx))
+ goto err;
+ if (!EVP_DigestFinal_ex(&tmp_ctx, &(m[0]), &m_len))
goto err;
EVP_MD_CTX_cleanup(&tmp_ctx);
- if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
- {
+ if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) {
size_t sltmp = (size_t)EVP_PKEY_size(pkey);
i = 0;
pkctx = EVP_PKEY_CTX_new(pkey, NULL);
@@ -107,33 +109,29 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
goto err;
*siglen = sltmp;
i = 1;
- err:
+err:
EVP_PKEY_CTX_free(pkctx);
return i;
- }
+ }
- for (i=0; i<4; i++)
- {
- v=ctx->digest->required_pkey_type[i];
- if (v == 0) break;
- if (pkey->type == v)
- {
- ok=1;
+ for (i = 0; i < 4; i++) {
+ v = ctx->digest->required_pkey_type[i];
+ if (v == 0)
+ break;
+ if (pkey->type == v) {
+ ok = 1;
break;
- }
- }
- if (!ok)
- {
- EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE);
- return(0);
- }
-
- if (ctx->digest->sign == NULL)
- {
- EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_NO_SIGN_FUNCTION_CONFIGURED);
- return(0);
}
- return(ctx->digest->sign(ctx->digest->type,m,m_len,sigret,siglen,
- pkey->pkey.ptr));
+ }
+ if (!ok) {
+ EVPerr(EVP_F_EVP_SIGNFINAL, EVP_R_WRONG_PUBLIC_KEY_TYPE);
+ return (0);
}
+ if (ctx->digest->sign == NULL) {
+ EVPerr(EVP_F_EVP_SIGNFINAL, EVP_R_NO_SIGN_FUNCTION_CONFIGURED);
+ return (0);
+ }
+ return(ctx->digest->sign(ctx->digest->type, m,m_len, sigret, siglen,
+ pkey->pkey.ptr));
+}
diff --git a/lib/libssl/src/crypto/evp/p_verify.c b/lib/libssl/src/crypto/evp/p_verify.c
index c66d63ccf85..3b9b8ab7d63 100644
--- a/lib/libssl/src/crypto/evp/p_verify.c
+++ b/lib/libssl/src/crypto/evp/p_verify.c
@@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
@@ -62,24 +62,24 @@
#include <openssl/objects.h>
#include <openssl/x509.h>
-int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
- unsigned int siglen, EVP_PKEY *pkey)
- {
+int
+EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
+ unsigned int siglen, EVP_PKEY *pkey)
+{
unsigned char m[EVP_MAX_MD_SIZE];
unsigned int m_len;
- int i = 0,ok = 0,v;
+ int i = 0, ok = 0, v;
EVP_MD_CTX tmp_ctx;
EVP_PKEY_CTX *pkctx = NULL;
EVP_MD_CTX_init(&tmp_ctx);
- if (!EVP_MD_CTX_copy_ex(&tmp_ctx,ctx))
- goto err;
- if (!EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len))
+ if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx))
+ goto err;
+ if (!EVP_DigestFinal_ex(&tmp_ctx, &(m[0]), &m_len))
goto err;
EVP_MD_CTX_cleanup(&tmp_ctx);
- if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
- {
+ if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) {
i = -1;
pkctx = EVP_PKEY_CTX_new(pkey, NULL);
if (!pkctx)
@@ -89,33 +89,30 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0)
goto err;
i = EVP_PKEY_verify(pkctx, sigbuf, siglen, m, m_len);
- err:
+err:
EVP_PKEY_CTX_free(pkctx);
return i;
- }
+ }
- for (i=0; i<4; i++)
- {
- v=ctx->digest->required_pkey_type[i];
- if (v == 0) break;
- if (pkey->type == v)
- {
- ok=1;
+ for (i = 0; i < 4; i++) {
+ v = ctx->digest->required_pkey_type[i];
+ if (v == 0)
+ break;
+ if (pkey->type == v) {
+ ok = 1;
break;
- }
- }
- if (!ok)
- {
- EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE);
- return(-1);
- }
- if (ctx->digest->verify == NULL)
- {
- EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED);
- return(0);
}
-
- return(ctx->digest->verify(ctx->digest->type,m,m_len,
- sigbuf,siglen,pkey->pkey.ptr));
+ }
+ if (!ok) {
+ EVPerr(EVP_F_EVP_VERIFYFINAL, EVP_R_WRONG_PUBLIC_KEY_TYPE);
+ return (-1);
+ }
+ if (ctx->digest->verify == NULL) {
+ EVPerr(EVP_F_EVP_VERIFYFINAL,
+ EVP_R_NO_VERIFY_FUNCTION_CONFIGURED);
+ return (0);
}
+ return(ctx->digest->verify(ctx->digest->type, m, m_len,
+ sigbuf, siglen, pkey->pkey.ptr));
+}
diff --git a/lib/libssl/src/crypto/evp/pmeth_fn.c b/lib/libssl/src/crypto/evp/pmeth_fn.c
index c4676f2f8df..12dd9e26a1d 100644
--- a/lib/libssl/src/crypto/evp/pmeth_fn.c
+++ b/lib/libssl/src/crypto/evp/pmeth_fn.c
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -79,15 +79,16 @@
} \
}
-int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->sign)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->sign) {
EVPerr(EVP_F_EVP_PKEY_SIGN_INIT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
ctx->operation = EVP_PKEY_OP_SIGN;
if (!ctx->pmeth->sign_init)
return 1;
@@ -95,36 +96,35 @@ int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx)
if (ret <= 0)
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
- }
+}
-int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
- unsigned char *sig, size_t *siglen,
- const unsigned char *tbs, size_t tbslen)
- {
- if (!ctx || !ctx->pmeth || !ctx->pmeth->sign)
- {
+int
+EVP_PKEY_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
+ const unsigned char *tbs, size_t tbslen)
+{
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->sign) {
EVPerr(EVP_F_EVP_PKEY_SIGN,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
- if (ctx->operation != EVP_PKEY_OP_SIGN)
- {
+ }
+ if (ctx->operation != EVP_PKEY_OP_SIGN) {
EVPerr(EVP_F_EVP_PKEY_SIGN, EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
+ }
M_check_autoarg(ctx, sig, siglen, EVP_F_EVP_PKEY_SIGN)
return ctx->pmeth->sign(ctx, sig, siglen, tbs, tbslen);
- }
+}
-int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->verify)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->verify) {
EVPerr(EVP_F_EVP_PKEY_VERIFY_INIT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
ctx->operation = EVP_PKEY_OP_VERIFY;
if (!ctx->pmeth->verify_init)
return 1;
@@ -132,35 +132,34 @@ int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx)
if (ret <= 0)
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
- }
+}
-int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
- const unsigned char *sig, size_t siglen,
- const unsigned char *tbs, size_t tbslen)
- {
- if (!ctx || !ctx->pmeth || !ctx->pmeth->verify)
- {
+int
+EVP_PKEY_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
+ const unsigned char *tbs, size_t tbslen)
+{
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->verify) {
EVPerr(EVP_F_EVP_PKEY_VERIFY,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
- if (ctx->operation != EVP_PKEY_OP_VERIFY)
- {
+ }
+ if (ctx->operation != EVP_PKEY_OP_VERIFY) {
EVPerr(EVP_F_EVP_PKEY_VERIFY, EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
- return ctx->pmeth->verify(ctx, sig, siglen, tbs, tbslen);
}
+ return ctx->pmeth->verify(ctx, sig, siglen, tbs, tbslen);
+}
-int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover) {
EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
ctx->operation = EVP_PKEY_OP_VERIFYRECOVER;
if (!ctx->pmeth->verify_recover_init)
return 1;
@@ -168,36 +167,36 @@ int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx)
if (ret <= 0)
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
- }
+}
-int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
- unsigned char *rout, size_t *routlen,
- const unsigned char *sig, size_t siglen)
- {
- if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover)
- {
+int
+EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen,
+ const unsigned char *sig, size_t siglen)
+{
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover) {
EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
- if (ctx->operation != EVP_PKEY_OP_VERIFYRECOVER)
- {
- EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER, EVP_R_OPERATON_NOT_INITIALIZED);
+ }
+ if (ctx->operation != EVP_PKEY_OP_VERIFYRECOVER) {
+ EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER,
+ EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
+ }
M_check_autoarg(ctx, rout, routlen, EVP_F_EVP_PKEY_VERIFY_RECOVER)
return ctx->pmeth->verify_recover(ctx, rout, routlen, sig, siglen);
- }
+}
-int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt) {
EVPerr(EVP_F_EVP_PKEY_ENCRYPT_INIT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
ctx->operation = EVP_PKEY_OP_ENCRYPT;
if (!ctx->pmeth->encrypt_init)
return 1;
@@ -205,36 +204,35 @@ int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx)
if (ret <= 0)
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
- }
+}
-int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
- unsigned char *out, size_t *outlen,
- const unsigned char *in, size_t inlen)
- {
- if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt)
- {
+int
+EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
+ const unsigned char *in, size_t inlen)
+{
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt) {
EVPerr(EVP_F_EVP_PKEY_ENCRYPT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
- if (ctx->operation != EVP_PKEY_OP_ENCRYPT)
- {
+ }
+ if (ctx->operation != EVP_PKEY_OP_ENCRYPT) {
EVPerr(EVP_F_EVP_PKEY_ENCRYPT, EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
+ }
M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_ENCRYPT)
return ctx->pmeth->encrypt(ctx, out, outlen, in, inlen);
- }
+}
-int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt) {
EVPerr(EVP_F_EVP_PKEY_DECRYPT_INIT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
ctx->operation = EVP_PKEY_OP_DECRYPT;
if (!ctx->pmeth->decrypt_init)
return 1;
@@ -242,37 +240,35 @@ int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx)
if (ret <= 0)
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
- }
+}
-int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
- unsigned char *out, size_t *outlen,
- const unsigned char *in, size_t inlen)
- {
- if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt)
- {
+int
+EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
+ const unsigned char *in, size_t inlen)
+{
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt) {
EVPerr(EVP_F_EVP_PKEY_DECRYPT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
- if (ctx->operation != EVP_PKEY_OP_DECRYPT)
- {
+ }
+ if (ctx->operation != EVP_PKEY_OP_DECRYPT) {
EVPerr(EVP_F_EVP_PKEY_DECRYPT, EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
+ }
M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_DECRYPT)
return ctx->pmeth->decrypt(ctx, out, outlen, in, inlen);
- }
+}
-
-int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->derive)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->derive) {
EVPerr(EVP_F_EVP_PKEY_DERIVE_INIT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
ctx->operation = EVP_PKEY_OP_DERIVE;
if (!ctx->pmeth->derive_init)
return 1;
@@ -280,23 +276,27 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
if (ret <= 0)
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
- }
+}
-int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer)
- {
+int
+EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer)
+{
int ret;
- if (!ctx || !ctx->pmeth || !(ctx->pmeth->derive||ctx->pmeth->encrypt||ctx->pmeth->decrypt) || !ctx->pmeth->ctrl)
- {
+
+ if (!ctx || !ctx->pmeth || !(ctx->pmeth->derive ||
+ ctx->pmeth->encrypt || ctx->pmeth->decrypt) ||
+ !ctx->pmeth->ctrl) {
EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
- if (ctx->operation != EVP_PKEY_OP_DERIVE && ctx->operation != EVP_PKEY_OP_ENCRYPT && ctx->operation != EVP_PKEY_OP_DECRYPT)
- {
+ }
+ if (ctx->operation != EVP_PKEY_OP_DERIVE &&
+ ctx->operation != EVP_PKEY_OP_ENCRYPT &&
+ ctx->operation != EVP_PKEY_OP_DECRYPT) {
EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER,
- EVP_R_OPERATON_NOT_INITIALIZED);
+ EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
+ }
ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 0, peer);
@@ -306,18 +306,16 @@ int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer)
if (ret == 2)
return 1;
- if (!ctx->pkey)
- {
+ if (!ctx->pkey) {
EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_NO_KEY_SET);
return -1;
- }
+ }
- if (ctx->pkey->type != peer->type)
- {
+ if (ctx->pkey->type != peer->type) {
EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER,
- EVP_R_DIFFERENT_KEY_TYPES);
+ EVP_R_DIFFERENT_KEY_TYPES);
return -1;
- }
+ }
/* ran@cryptocom.ru: For clarity. The error is if parameters in peer are
* present (!missing) but don't match. EVP_PKEY_cmp_parameters may return
@@ -325,12 +323,11 @@ int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer)
* (different key types) is impossible here because it is checked earlier.
* -2 is OK for us here, as well as 1, so we can check for 0 only. */
if (!EVP_PKEY_missing_parameters(peer) &&
- !EVP_PKEY_cmp_parameters(ctx->pkey, peer))
- {
+ !EVP_PKEY_cmp_parameters(ctx->pkey, peer)) {
EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER,
- EVP_R_DIFFERENT_PARAMETERS);
+ EVP_R_DIFFERENT_PARAMETERS);
return -1;
- }
+ }
if (ctx->peerkey)
EVP_PKEY_free(ctx->peerkey);
@@ -338,31 +335,27 @@ int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer)
ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 1, peer);
- if (ret <= 0)
- {
+ if (ret <= 0) {
ctx->peerkey = NULL;
return ret;
- }
-
- CRYPTO_add(&peer->references,1,CRYPTO_LOCK_EVP_PKEY);
- return 1;
}
+ CRYPTO_add(&peer->references, 1, CRYPTO_LOCK_EVP_PKEY);
+ return 1;
+}
-int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen)
- {
- if (!ctx || !ctx->pmeth || !ctx->pmeth->derive)
- {
+int
+EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen)
+{
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->derive) {
EVPerr(EVP_F_EVP_PKEY_DERIVE,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
- if (ctx->operation != EVP_PKEY_OP_DERIVE)
- {
+ }
+ if (ctx->operation != EVP_PKEY_OP_DERIVE) {
EVPerr(EVP_F_EVP_PKEY_DERIVE, EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
+ }
M_check_autoarg(ctx, key, pkeylen, EVP_F_EVP_PKEY_DERIVE)
return ctx->pmeth->derive(ctx, key, pkeylen);
- }
-
+}
diff --git a/lib/libssl/src/crypto/evp/pmeth_gn.c b/lib/libssl/src/crypto/evp/pmeth_gn.c
index 5d74161a09a..c6683ab89b1 100644
--- a/lib/libssl/src/crypto/evp/pmeth_gn.c
+++ b/lib/libssl/src/crypto/evp/pmeth_gn.c
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -64,15 +64,16 @@
#include <openssl/bn.h>
#include "evp_locl.h"
-int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) {
EVPerr(EVP_F_EVP_PKEY_PARAMGEN_INIT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
ctx->operation = EVP_PKEY_OP_PARAMGEN;
if (!ctx->pmeth->paramgen_init)
return 1;
@@ -80,23 +81,23 @@ int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx)
if (ret <= 0)
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
- }
+}
-int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
- {
+int
+EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) {
EVPerr(EVP_F_EVP_PKEY_PARAMGEN,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
- if (ctx->operation != EVP_PKEY_OP_PARAMGEN)
- {
+ if (ctx->operation != EVP_PKEY_OP_PARAMGEN) {
EVPerr(EVP_F_EVP_PKEY_PARAMGEN, EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
+ }
if (!ppkey)
return -1;
@@ -105,23 +106,23 @@ int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
*ppkey = EVP_PKEY_new();
ret = ctx->pmeth->paramgen(ctx, *ppkey);
- if (ret <= 0)
- {
+ if (ret <= 0) {
EVP_PKEY_free(*ppkey);
*ppkey = NULL;
- }
- return ret;
}
+ return ret;
+}
-int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) {
EVPerr(EVP_F_EVP_PKEY_KEYGEN_INIT,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
+ }
ctx->operation = EVP_PKEY_OP_KEYGEN;
if (!ctx->pmeth->keygen_init)
return 1;
@@ -129,23 +130,22 @@ int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx)
if (ret <= 0)
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
- }
+}
-int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
- {
+int
+EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen)
- {
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) {
EVPerr(EVP_F_EVP_PKEY_KEYGEN,
- EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
- }
- if (ctx->operation != EVP_PKEY_OP_KEYGEN)
- {
+ }
+ if (ctx->operation != EVP_PKEY_OP_KEYGEN) {
EVPerr(EVP_F_EVP_PKEY_KEYGEN, EVP_R_OPERATON_NOT_INITIALIZED);
return -1;
- }
+ }
if (!ppkey)
return -1;
@@ -154,67 +154,73 @@ int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
*ppkey = EVP_PKEY_new();
ret = ctx->pmeth->keygen(ctx, *ppkey);
- if (ret <= 0)
- {
+ if (ret <= 0) {
EVP_PKEY_free(*ppkey);
*ppkey = NULL;
- }
- return ret;
}
+ return ret;
+}
-void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb)
- {
+void
+EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb)
+{
ctx->pkey_gencb = cb;
- }
+}
-EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx)
- {
+EVP_PKEY_gen_cb *
+EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx)
+{
return ctx->pkey_gencb;
- }
+}
/* "translation callback" to call EVP_PKEY_CTX callbacks using BN_GENCB
* style callbacks.
*/
-static int trans_cb(int a, int b, BN_GENCB *gcb)
- {
+static int
+trans_cb(int a, int b, BN_GENCB *gcb)
+{
EVP_PKEY_CTX *ctx = gcb->arg;
ctx->keygen_info[0] = a;
ctx->keygen_info[1] = b;
return ctx->pkey_gencb(ctx);
- }
+}
-void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx)
- {
+void
+evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx)
+{
BN_GENCB_set(cb, trans_cb, ctx)
- }
+}
-int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx)
- {
+int
+EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx)
+{
if (idx == -1)
- return ctx->keygen_info_count;
+ return ctx->keygen_info_count;
if (idx < 0 || idx > ctx->keygen_info_count)
return 0;
return ctx->keygen_info[idx];
- }
+}
-EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,
- unsigned char *key, int keylen)
- {
+EVP_PKEY *
+EVP_PKEY_new_mac_key(int type, ENGINE *e, const unsigned char *key, int keylen)
+{
EVP_PKEY_CTX *mac_ctx = NULL;
EVP_PKEY *mac_key = NULL;
+
mac_ctx = EVP_PKEY_CTX_new_id(type, e);
if (!mac_ctx)
return NULL;
if (EVP_PKEY_keygen_init(mac_ctx) <= 0)
goto merr;
if (EVP_PKEY_CTX_ctrl(mac_ctx, -1, EVP_PKEY_OP_KEYGEN,
- EVP_PKEY_CTRL_SET_MAC_KEY, keylen, key) <= 0)
+ EVP_PKEY_CTRL_SET_MAC_KEY, keylen, (void *)key) <= 0)
goto merr;
if (EVP_PKEY_keygen(mac_ctx, &mac_key) <= 0)
goto merr;
- merr:
+
+merr:
if (mac_ctx)
EVP_PKEY_CTX_free(mac_ctx);
return mac_key;
- }
+}
diff --git a/lib/libssl/src/crypto/evp/pmeth_lib.c b/lib/libssl/src/crypto/evp/pmeth_lib.c
index a9fb15fdfe3..e51ae510981 100644
--- a/lib/libssl/src/crypto/evp/pmeth_lib.c
+++ b/lib/libssl/src/crypto/evp/pmeth_lib.c
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -75,8 +75,7 @@ STACK_OF(EVP_PKEY_METHOD) *app_pkey_methods = NULL;
extern const EVP_PKEY_METHOD rsa_pkey_meth, dh_pkey_meth, dsa_pkey_meth;
extern const EVP_PKEY_METHOD ec_pkey_meth, hmac_pkey_meth, cmac_pkey_meth;
-static const EVP_PKEY_METHOD *standard_methods[] =
- {
+static const EVP_PKEY_METHOD *standard_methods[] = {
#ifndef OPENSSL_NO_RSA
&rsa_pkey_meth,
#endif
@@ -91,62 +90,61 @@ static const EVP_PKEY_METHOD *standard_methods[] =
#endif
&hmac_pkey_meth,
&cmac_pkey_meth
- };
+};
DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *,
- pmeth);
+ pmeth);
-static int pmeth_cmp(const EVP_PKEY_METHOD * const *a,
- const EVP_PKEY_METHOD * const *b)
- {
- return ((*a)->pkey_id - (*b)->pkey_id);
- }
+static int
+pmeth_cmp(const EVP_PKEY_METHOD * const *a, const EVP_PKEY_METHOD * const *b)
+{
+ return ((*a)->pkey_id - (*b)->pkey_id);
+}
IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *,
- pmeth);
+ pmeth);
-const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type)
- {
+const EVP_PKEY_METHOD *
+EVP_PKEY_meth_find(int type)
+{
EVP_PKEY_METHOD tmp;
const EVP_PKEY_METHOD *t = &tmp, **ret;
+
tmp.pkey_id = type;
- if (app_pkey_methods)
- {
+ if (app_pkey_methods) {
int idx;
idx = sk_EVP_PKEY_METHOD_find(app_pkey_methods, &tmp);
if (idx >= 0)
return sk_EVP_PKEY_METHOD_value(app_pkey_methods, idx);
- }
+ }
ret = OBJ_bsearch_pmeth(&t, standard_methods,
- sizeof(standard_methods)/sizeof(EVP_PKEY_METHOD *));
+ sizeof(standard_methods)/sizeof(EVP_PKEY_METHOD *));
if (!ret || !*ret)
return NULL;
return *ret;
- }
+}
-static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
- {
+static EVP_PKEY_CTX *
+int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
+{
EVP_PKEY_CTX *ret;
const EVP_PKEY_METHOD *pmeth;
- if (id == -1)
- {
+
+ if (id == -1) {
if (!pkey || !pkey->ameth)
return NULL;
id = pkey->ameth->pkey_id;
- }
+ }
#ifndef OPENSSL_NO_ENGINE
if (pkey && pkey->engine)
e = pkey->engine;
/* Try to find an ENGINE which implements this method */
- if (e)
- {
- if (!ENGINE_init(e))
- {
- EVPerr(EVP_F_INT_CTX_NEW,ERR_R_ENGINE_LIB);
+ if (e) {
+ if (!ENGINE_init(e)) {
+ EVPerr(EVP_F_INT_CTX_NEW, ERR_R_ENGINE_LIB);
return NULL;
- }
}
- else
+ } else
e = ENGINE_get_pkey_meth_engine(id);
/* If an ENGINE handled this method look it up. Othewise
@@ -159,22 +157,20 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
#endif
pmeth = EVP_PKEY_meth_find(id);
- if (pmeth == NULL)
- {
- EVPerr(EVP_F_INT_CTX_NEW,EVP_R_UNSUPPORTED_ALGORITHM);
+ if (pmeth == NULL) {
+ EVPerr(EVP_F_INT_CTX_NEW, EVP_R_UNSUPPORTED_ALGORITHM);
return NULL;
- }
+ }
ret = malloc(sizeof(EVP_PKEY_CTX));
- if (!ret)
- {
+ if (!ret) {
#ifndef OPENSSL_NO_ENGINE
if (e)
ENGINE_finish(e);
#endif
- EVPerr(EVP_F_INT_CTX_NEW,ERR_R_MALLOC_FAILURE);
+ EVPerr(EVP_F_INT_CTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
- }
+ }
ret->engine = e;
ret->pmeth = pmeth;
ret->operation = EVP_PKEY_OP_UNDEFINED;
@@ -182,24 +178,24 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
ret->peerkey = NULL;
ret->pkey_gencb = 0;
if (pkey)
- CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
+ CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
ret->data = NULL;
- if (pmeth->init)
- {
- if (pmeth->init(ret) <= 0)
- {
+ if (pmeth->init) {
+ if (pmeth->init(ret) <= 0) {
EVP_PKEY_CTX_free(ret);
return NULL;
- }
}
+ }
return ret;
- }
+}
-EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags)
- {
+EVP_PKEY_METHOD*
+EVP_PKEY_meth_new(int id, int flags)
+{
EVP_PKEY_METHOD *pmeth;
+
pmeth = malloc(sizeof(EVP_PKEY_METHOD));
if (!pmeth)
return NULL;
@@ -236,20 +232,20 @@ EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags)
pmeth->ctrl_str = 0;
return pmeth;
- }
+}
-void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,
- const EVP_PKEY_METHOD *meth)
- {
+void
+EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags, const EVP_PKEY_METHOD *meth)
+{
if (ppkey_id)
*ppkey_id = meth->pkey_id;
if (pflags)
*pflags = meth->flags;
- }
-
-void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src)
- {
+}
+void
+EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src)
+{
dst->init = src->init;
dst->copy = src->copy;
dst->cleanup = src->cleanup;
@@ -286,36 +282,40 @@ void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src)
dst->ctrl = src->ctrl;
dst->ctrl_str = src->ctrl_str;
- }
+}
-void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth)
- {
+void
+EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth)
+{
if (pmeth && (pmeth->flags & EVP_PKEY_FLAG_DYNAMIC))
free(pmeth);
- }
+}
-EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e)
- {
+EVP_PKEY_CTX *
+EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e)
+{
return int_ctx_new(pkey, e, -1);
- }
+}
-EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e)
- {
+EVP_PKEY_CTX *
+EVP_PKEY_CTX_new_id(int id, ENGINE *e)
+{
return int_ctx_new(NULL, e, id);
- }
+}
-EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
- {
+EVP_PKEY_CTX *
+EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
+{
EVP_PKEY_CTX *rctx;
+
if (!pctx->pmeth || !pctx->pmeth->copy)
return NULL;
#ifndef OPENSSL_NO_ENGINE
/* Make sure it's safe to copy a pkey context using an ENGINE */
- if (pctx->engine && !ENGINE_init(pctx->engine))
- {
- EVPerr(EVP_F_EVP_PKEY_CTX_DUP,ERR_R_ENGINE_LIB);
+ if (pctx->engine && !ENGINE_init(pctx->engine)) {
+ EVPerr(EVP_F_EVP_PKEY_CTX_DUP, ERR_R_ENGINE_LIB);
return 0;
- }
+ }
#endif
rctx = malloc(sizeof(EVP_PKEY_CTX));
if (!rctx)
@@ -327,12 +327,12 @@ EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
#endif
if (pctx->pkey)
- CRYPTO_add(&pctx->pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
+ CRYPTO_add(&pctx->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
rctx->pkey = pctx->pkey;
if (pctx->peerkey)
- CRYPTO_add(&pctx->peerkey->references,1,CRYPTO_LOCK_EVP_PKEY);
+ CRYPTO_add(&pctx->peerkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
rctx->peerkey = pctx->peerkey;
@@ -345,25 +345,25 @@ EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
EVP_PKEY_CTX_free(rctx);
return NULL;
+}
- }
-
-int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth)
- {
- if (app_pkey_methods == NULL)
- {
+int
+EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth)
+{
+ if (app_pkey_methods == NULL) {
app_pkey_methods = sk_EVP_PKEY_METHOD_new(pmeth_cmp);
if (!app_pkey_methods)
return 0;
- }
+ }
if (!sk_EVP_PKEY_METHOD_push(app_pkey_methods, pmeth))
return 0;
sk_EVP_PKEY_METHOD_sort(app_pkey_methods);
return 1;
- }
+}
-void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
- {
+void
+EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
+{
if (ctx == NULL)
return;
if (ctx->pmeth && ctx->pmeth->cleanup)
@@ -373,37 +373,36 @@ void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
if (ctx->peerkey)
EVP_PKEY_free(ctx->peerkey);
#ifndef OPENSSL_NO_ENGINE
- if(ctx->engine)
+ if (ctx->engine)
/* The EVP_PKEY_CTX we used belongs to an ENGINE, release the
* functional reference we held for this reason. */
ENGINE_finish(ctx->engine);
#endif
free(ctx);
- }
+}
-int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
- int cmd, int p1, void *p2)
- {
+int
+EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd,
+ int p1, void *p2)
+{
int ret;
- if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl)
- {
+
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl) {
EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_COMMAND_NOT_SUPPORTED);
return -2;
- }
+ }
if ((keytype != -1) && (ctx->pmeth->pkey_id != keytype))
return -1;
- if (ctx->operation == EVP_PKEY_OP_UNDEFINED)
- {
+ if (ctx->operation == EVP_PKEY_OP_UNDEFINED) {
EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_NO_OPERATION_SET);
return -1;
- }
+ }
- if ((optype != -1) && !(ctx->operation & optype))
- {
+ if ((optype != -1) && !(ctx->operation & optype)) {
EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_INVALID_OPERATION);
return -1;
- }
+ }
ret = ctx->pmeth->ctrl(ctx, cmd, p1, p2);
@@ -412,182 +411,201 @@ int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
return ret;
- }
+}
-int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx,
- const char *name, const char *value)
- {
- if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl_str)
- {
+int
+EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *name, const char *value)
+{
+ if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl_str) {
EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR,
- EVP_R_COMMAND_NOT_SUPPORTED);
+ EVP_R_COMMAND_NOT_SUPPORTED);
return -2;
- }
- if (!strcmp(name, "digest"))
- {
+ }
+ if (!strcmp(name, "digest")) {
const EVP_MD *md;
- if (!value || !(md = EVP_get_digestbyname(value)))
- {
+ if (!value || !(md = EVP_get_digestbyname(value))) {
EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR,
- EVP_R_INVALID_DIGEST);
+ EVP_R_INVALID_DIGEST);
return 0;
- }
- return EVP_PKEY_CTX_set_signature_md(ctx, md);
}
- return ctx->pmeth->ctrl_str(ctx, name, value);
+ return EVP_PKEY_CTX_set_signature_md(ctx, md);
}
+ return ctx->pmeth->ctrl_str(ctx, name, value);
+}
-int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx)
- {
+int
+EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx)
+{
return ctx->operation;
- }
+}
-void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen)
- {
+void
+EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen)
+{
ctx->keygen_info = dat;
ctx->keygen_info_count = datlen;
- }
+}
-void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data)
- {
+void
+EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data)
+{
ctx->data = data;
- }
+}
-void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx)
- {
+void *
+EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx)
+{
return ctx->data;
- }
+}
-EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx)
- {
+EVP_PKEY *
+EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx)
+{
return ctx->pkey;
- }
+}
-EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx)
- {
+EVP_PKEY *
+EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx)
+{
return ctx->peerkey;
- }
-
-void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data)
- {
+}
+
+void
+EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data)
+{
ctx->app_data = data;
- }
+}
-void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx)
- {
+void *
+EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx)
+{
return ctx->app_data;
- }
+}
-void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
- int (*init)(EVP_PKEY_CTX *ctx))
- {
+void
+EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
+ int (*init)(EVP_PKEY_CTX *ctx))
+{
pmeth->init = init;
- }
+}
-void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
- int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src))
- {
+void
+EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
+ int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src))
+{
pmeth->copy = copy;
- }
+}
-void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
- void (*cleanup)(EVP_PKEY_CTX *ctx))
- {
+void
+EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
+ void (*cleanup)(EVP_PKEY_CTX *ctx))
+{
pmeth->cleanup = cleanup;
- }
+}
-void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
- int (*paramgen_init)(EVP_PKEY_CTX *ctx),
- int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey))
- {
+void
+EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
+ int (*paramgen_init)(EVP_PKEY_CTX *ctx),
+ int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey))
+{
pmeth->paramgen_init = paramgen_init;
pmeth->paramgen = paramgen;
- }
+}
-void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
- int (*keygen_init)(EVP_PKEY_CTX *ctx),
- int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey))
- {
+void
+EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
+ int (*keygen_init)(EVP_PKEY_CTX *ctx),
+ int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey))
+{
pmeth->keygen_init = keygen_init;
pmeth->keygen = keygen;
- }
-
-void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
- int (*sign_init)(EVP_PKEY_CTX *ctx),
- int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
- const unsigned char *tbs, size_t tbslen))
- {
+}
+
+void
+EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
+ int (*sign_init)(EVP_PKEY_CTX *ctx),
+ int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
+ const unsigned char *tbs, size_t tbslen))
+{
pmeth->sign_init = sign_init;
pmeth->sign = sign;
- }
-
-void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
- int (*verify_init)(EVP_PKEY_CTX *ctx),
- int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
- const unsigned char *tbs, size_t tbslen))
- {
+}
+
+void
+EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
+ int (*verify_init)(EVP_PKEY_CTX *ctx),
+ int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
+ const unsigned char *tbs, size_t tbslen))
+{
pmeth->verify_init = verify_init;
pmeth->verify = verify;
- }
-
-void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
- int (*verify_recover_init)(EVP_PKEY_CTX *ctx),
- int (*verify_recover)(EVP_PKEY_CTX *ctx,
- unsigned char *sig, size_t *siglen,
- const unsigned char *tbs, size_t tbslen))
- {
+}
+
+void
+EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
+ int (*verify_recover_init)(EVP_PKEY_CTX *ctx),
+ int (*verify_recover)(EVP_PKEY_CTX *ctx,
+ unsigned char *sig, size_t *siglen,
+ const unsigned char *tbs, size_t tbslen))
+{
pmeth->verify_recover_init = verify_recover_init;
pmeth->verify_recover = verify_recover;
- }
-
-void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
- int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
- int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
- EVP_MD_CTX *mctx))
- {
+}
+
+void
+EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
+ int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
+ int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
+ EVP_MD_CTX *mctx))
+{
pmeth->signctx_init = signctx_init;
pmeth->signctx = signctx;
- }
-
-void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
- int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
- int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig,int siglen,
- EVP_MD_CTX *mctx))
- {
+}
+
+void
+EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
+ int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
+ int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
+ EVP_MD_CTX *mctx))
+{
pmeth->verifyctx_init = verifyctx_init;
pmeth->verifyctx = verifyctx;
- }
-
-void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
- int (*encrypt_init)(EVP_PKEY_CTX *ctx),
- int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
- const unsigned char *in, size_t inlen))
- {
+}
+
+void
+EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
+ int (*encrypt_init)(EVP_PKEY_CTX *ctx),
+ int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
+ const unsigned char *in, size_t inlen))
+{
pmeth->encrypt_init = encrypt_init;
pmeth->encrypt = encryptfn;
- }
-
-void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
- int (*decrypt_init)(EVP_PKEY_CTX *ctx),
- int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
- const unsigned char *in, size_t inlen))
- {
+}
+
+void
+EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
+ int (*decrypt_init)(EVP_PKEY_CTX *ctx),
+ int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
+ const unsigned char *in, size_t inlen))
+{
pmeth->decrypt_init = decrypt_init;
pmeth->decrypt = decrypt;
- }
+}
-void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
- int (*derive_init)(EVP_PKEY_CTX *ctx),
- int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen))
- {
+void
+EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
+ int (*derive_init)(EVP_PKEY_CTX *ctx),
+ int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen))
+{
pmeth->derive_init = derive_init;
pmeth->derive = derive;
- }
+}
-void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
- int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
- int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value))
- {
+void
+EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
+ int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
+ int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value))
+{
pmeth->ctrl = ctrl;
pmeth->ctrl_str = ctrl_str;
- }
+}