diff options
author | jsing <> | 2015-10-13 15:25:18 +0000 |
---|---|---|
committer | jsing <> | 2015-10-13 15:25:18 +0000 |
commit | 118a859ea4c28f8b6ffd00540de9e1b511925ae7 (patch) | |
tree | 95c0b10e1d70598129942e4d7c82e0d1c7bcf82c | |
parent | 662c5e99363907f9f55492004d9626b6b7ae4579 (diff) | |
download | openbsd-118a859ea4c28f8b6ffd00540de9e1b511925ae7.tar.gz openbsd-118a859ea4c28f8b6ffd00540de9e1b511925ae7.tar.bz2 openbsd-118a859ea4c28f8b6ffd00540de9e1b511925ae7.zip |
Convert ECParameters_dup() from a macro that uses ASN1_dup_of() into an
actual function. This removes the last ASN1_dup_of usage from the tree.
Feedback from doug@ and miod@
-rw-r--r-- | src/lib/libcrypto/doc/ec.pod | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec.h | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 18 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/ec/ec.h | 5 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/ec/ec_lib.c | 18 | ||||
-rw-r--r-- | src/lib/libssl/src/doc/crypto/ec.pod | 2 |
6 files changed, 40 insertions, 10 deletions
diff --git a/src/lib/libcrypto/doc/ec.pod b/src/lib/libcrypto/doc/ec.pod index 7d57ba8ea0..891948e4f6 100644 --- a/src/lib/libcrypto/doc/ec.pod +++ b/src/lib/libcrypto/doc/ec.pod | |||
@@ -158,7 +158,7 @@ ec - Elliptic Curve functions | |||
158 | int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); | 158 | int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); |
159 | int ECParameters_print_fp(FILE *fp, const EC_KEY *key); | 159 | int ECParameters_print_fp(FILE *fp, const EC_KEY *key); |
160 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); | 160 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); |
161 | #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) | 161 | EC_KEY *ECParameters_dup(EC_KEY *key); |
162 | #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ | 162 | #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ |
163 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \ | 163 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \ |
164 | EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) | 164 | EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) |
diff --git a/src/lib/libcrypto/ec/ec.h b/src/lib/libcrypto/ec/ec.h index 3b409ff92d..a1ece2e0d5 100644 --- a/src/lib/libcrypto/ec/ec.h +++ b/src/lib/libcrypto/ec/ec.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec.h,v 1.10 2015/06/20 13:26:08 jsing Exp $ */ | 1 | /* $OpenBSD: ec.h,v 1.11 2015/10/13 15:25:18 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -945,8 +945,7 @@ int ECParameters_print_fp(FILE *fp, const EC_KEY *key); | |||
945 | */ | 945 | */ |
946 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); | 946 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); |
947 | 947 | ||
948 | 948 | EC_KEY *ECParameters_dup(EC_KEY *key); | |
949 | #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) | ||
950 | 949 | ||
951 | #ifndef __cplusplus | 950 | #ifndef __cplusplus |
952 | #if defined(__SUNPRO_C) | 951 | #if defined(__SUNPRO_C) |
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index c28ab18fc0..2b5abbd4bb 100644 --- a/src/lib/libcrypto/ec/ec_lib.c +++ b/src/lib/libcrypto/ec/ec_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_lib.c,v 1.19 2015/09/10 15:56:25 jsing Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.20 2015/10/13 15:25:18 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -1102,3 +1102,19 @@ EC_GROUP_have_precompute_mult(const EC_GROUP * group) | |||
1102 | return 0; /* cannot tell whether precomputation has | 1102 | return 0; /* cannot tell whether precomputation has |
1103 | * been performed */ | 1103 | * been performed */ |
1104 | } | 1104 | } |
1105 | |||
1106 | EC_KEY * | ||
1107 | ECParameters_dup(EC_KEY *key) | ||
1108 | { | ||
1109 | unsigned char *p = NULL; | ||
1110 | EC_KEY *k = NULL; | ||
1111 | int len; | ||
1112 | |||
1113 | if (key == NULL) | ||
1114 | return (NULL); | ||
1115 | |||
1116 | if ((len = i2d_ECParameters(key, &p)) > 0) | ||
1117 | k = d2i_ECParameters(NULL, (const unsigned char **)&p, len); | ||
1118 | |||
1119 | return (k); | ||
1120 | } | ||
diff --git a/src/lib/libssl/src/crypto/ec/ec.h b/src/lib/libssl/src/crypto/ec/ec.h index 3b409ff92d..a1ece2e0d5 100644 --- a/src/lib/libssl/src/crypto/ec/ec.h +++ b/src/lib/libssl/src/crypto/ec/ec.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec.h,v 1.10 2015/06/20 13:26:08 jsing Exp $ */ | 1 | /* $OpenBSD: ec.h,v 1.11 2015/10/13 15:25:18 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -945,8 +945,7 @@ int ECParameters_print_fp(FILE *fp, const EC_KEY *key); | |||
945 | */ | 945 | */ |
946 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); | 946 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); |
947 | 947 | ||
948 | 948 | EC_KEY *ECParameters_dup(EC_KEY *key); | |
949 | #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) | ||
950 | 949 | ||
951 | #ifndef __cplusplus | 950 | #ifndef __cplusplus |
952 | #if defined(__SUNPRO_C) | 951 | #if defined(__SUNPRO_C) |
diff --git a/src/lib/libssl/src/crypto/ec/ec_lib.c b/src/lib/libssl/src/crypto/ec/ec_lib.c index c28ab18fc0..2b5abbd4bb 100644 --- a/src/lib/libssl/src/crypto/ec/ec_lib.c +++ b/src/lib/libssl/src/crypto/ec/ec_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_lib.c,v 1.19 2015/09/10 15:56:25 jsing Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.20 2015/10/13 15:25:18 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -1102,3 +1102,19 @@ EC_GROUP_have_precompute_mult(const EC_GROUP * group) | |||
1102 | return 0; /* cannot tell whether precomputation has | 1102 | return 0; /* cannot tell whether precomputation has |
1103 | * been performed */ | 1103 | * been performed */ |
1104 | } | 1104 | } |
1105 | |||
1106 | EC_KEY * | ||
1107 | ECParameters_dup(EC_KEY *key) | ||
1108 | { | ||
1109 | unsigned char *p = NULL; | ||
1110 | EC_KEY *k = NULL; | ||
1111 | int len; | ||
1112 | |||
1113 | if (key == NULL) | ||
1114 | return (NULL); | ||
1115 | |||
1116 | if ((len = i2d_ECParameters(key, &p)) > 0) | ||
1117 | k = d2i_ECParameters(NULL, (const unsigned char **)&p, len); | ||
1118 | |||
1119 | return (k); | ||
1120 | } | ||
diff --git a/src/lib/libssl/src/doc/crypto/ec.pod b/src/lib/libssl/src/doc/crypto/ec.pod index 7d57ba8ea0..891948e4f6 100644 --- a/src/lib/libssl/src/doc/crypto/ec.pod +++ b/src/lib/libssl/src/doc/crypto/ec.pod | |||
@@ -158,7 +158,7 @@ ec - Elliptic Curve functions | |||
158 | int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); | 158 | int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); |
159 | int ECParameters_print_fp(FILE *fp, const EC_KEY *key); | 159 | int ECParameters_print_fp(FILE *fp, const EC_KEY *key); |
160 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); | 160 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); |
161 | #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) | 161 | EC_KEY *ECParameters_dup(EC_KEY *key); |
162 | #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ | 162 | #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ |
163 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \ | 163 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \ |
164 | EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) | 164 | EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) |