aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2003-02-21 13:58:23 +0000
committerBodo Möller <bodo@openssl.org>2003-02-21 13:58:23 +0000
commit62e3163b1b153a2414d5c258ace557a3b4d373c5 (patch)
treec009b685a6ec9a7999733a92bd92cf50d1182755 /crypto/ec
parent8214e74f7680156c6ce5fd7ff37bef12311d1796 (diff)
downloadopenssl-62e3163b1b153a2414d5c258ace557a3b4d373c5.tar.gz
ECPublicKey_set_octet_string and ECPublicKey_get_octet_string
behaviour was not quite consistent with the conventions for d2i and i2d functions as far as handling of the 'out' or 'in' pointer is concerned. This patch changes this behaviour, and renames the functions to o2i_ECPublicKey and i2o_ECPublicKey (not 'd2i' and 'i2d' because the external encoding is just a raw object string without any DER icing). Submitted by: Nils Larsch
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ec.h16
-rw-r--r--crypto/ec/ec_asn1.c20
-rw-r--r--crypto/ec/ec_err.c4
3 files changed, 20 insertions, 20 deletions
diff --git a/crypto/ec/ec.h b/crypto/ec/ec.h
index f68963e66f..1013bd8fa4 100644
--- a/crypto/ec/ec.h
+++ b/crypto/ec/ec.h
@@ -319,16 +319,16 @@ int EC_KEY_generate_key(EC_KEY *);
/* EC_KEY_check_key() */
int EC_KEY_check_key(const EC_KEY *);
-/* de- and encode functions for the SEC1 ECPrivateKey */
+/* de- and encoding functions for SEC1 ECPrivateKey */
EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len);
int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out);
-/* de- and encode functions for the elliptic curve parameters */
+/* de- and encoding functions for EC parameters */
EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len);
int i2d_ECParameters(EC_KEY *a, unsigned char **out);
-
-EC_KEY *ECPublicKey_set_octet_string(EC_KEY **a, const unsigned char **in,
- long len);
-int ECPublicKey_get_octet_string(EC_KEY *a, unsigned char **out);
+/* de- and encoding functions for EC public key
+ * (octet string, not DER -- hence 'o2i' and 'i2o') */
+EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len);
+int i2o_ECPublicKey(EC_KEY *a, unsigned char **out);
#ifndef OPENSSL_NO_BIO
int ECParameters_print(BIO *bp, const EC_KEY *x);
@@ -359,8 +359,6 @@ void ERR_load_EC_strings(void);
#define EC_F_ECPARAMETERS_PRINT_FP 148
#define EC_F_ECPKPARAMETERS_PRINT 149
#define EC_F_ECPKPARAMETERS_PRINT_FP 150
-#define EC_F_ECPUBLICKEY_GET_OCTET 151
-#define EC_F_ECPUBLICKEY_SET_OCTET 152
#define EC_F_ECP_NIST_MOD_192 203
#define EC_F_ECP_NIST_MOD_224 204
#define EC_F_ECP_NIST_MOD_256 205
@@ -455,6 +453,8 @@ void ERR_load_EC_strings(void);
#define EC_F_I2D_ECPARAMETERS 190
#define EC_F_I2D_ECPKPARAMETERS 191
#define EC_F_I2D_ECPRIVATEKEY 192
+#define EC_F_I2O_ECPUBLICKEY 151
+#define EC_F_O2I_ECPUBLICKEY 152
/* Reason codes. */
#define EC_R_ASN1_ERROR 115
diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c
index c1c6ffee5a..927a3716cf 100644
--- a/crypto/ec/ec_asn1.c
+++ b/crypto/ec/ec_asn1.c
@@ -1406,8 +1406,7 @@ EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len)
return ret;
}
-EC_KEY *ECPublicKey_set_octet_string(EC_KEY **a, const unsigned char **in,
- long len)
+EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len)
{
EC_KEY *ret=NULL;
@@ -1415,33 +1414,34 @@ EC_KEY *ECPublicKey_set_octet_string(EC_KEY **a, const unsigned char **in,
{
/* sorry, but a EC_GROUP-structur is necessary
* to set the public key */
- ECerr(EC_F_ECPUBLICKEY_SET_OCTET, ERR_R_PASSED_NULL_PARAMETER);
+ ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
ret = *a;
if (ret->pub_key == NULL &&
(ret->pub_key = EC_POINT_new(ret->group)) == NULL)
{
- ECerr(EC_F_ECPUBLICKEY_SET_OCTET, ERR_R_MALLOC_FAILURE);
+ ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_MALLOC_FAILURE);
return 0;
}
if (!EC_POINT_oct2point(ret->group, ret->pub_key, *in, len, NULL))
{
- ECerr(EC_F_ECPUBLICKEY_SET_OCTET, ERR_R_EC_LIB);
+ ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_EC_LIB);
return 0;
}
/* save the point conversion form */
ret->conv_form = (point_conversion_form_t)(*in[0] & ~0x01);
+ *in += len;
return ret;
}
-int ECPublicKey_get_octet_string(EC_KEY *a, unsigned char **out)
+int i2o_ECPublicKey(EC_KEY *a, unsigned char **out)
{
size_t buf_len=0;
if (a == NULL)
{
- ECerr(EC_F_ECPUBLICKEY_GET_OCTET, ERR_R_PASSED_NULL_PARAMETER);
+ ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
@@ -1455,17 +1455,17 @@ int ECPublicKey_get_octet_string(EC_KEY *a, unsigned char **out)
if (*out == NULL)
if ((*out = OPENSSL_malloc(buf_len)) == NULL)
{
- ECerr(EC_F_ECPUBLICKEY_GET_OCTET,
- ERR_R_MALLOC_FAILURE);
+ ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_MALLOC_FAILURE);
return 0;
}
if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form,
*out, buf_len, NULL))
{
- ECerr(EC_F_ECPUBLICKEY_GET_OCTET, ERR_R_EC_LIB);
+ ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB);
OPENSSL_free(*out);
*out = NULL;
return 0;
}
+ *out += buf_len;
return buf_len;
}
diff --git a/crypto/ec/ec_err.c b/crypto/ec/ec_err.c
index 7730402d09..d74ddace58 100644
--- a/crypto/ec/ec_err.c
+++ b/crypto/ec/ec_err.c
@@ -74,8 +74,6 @@ static ERR_STRING_DATA EC_str_functs[]=
{ERR_PACK(0,EC_F_ECPARAMETERS_PRINT_FP,0), "ECParameters_print_fp"},
{ERR_PACK(0,EC_F_ECPKPARAMETERS_PRINT,0), "ECPKParameters_print"},
{ERR_PACK(0,EC_F_ECPKPARAMETERS_PRINT_FP,0), "ECPKParameters_print_fp"},
-{ERR_PACK(0,EC_F_ECPUBLICKEY_GET_OCTET,0), "ECPUBLICKEY_GET_OCTET"},
-{ERR_PACK(0,EC_F_ECPUBLICKEY_SET_OCTET,0), "ECPUBLICKEY_SET_OCTET"},
{ERR_PACK(0,EC_F_ECP_NIST_MOD_192,0), "ECP_NIST_MOD_192"},
{ERR_PACK(0,EC_F_ECP_NIST_MOD_224,0), "ECP_NIST_MOD_224"},
{ERR_PACK(0,EC_F_ECP_NIST_MOD_256,0), "ECP_NIST_MOD_256"},
@@ -170,6 +168,8 @@ static ERR_STRING_DATA EC_str_functs[]=
{ERR_PACK(0,EC_F_I2D_ECPARAMETERS,0), "i2d_ECParameters"},
{ERR_PACK(0,EC_F_I2D_ECPKPARAMETERS,0), "i2d_ECPKParameters"},
{ERR_PACK(0,EC_F_I2D_ECPRIVATEKEY,0), "i2d_ECPrivateKey"},
+{ERR_PACK(0,EC_F_I2O_ECPUBLICKEY,0), "i2o_ECPublicKey"},
+{ERR_PACK(0,EC_F_O2I_ECPUBLICKEY,0), "o2i_ECPublicKey"},
{0,NULL}
};