Commit 2167239a authored by Matt Caswell's avatar Matt Caswell
Browse files

Use lowercase for internal SM2 symbols

parent 206521a0
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ static int pkey_ec_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
#if defined(OPENSSL_NO_SM2)
        return -1;
#else
        ret = SM2_sign(type, tbs, tbslen, sig, &sltmp, ec);
        ret = sm2_sign(type, tbs, tbslen, sig, &sltmp, ec);
#endif
    } else {
        ret = ECDSA_sign(type, tbs, tbslen, sig, &sltmp, ec);
@@ -156,7 +156,7 @@ static int pkey_ec_verify(EVP_PKEY_CTX *ctx,
#if defined(OPENSSL_NO_SM2)
        ret = -1;
#else
        ret = SM2_verify(type, tbs, tbslen, sig, siglen, ec);
        ret = sm2_verify(type, tbs, tbslen, sig, siglen, ec);
#endif
    } else {
        ret = ECDSA_verify(type, tbs, tbslen, sig, siglen, ec);
@@ -223,14 +223,14 @@ static int pkey_ecies_encrypt(EVP_PKEY_CTX *ctx,
            md_type = NID_sm3;

        if (out == NULL) {
            if (!SM2_ciphertext_size(ec, EVP_get_digestbynid(md_type), inlen,
            if (!sm2_ciphertext_size(ec, EVP_get_digestbynid(md_type), inlen,
                                     outlen))
                ret = -1;
            else
                ret = 1;
        }
        else {
            ret = SM2_encrypt(ec, EVP_get_digestbynid(md_type),
            ret = sm2_encrypt(ec, EVP_get_digestbynid(md_type),
                              in, inlen, out, outlen);
        }
# endif
@@ -263,14 +263,14 @@ static int pkey_ecies_decrypt(EVP_PKEY_CTX *ctx,
            md_type = NID_sm3;

        if (out == NULL) {
            if (!SM2_plaintext_size(ec, EVP_get_digestbynid(md_type), inlen,
            if (!sm2_plaintext_size(ec, EVP_get_digestbynid(md_type), inlen,
                                    outlen))
                ret = -1;
            else
                ret = 1;
        }
        else {
            ret = SM2_decrypt(ec, EVP_get_digestbynid(md_type),
            ret = sm2_decrypt(ec, EVP_get_digestbynid(md_type),
                              in, inlen, out, outlen);
        }
# endif
+9 −9
Original line number Diff line number Diff line
@@ -1068,15 +1068,15 @@ SM2_F_PKEY_SM2_CTRL_STR:275:pkey_sm2_ctrl_str
SM2_F_PKEY_SM2_KEYGEN:276:pkey_sm2_keygen
SM2_F_PKEY_SM2_PARAMGEN:277:pkey_sm2_paramgen
SM2_F_PKEY_SM2_SIGN:278:pkey_sm2_sign
SM2_F_SM2_COMPUTE_MSG_HASH:284:SM2_compute_msg_hash
SM2_F_SM2_COMPUTE_USERID_DIGEST:286:SM2_compute_userid_digest
SM2_F_SM2_DECRYPT:279:SM2_decrypt
SM2_F_SM2_ENCRYPT:280:SM2_encrypt
SM2_F_SM2_PLAINTEXT_SIZE:287:SM2_plaintext_size
SM2_F_SM2_SIGN:281:SM2_sign
SM2_F_SM2_SIG_GEN:285:SM2_sig_gen
SM2_F_SM2_SIG_VERIFY:282:SM2_sig_verify
SM2_F_SM2_VERIFY:283:SM2_verify
SM2_F_SM2_COMPUTE_MSG_HASH:284:sm2_compute_msg_hash
SM2_F_SM2_COMPUTE_USERID_DIGEST:286:sm2_compute_userid_digest
SM2_F_SM2_DECRYPT:279:sm2_decrypt
SM2_F_SM2_ENCRYPT:280:sm2_encrypt
SM2_F_SM2_PLAINTEXT_SIZE:287:sm2_plaintext_size
SM2_F_SM2_SIGN:281:sm2_sign
SM2_F_SM2_SIG_GEN:285:sm2_sig_gen
SM2_F_SM2_SIG_VERIFY:282:sm2_sig_verify
SM2_F_SM2_VERIFY:283:sm2_verify
SSL_F_ADD_CLIENT_KEY_SHARE_EXT:438:*
SSL_F_ADD_KEY_SHARE:512:add_key_share
SSL_F_BYTES_TO_CIPHER_LIST:519:bytes_to_cipher_list
+9 −9
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ extern "C" {
/* The default user id as specified in GM/T 0009-2012 */
#  define SM2_DEFAULT_USERID "1234567812345678"

int SM2_compute_userid_digest(uint8_t *out,
int sm2_compute_userid_digest(uint8_t *out,
                              const EVP_MD *digest,
                              const char *user_id, const EC_KEY *key);

@@ -32,11 +32,11 @@ int SM2_compute_userid_digest(uint8_t *out,
 * SM2 signature operation. Computes ZA (user id digest) and then signs
 * H(ZA || msg) using SM2
 */
ECDSA_SIG *SM2_do_sign(const EC_KEY *key,
ECDSA_SIG *sm2_do_sign(const EC_KEY *key,
                       const EVP_MD *digest,
                       const char *user_id, const uint8_t *msg, size_t msg_len);

int SM2_do_verify(const EC_KEY *key,
int sm2_do_verify(const EC_KEY *key,
                  const EVP_MD *digest,
                  const ECDSA_SIG *signature,
                  const char *user_id, const uint8_t *msg, size_t msg_len);
@@ -44,32 +44,32 @@ int SM2_do_verify(const EC_KEY *key,
/*
 * SM2 signature generation. Assumes input is an SM3 digest
 */
int SM2_sign(int type, const unsigned char *dgst, int dgstlen,
int sm2_sign(int type, const unsigned char *dgst, int dgstlen,
             unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);

/*
 * SM2 signature verification. Assumes input is an SM3 digest
 */
int SM2_verify(int type, const unsigned char *dgst, int dgstlen,
int sm2_verify(int type, const unsigned char *dgst, int dgstlen,
               const unsigned char *sig, int siglen, EC_KEY *eckey);


/*
 * SM2 encryption
 */
int SM2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
                        size_t *ct_size);

int SM2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
                       size_t *pt_size);

int SM2_encrypt(const EC_KEY *key,
int sm2_encrypt(const EC_KEY *key,
                const EVP_MD *digest,
                const uint8_t *msg,
                size_t msg_len,
                uint8_t *ciphertext_buf, size_t *ciphertext_len);

int SM2_decrypt(const EC_KEY *key,
int sm2_decrypt(const EC_KEY *key,
                const EVP_MD *digest,
                const uint8_t *ciphertext,
                size_t ciphertext_len, uint8_t *ptext_buf, size_t *ptext_len);
+9 −9
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ ASN1_SEQUENCE(SM2_Ciphertext) = {

IMPLEMENT_ASN1_FUNCTIONS(SM2_Ciphertext)

static size_t EC_field_size(const EC_GROUP *group)
static size_t ec_field_size(const EC_GROUP *group)
{
    /* Is there some simpler way to do this? */
    BIGNUM *p = BN_new();
@@ -59,10 +59,10 @@ static size_t EC_field_size(const EC_GROUP *group)
    return field_size;
}

int SM2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
                       size_t *pt_size)
{
    const size_t field_size = EC_field_size(EC_KEY_get0_group(key));
    const size_t field_size = ec_field_size(EC_KEY_get0_group(key));
    const int md_size = EVP_MD_size(digest);
    size_t overhead;

@@ -85,10 +85,10 @@ int SM2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
    return 1;
}

int SM2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
                        size_t *ct_size)
{
    const size_t field_size = EC_field_size(EC_KEY_get0_group(key));
    const size_t field_size = ec_field_size(EC_KEY_get0_group(key));
    const int md_size = EVP_MD_size(digest);

    if (field_size == 0 || md_size < 0)
@@ -98,7 +98,7 @@ int SM2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
    return 1;
}

int SM2_encrypt(const EC_KEY *key,
int sm2_encrypt(const EC_KEY *key,
                const EVP_MD *digest,
                const uint8_t *msg,
                size_t msg_len, uint8_t *ciphertext_buf, size_t *ciphertext_len)
@@ -121,7 +121,7 @@ int SM2_encrypt(const EC_KEY *key,
    uint8_t *msg_mask = NULL;
    uint8_t *x2y2 = NULL;
    uint8_t *C3 = NULL;
    const size_t field_size = EC_field_size(group);
    const size_t field_size = ec_field_size(group);
    const size_t C3_size = EVP_MD_size(digest);

    /* NULL these before any "goto done" */
@@ -250,7 +250,7 @@ int SM2_encrypt(const EC_KEY *key,
    return rc;
}

int SM2_decrypt(const EC_KEY *key,
int sm2_decrypt(const EC_KEY *key,
                const EVP_MD *digest,
                const uint8_t *ciphertext,
                size_t ciphertext_len, uint8_t *ptext_buf, size_t *ptext_len)
@@ -265,7 +265,7 @@ int SM2_decrypt(const EC_KEY *key,
    BIGNUM *y2 = NULL;
    uint8_t *x2y2 = NULL;
    uint8_t *computed_C3 = NULL;
    const size_t field_size = EC_field_size(group);
    const size_t field_size = ec_field_size(group);
    const int hash_size = EVP_MD_size(digest);
    uint8_t *msg_mask = NULL;
    const uint8_t *C2 = NULL;
+9 −9
Original line number Diff line number Diff line
@@ -20,16 +20,16 @@ static const ERR_STRING_DATA SM2_str_functs[] = {
    {ERR_PACK(ERR_LIB_SM2, SM2_F_PKEY_SM2_PARAMGEN, 0), "pkey_sm2_paramgen"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_PKEY_SM2_SIGN, 0), "pkey_sm2_sign"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_COMPUTE_MSG_HASH, 0),
     "SM2_compute_msg_hash"},
     "sm2_compute_msg_hash"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_COMPUTE_USERID_DIGEST, 0),
     "SM2_compute_userid_digest"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_DECRYPT, 0), "SM2_decrypt"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_ENCRYPT, 0), "SM2_encrypt"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_PLAINTEXT_SIZE, 0), "SM2_plaintext_size"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_SIGN, 0), "SM2_sign"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_SIG_GEN, 0), "SM2_sig_gen"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_SIG_VERIFY, 0), "SM2_sig_verify"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_VERIFY, 0), "SM2_verify"},
     "sm2_compute_userid_digest"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_DECRYPT, 0), "sm2_decrypt"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_ENCRYPT, 0), "sm2_encrypt"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_PLAINTEXT_SIZE, 0), "sm2_plaintext_size"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_SIGN, 0), "sm2_sign"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_SIG_GEN, 0), "sm2_sig_gen"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_SIG_VERIFY, 0), "sm2_sig_verify"},
    {ERR_PACK(ERR_LIB_SM2, SM2_F_SM2_VERIFY, 0), "sm2_verify"},
    {0, NULL}
};

Loading