diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2023-08-11 13:57:25 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2023-08-11 13:57:25 +0000 |
commit | adf89af4b01d8b2854224599452b6fa346b32ffb (patch) | |
tree | 64df950b3a2ebbdc187db9aa4d4e19badee895bd /lib/libcrypto/dsa | |
parent | ad2e4cddb325dcac2511998c6310d10ce8fe4847 (diff) |
Improve variable names in {dh,dsa}_{pub,priv}_{de,en}code()
Use aint for the ASN1_INTEGER holding the key and astr for the ASN1_STRING
holding the parameters. This frees up key and params for their DER encoded
versions, matching the naming we use elsewhere much more closely.
ok jsing
Diffstat (limited to 'lib/libcrypto/dsa')
-rw-r--r-- | lib/libcrypto/dsa/dsa_ameth.c | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/lib/libcrypto/dsa/dsa_ameth.c b/lib/libcrypto/dsa/dsa_ameth.c index 529bab4d478..494bef3ce42 100644 --- a/lib/libcrypto/dsa/dsa_ameth.c +++ b/lib/libcrypto/dsa/dsa_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_ameth.c,v 1.50 2023/08/11 13:53:45 tb Exp $ */ +/* $OpenBSD: dsa_ameth.c,v 1.51 2023/08/11 13:57:24 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -78,23 +78,23 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) X509_ALGOR *algor; int ptype; const void *pval; - const ASN1_STRING *params; - const unsigned char *key_der, *params_der, *p; + const ASN1_STRING *astr; + const unsigned char *key, *params, *p; int key_len, params_len; - ASN1_INTEGER *key = NULL; + ASN1_INTEGER *aint = NULL; DSA *dsa = NULL; int ret = 0; - if (!X509_PUBKEY_get0_param(NULL, &key_der, &key_len, &algor, pubkey)) + if (!X509_PUBKEY_get0_param(NULL, &key, &key_len, &algor, pubkey)) goto err; X509_ALGOR_get0(NULL, &ptype, &pval, algor); if (ptype == V_ASN1_SEQUENCE) { - params = pval; - params_der = params->data; - params_len = params->length; + astr = pval; + params = astr->data; + params_len = astr->length; - p = params_der; + p = params; if ((dsa = d2i_DSAparams(NULL, &p, params_len)) == NULL) { DSAerror(DSA_R_DECODE_ERROR); goto err; @@ -109,12 +109,12 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) goto err; } - p = key_der; - if ((key = d2i_ASN1_INTEGER(NULL, &p, key_len)) == NULL) { + p = key; + if ((aint = d2i_ASN1_INTEGER(NULL, &p, key_len)) == NULL) { DSAerror(DSA_R_DECODE_ERROR); goto err; } - if ((dsa->pub_key = ASN1_INTEGER_to_BN(key, NULL)) == NULL) { + if ((dsa->pub_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) { DSAerror(DSA_R_BN_DECODE_ERROR); goto err; } @@ -132,7 +132,7 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) ret = 1; err: - ASN1_INTEGER_free(key); + ASN1_INTEGER_free(aint); DSA_free(dsa); return ret; @@ -142,35 +142,35 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) { const DSA *dsa = pkey->pkey.dsa; - ASN1_STRING *params = NULL; + ASN1_STRING *astr = NULL; int ptype = V_ASN1_UNDEF; - ASN1_INTEGER *key = NULL; + ASN1_INTEGER *aint = NULL; ASN1_OBJECT *aobj; - unsigned char *params_der = NULL, *key_der = NULL; + unsigned char *params = NULL, *key = NULL; int params_len = 0, key_len = 0; int ret = 0; if (pkey->save_parameters && dsa->p && dsa->q && dsa->g) { - if ((params_len = i2d_DSAparams(dsa, ¶ms_der)) <= 0) { + if ((params_len = i2d_DSAparams(dsa, ¶ms)) <= 0) { DSAerror(ERR_R_MALLOC_FAILURE); params_len = 0; goto err; } - if ((params = ASN1_STRING_new()) == NULL) { + if ((astr = ASN1_STRING_new()) == NULL) { DSAerror(ERR_R_MALLOC_FAILURE); goto err; } - ASN1_STRING_set0(params, params_der, params_len); - params_der = NULL; + ASN1_STRING_set0(astr, params, params_len); + params = NULL; params_len = 0; ptype = V_ASN1_SEQUENCE; } - if ((key = BN_to_ASN1_INTEGER(dsa->pub_key, NULL)) == NULL) { + if ((aint = BN_to_ASN1_INTEGER(dsa->pub_key, NULL)) == NULL) { DSAerror(ERR_R_MALLOC_FAILURE); goto err; } - if ((key_len = i2d_ASN1_INTEGER(key, &key_der)) <= 0) { + if ((key_len = i2d_ASN1_INTEGER(aint, &key)) <= 0) { DSAerror(ERR_R_MALLOC_FAILURE); key_len = 0; goto err; @@ -178,19 +178,19 @@ dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) if ((aobj = OBJ_nid2obj(EVP_PKEY_DSA)) == NULL) goto err; - if (!X509_PUBKEY_set0_param(pk, aobj, ptype, params, key_der, key_len)) + if (!X509_PUBKEY_set0_param(pk, aobj, ptype, astr, key, key_len)) goto err; - params = NULL; - key_der = NULL; + astr = NULL; + key = NULL; key_len = 0; ret = 1; err: - ASN1_STRING_free(params); - ASN1_INTEGER_free(key); - freezero(params_der, params_len); - freezero(key_der, key_len); + ASN1_STRING_free(astr); + ASN1_INTEGER_free(aint); + freezero(params, params_len); + freezero(key, key_len); return ret; } @@ -205,15 +205,15 @@ dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) const X509_ALGOR *algor; int ptype; const void *pval; - const ASN1_STRING *params; - const unsigned char *key_der, *params_der, *p; + const ASN1_STRING *astr; + const unsigned char *key, *params, *p; int key_len, params_len; - ASN1_INTEGER *key = NULL; + ASN1_INTEGER *aint = NULL; BN_CTX *ctx = NULL; DSA *dsa = NULL; int ret = 0; - if (!PKCS8_pkey_get0(NULL, &key_der, &key_len, &algor, p8)) + if (!PKCS8_pkey_get0(NULL, &key, &key_len, &algor, p8)) goto err; X509_ALGOR_get0(NULL, &ptype, &pval, algor); @@ -222,21 +222,21 @@ dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) goto err; } - params = pval; - params_der = params->data; - params_len = params->length; + astr = pval; + params = astr->data; + params_len = astr->length; - p = params_der; + p = params; if ((dsa = d2i_DSAparams(NULL, &p, params_len)) == NULL) { DSAerror(DSA_R_DECODE_ERROR); goto err; } - p = key_der; - if ((key = d2i_ASN1_INTEGER(NULL, &p, key_len)) == NULL) { + p = key; + if ((aint = d2i_ASN1_INTEGER(NULL, &p, key_len)) == NULL) { DSAerror(DSA_R_DECODE_ERROR); goto err; } - if ((dsa->priv_key = ASN1_INTEGER_to_BN(key, NULL)) == NULL) { + if ((dsa->priv_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) { DSAerror(DSA_R_BN_DECODE_ERROR); goto err; } @@ -273,7 +273,7 @@ dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) DSA_free(dsa); BN_CTX_end(ctx); BN_CTX_free(ctx); - ASN1_INTEGER_free(key); + ASN1_INTEGER_free(aint); return ret; } @@ -282,32 +282,32 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) { const DSA *dsa = pkey->pkey.dsa; - ASN1_STRING *params = NULL; + ASN1_STRING *astr = NULL; int ptype = V_ASN1_SEQUENCE; - ASN1_INTEGER *key = NULL; + ASN1_INTEGER *aint = NULL; ASN1_OBJECT *aobj; - unsigned char *params_der = NULL, *key_der = NULL; + unsigned char *params = NULL, *key = NULL; int params_len = 0, key_len = 0; int ret = 0; - if ((params_len = i2d_DSAparams(dsa, ¶ms_der)) <= 0) { + if ((params_len = i2d_DSAparams(dsa, ¶ms)) <= 0) { DSAerror(ERR_R_MALLOC_FAILURE); params_len = 0; goto err; } - if ((params = ASN1_STRING_type_new(V_ASN1_SEQUENCE)) == NULL) { + if ((astr = ASN1_STRING_type_new(V_ASN1_SEQUENCE)) == NULL) { DSAerror(ERR_R_MALLOC_FAILURE); goto err; } - ASN1_STRING_set0(params, params_der, params_len); - params_der = NULL; + ASN1_STRING_set0(astr, params, params_len); + params = NULL; params_len = 0; - if ((key = BN_to_ASN1_INTEGER(dsa->priv_key, NULL)) == NULL) { + if ((aint = BN_to_ASN1_INTEGER(dsa->priv_key, NULL)) == NULL) { DSAerror(DSA_R_BN_ERROR); goto err; } - if ((key_len = i2d_ASN1_INTEGER(key, &key_der)) <= 0) { + if ((key_len = i2d_ASN1_INTEGER(aint, &key)) <= 0) { DSAerror(ERR_R_MALLOC_FAILURE); key_len = 0; goto err; @@ -315,19 +315,19 @@ dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) if ((aobj = OBJ_nid2obj(NID_dsa)) == NULL) goto err; - if (!PKCS8_pkey_set0(p8, aobj, 0, ptype, params, key_der, key_len)) + if (!PKCS8_pkey_set0(p8, aobj, 0, ptype, astr, key, key_len)) goto err; - params = NULL; - key_der = NULL; + astr = NULL; + key = NULL; key_len = 0; ret = 1; err: - ASN1_STRING_free(params); - ASN1_INTEGER_free(key); - freezero(params_der, params_len); - freezero(key_der, key_len); + ASN1_STRING_free(astr); + ASN1_INTEGER_free(aint); + freezero(params, params_len); + freezero(key, key_len); return ret; } |