Update SM9 EVP

This commit is contained in:
Zhi Guan
2018-12-03 17:15:57 +08:00
parent c301af807b
commit c0ee87b077
8 changed files with 389 additions and 232 deletions

View File

@@ -1412,149 +1412,145 @@ int ERR_load_EC_strings(void);
# define EC_F_ECP_NISTZ256_POINTS_MUL 137
# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 138
# define EC_F_ECP_NISTZ256_WINDOWED_MUL 139
# define EC_F_ECP_SM2Z256_GET_AFFINE 278
# define EC_F_ECP_SM2Z256_MULT_PRECOMPUTE 279
# define EC_F_ECP_SM2Z256_POINTS_MUL 280
# define EC_F_ECP_SM2Z256_PRE_COMP_NEW 281
# define EC_F_ECP_SM2Z256_WINDOWED_MUL 282
# define EC_F_ECX_KEY_OP 140
# define EC_F_ECX_PRIV_ENCODE 141
# define EC_F_ECX_PUB_ENCODE 142
# define EC_F_EC_ASN1_GROUP2CURVE 143
# define EC_F_EC_ASN1_GROUP2FIELDID 144
# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 145
# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 146
# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 147
# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 148
# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 149
# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 150
# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 151
# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 152
# define EC_F_EC_GFP_MONT_FIELD_DECODE 153
# define EC_F_EC_GFP_MONT_FIELD_ENCODE 154
# define EC_F_EC_GFP_MONT_FIELD_MUL 155
# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 156
# define EC_F_EC_GFP_MONT_FIELD_SQR 157
# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 158
# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 159
# define EC_F_EC_GFP_NISTP224_POINTS_MUL 160
# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 161
# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 162
# define EC_F_EC_GFP_NISTP256_POINTS_MUL 163
# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 164
# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 165
# define EC_F_EC_GFP_NISTP521_POINTS_MUL 166
# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 167
# define EC_F_EC_GFP_NIST_FIELD_MUL 168
# define EC_F_EC_GFP_NIST_FIELD_SQR 169
# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 170
# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 171
# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 172
# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 173
# define EC_F_EC_GFP_SIMPLE_OCT2POINT 174
# define EC_F_EC_GFP_SIMPLE_POINT2OCT 175
# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 176
# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 177
# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 178
# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 179
# define EC_F_EC_GFP_SM2P256_GROUP_SET_CURVE 274
# define EC_F_EC_GFP_SM2P256_POINTS_MUL 275
# define EC_F_EC_GFP_SM2P256_POINT_GET_AFFINE_COORDINATES 276
# define EC_F_EC_GROUP_CHECK 180
# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 181
# define EC_F_EC_GROUP_COPY 182
# define EC_F_EC_GROUP_GENERATE_TYPE1CURVE 183
# define EC_F_EC_GROUP_GET_CURVE_GF2M 184
# define EC_F_EC_GROUP_GET_CURVE_GFP 185
# define EC_F_EC_GROUP_GET_DEGREE 186
# define EC_F_EC_GROUP_GET_ECPARAMETERS 187
# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 188
# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 189
# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 190
# define EC_F_EC_GROUP_GET_TYPE1CURVE_ETA 191
# define EC_F_EC_GROUP_GET_TYPE1CURVE_ZETA 192
# define EC_F_EC_GROUP_IS_TYPE1CURVE 193
# define EC_F_EC_GROUP_NEW 194
# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 195
# define EC_F_EC_GROUP_NEW_FROM_DATA 196
# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 197
# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 198
# define EC_F_EC_GROUP_NEW_TYPE1CURVE 199
# define EC_F_EC_GROUP_SET_CURVE_GF2M 200
# define EC_F_EC_GROUP_SET_CURVE_GFP 201
# define EC_F_EC_GROUP_SET_GENERATOR 202
# define EC_F_EC_KEY_CHECK_KEY 203
# define EC_F_EC_KEY_COPY 204
# define EC_F_EC_KEY_GENERATE_KEY 205
# define EC_F_EC_KEY_NEW_METHOD 206
# define EC_F_EC_KEY_OCT2PRIV 207
# define EC_F_EC_KEY_PRINT_FP 208
# define EC_F_EC_KEY_PRIV2OCT 209
# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 210
# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 211
# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 212
# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 213
# define EC_F_EC_POINTS_MAKE_AFFINE 214
# define EC_F_EC_POINT_ADD 215
# define EC_F_EC_POINT_CMP 216
# define EC_F_EC_POINT_CMP_FPPOINT 217
# define EC_F_EC_POINT_COPY 218
# define EC_F_EC_POINT_DBL 219
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 220
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 221
# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 222
# define EC_F_EC_POINT_HASH2POINT 223
# define EC_F_EC_POINT_INVERT 224
# define EC_F_EC_POINT_IS_AT_INFINITY 225
# define EC_F_EC_POINT_IS_ON_CURVE 226
# define EC_F_EC_POINT_MAKE_AFFINE 227
# define EC_F_EC_POINT_NEW 228
# define EC_F_EC_POINT_OCT2POINT 229
# define EC_F_EC_POINT_POINT2OCT 230
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 231
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 232
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 233
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 234
# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 235
# define EC_F_EC_POINT_SET_TO_INFINITY 236
# define EC_F_EC_PRE_COMP_NEW 237
# define EC_F_EC_TYPE1CURVE_TATE 238
# define EC_F_EC_WNAF_MUL 239
# define EC_F_EC_WNAF_PRECOMPUTE_MULT 240
# define EC_F_I2D_ECIESPARAMETERS 241
# define EC_F_I2D_ECPARAMETERS 242
# define EC_F_I2D_ECPKPARAMETERS 243
# define EC_F_I2D_ECPRIVATEKEY 244
# define EC_F_I2O_ECPUBLICKEY 245
# define EC_F_NISTP224_PRE_COMP_NEW 246
# define EC_F_NISTP256_PRE_COMP_NEW 247
# define EC_F_NISTP521_PRE_COMP_NEW 248
# define EC_F_O2I_ECPUBLICKEY 249
# define EC_F_OLD_EC_PRIV_DECODE 250
# define EC_F_OSSL_ECDH_COMPUTE_KEY 251
# define EC_F_OSSL_ECDSA_SIGN_SIG 252
# define EC_F_OSSL_ECDSA_VERIFY_SIG 253
# define EC_F_PKEY_ECX_DERIVE 254
# define EC_F_PKEY_EC_CTRL 255
# define EC_F_PKEY_EC_CTRL_STR 256
# define EC_F_PKEY_EC_DECRYPT 257
# define EC_F_PKEY_EC_DERIVE 258
# define EC_F_PKEY_EC_ENCRYPT 259
# define EC_F_PKEY_EC_KEYGEN 260
# define EC_F_PKEY_EC_PARAMGEN 261
# define EC_F_PKEY_EC_SIGN 262
# define EC_F_SM2P256_PRE_COMP_NEW 277
# define EC_F_SM2_COMPUTE_ID_DIGEST 263
# define EC_F_SM2_COMPUTE_MESSAGE_DIGEST 264
# define EC_F_SM2_DO_ENCRYPT 265
# define EC_F_SM2_GET_PUBLIC_KEY_DATA 266
# define EC_F_SM2_KAP_COMPUTE_KEY 267
# define EC_F_SM2_KAP_CTX_INIT 268
# define EC_F_SM2_KAP_FINAL_CHECK 269
# define EC_F_SM2_KAP_PREPARE 270
# define EC_F_TYPE1CURVE_EVAL_LINE_TEXTBOOK 271
# define EC_F_TYPE1CURVE_EVAL_MILLER_TEXTBOOK 272
# define EC_F_TYPE1CURVE_PHI 273
# define EC_F_ECP_SM2Z256_GET_AFFINE 140
# define EC_F_ECP_SM2Z256_MULT_PRECOMPUTE 141
# define EC_F_ECP_SM2Z256_POINTS_MUL 142
# define EC_F_ECP_SM2Z256_PRE_COMP_NEW 143
# define EC_F_ECP_SM2Z256_WINDOWED_MUL 144
# define EC_F_ECX_KEY_OP 145
# define EC_F_ECX_PRIV_ENCODE 146
# define EC_F_ECX_PUB_ENCODE 147
# define EC_F_EC_ASN1_GROUP2CURVE 148
# define EC_F_EC_ASN1_GROUP2FIELDID 149
# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 150
# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 151
# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 152
# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 153
# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 154
# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 155
# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 156
# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 157
# define EC_F_EC_GFP_MONT_FIELD_DECODE 158
# define EC_F_EC_GFP_MONT_FIELD_ENCODE 159
# define EC_F_EC_GFP_MONT_FIELD_MUL 160
# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 161
# define EC_F_EC_GFP_MONT_FIELD_SQR 162
# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 163
# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 164
# define EC_F_EC_GFP_NISTP224_POINTS_MUL 165
# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 166
# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 167
# define EC_F_EC_GFP_NISTP256_POINTS_MUL 168
# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 169
# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 170
# define EC_F_EC_GFP_NISTP521_POINTS_MUL 171
# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 172
# define EC_F_EC_GFP_NIST_FIELD_MUL 173
# define EC_F_EC_GFP_NIST_FIELD_SQR 174
# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 175
# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 176
# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 177
# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 178
# define EC_F_EC_GFP_SIMPLE_OCT2POINT 179
# define EC_F_EC_GFP_SIMPLE_POINT2OCT 180
# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 181
# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 182
# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 183
# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 184
# define EC_F_EC_GROUP_CHECK 185
# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 186
# define EC_F_EC_GROUP_COPY 187
# define EC_F_EC_GROUP_GENERATE_TYPE1CURVE 188
# define EC_F_EC_GROUP_GET_CURVE_GF2M 189
# define EC_F_EC_GROUP_GET_CURVE_GFP 190
# define EC_F_EC_GROUP_GET_DEGREE 191
# define EC_F_EC_GROUP_GET_ECPARAMETERS 192
# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 193
# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 194
# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 195
# define EC_F_EC_GROUP_GET_TYPE1CURVE_ETA 196
# define EC_F_EC_GROUP_GET_TYPE1CURVE_ZETA 197
# define EC_F_EC_GROUP_IS_TYPE1CURVE 198
# define EC_F_EC_GROUP_NEW 199
# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 200
# define EC_F_EC_GROUP_NEW_FROM_DATA 201
# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 202
# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 203
# define EC_F_EC_GROUP_NEW_TYPE1CURVE 204
# define EC_F_EC_GROUP_SET_CURVE_GF2M 205
# define EC_F_EC_GROUP_SET_CURVE_GFP 206
# define EC_F_EC_GROUP_SET_GENERATOR 207
# define EC_F_EC_KEY_CHECK_KEY 208
# define EC_F_EC_KEY_COPY 209
# define EC_F_EC_KEY_GENERATE_KEY 210
# define EC_F_EC_KEY_NEW_METHOD 211
# define EC_F_EC_KEY_OCT2PRIV 212
# define EC_F_EC_KEY_PRINT_FP 213
# define EC_F_EC_KEY_PRIV2OCT 214
# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 215
# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 216
# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 217
# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 218
# define EC_F_EC_POINTS_MAKE_AFFINE 219
# define EC_F_EC_POINT_ADD 220
# define EC_F_EC_POINT_CMP 221
# define EC_F_EC_POINT_CMP_FPPOINT 222
# define EC_F_EC_POINT_COPY 223
# define EC_F_EC_POINT_DBL 224
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 225
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 226
# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 227
# define EC_F_EC_POINT_HASH2POINT 228
# define EC_F_EC_POINT_INVERT 229
# define EC_F_EC_POINT_IS_AT_INFINITY 230
# define EC_F_EC_POINT_IS_ON_CURVE 231
# define EC_F_EC_POINT_MAKE_AFFINE 232
# define EC_F_EC_POINT_NEW 233
# define EC_F_EC_POINT_OCT2POINT 234
# define EC_F_EC_POINT_POINT2OCT 235
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 236
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 237
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 238
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 239
# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 240
# define EC_F_EC_POINT_SET_TO_INFINITY 241
# define EC_F_EC_PRE_COMP_NEW 242
# define EC_F_EC_TYPE1CURVE_TATE 243
# define EC_F_EC_WNAF_MUL 244
# define EC_F_EC_WNAF_PRECOMPUTE_MULT 245
# define EC_F_I2D_ECIESPARAMETERS 246
# define EC_F_I2D_ECPARAMETERS 247
# define EC_F_I2D_ECPKPARAMETERS 248
# define EC_F_I2D_ECPRIVATEKEY 249
# define EC_F_I2O_ECPUBLICKEY 250
# define EC_F_NISTP224_PRE_COMP_NEW 251
# define EC_F_NISTP256_PRE_COMP_NEW 252
# define EC_F_NISTP521_PRE_COMP_NEW 253
# define EC_F_O2I_ECPUBLICKEY 254
# define EC_F_OLD_EC_PRIV_DECODE 255
# define EC_F_OSSL_ECDH_COMPUTE_KEY 256
# define EC_F_OSSL_ECDSA_SIGN_SIG 257
# define EC_F_OSSL_ECDSA_VERIFY_SIG 258
# define EC_F_PKEY_ECX_DERIVE 259
# define EC_F_PKEY_EC_CTRL 260
# define EC_F_PKEY_EC_CTRL_STR 261
# define EC_F_PKEY_EC_DECRYPT 262
# define EC_F_PKEY_EC_DERIVE 263
# define EC_F_PKEY_EC_ENCRYPT 264
# define EC_F_PKEY_EC_KEYGEN 265
# define EC_F_PKEY_EC_PARAMGEN 266
# define EC_F_PKEY_EC_SIGN 267
# define EC_F_SM2_COMPUTE_ID_DIGEST 268
# define EC_F_SM2_COMPUTE_MESSAGE_DIGEST 269
# define EC_F_SM2_DO_ENCRYPT 270
# define EC_F_SM2_GET_PUBLIC_KEY_DATA 271
# define EC_F_SM2_KAP_COMPUTE_KEY 272
# define EC_F_SM2_KAP_CTX_INIT 273
# define EC_F_SM2_KAP_FINAL_CHECK 274
# define EC_F_SM2_KAP_PREPARE 275
# define EC_F_TYPE1CURVE_EVAL_LINE_TEXTBOOK 276
# define EC_F_TYPE1CURVE_EVAL_MILLER_TEXTBOOK 277
# define EC_F_TYPE1CURVE_PHI 278
/* Reason codes. */
# define EC_R_ASN1_ERROR 100
@@ -1578,7 +1574,6 @@ int ERR_load_EC_strings(void);
# define EC_R_ECIES_ENCRYPT_FAILED 118
# define EC_R_ECIES_VERIFY_MAC_FAILURE 119
# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 120
# define EC_R_ENCODE_ERROR 198
# define EC_R_ENCRYPT_FAILED 121
# define EC_R_ENCRYPT_FAILURE 122
# define EC_R_ERROR 123
@@ -1588,7 +1583,6 @@ int ERR_load_EC_strings(void);
# define EC_R_GET_TYPE1CURVE_ZETA_FAILURE 127
# define EC_R_GF2M_NOT_SUPPORTED 128
# define EC_R_GROUP2PKPARAMETERS_FAILURE 129
# define EC_R_GROUP_MISMATCH 199
# define EC_R_HMAC_FAILURE 130
# define EC_R_I2D_ECPKPARAMETERS_FAILURE 131
# define EC_R_INCOMPATIBLE_OBJECTS 132

View File

@@ -41,9 +41,9 @@ extern "C" {
*/
# define OPENSSL_VERSION_NUMBER 0x1010004fL
# ifdef OPENSSL_FIPS
# define OPENSSL_VERSION_TEXT "GmSSL 2.4.1 - OpenSSL 1.1.0d-fips 16 Nov 2018"
# define OPENSSL_VERSION_TEXT "GmSSL 2.4.2 - OpenSSL 1.1.0d-fips 3 Dec 2018"
# else
# define OPENSSL_VERSION_TEXT "GmSSL 2.4.1 - OpenSSL 1.1.0d 16 Nov 2018"
# define OPENSSL_VERSION_TEXT "GmSSL 2.4.2 - OpenSSL 1.1.0d 3 Dec 2018"
# endif
/*-

View File

@@ -176,6 +176,9 @@ int SM9_compute_share_key_B(int type,
const char *IDA, size_t IDAlen,
SM9PrivateKey *skB);
int SM9_MASTER_KEY_print(BIO *bp, const SM9_MASTER_KEY *x, int off);
int SM9_KEY_print(BIO *bp, const SM9_KEY *x, int off);
#ifndef OPENSSL_NO_STDIO
SM9MasterSecret *d2i_SM9MasterSecret_fp(FILE *fp, SM9MasterSecret **pp);
@@ -288,6 +291,9 @@ int ERR_load_SM9_strings(void);
/* Error codes for the SM9 functions. */
/* Function codes. */
# define SM9_F_DO_SM9_KEY_PRINT 143
# define SM9_F_DO_SM9_MASTER_KEY_PRINT 144
# define SM9_F_DO_SM9_MASTER_PRINT 142
# define SM9_F_OLD_SM9_MASTER_DECODE 100
# define SM9_F_OLD_SM9_PRIV_DECODE 101
# define SM9_F_PKEY_SM9_COPY 102
@@ -318,6 +324,11 @@ int ERR_load_SM9_strings(void);
# define SM9_F_SM9_MASTER_ENCODE 127
# define SM9_F_SM9_MASTER_KEY_EXTRACT_KEY 128
# define SM9_F_SM9_MASTER_KEY_NEW 129
# define SM9_F_SM9_MASTER_OLD_PRIV_DECODE 145
# define SM9_F_SM9_MASTER_PRIV_DECODE 146
# define SM9_F_SM9_MASTER_PRIV_ENCODE 147
# define SM9_F_SM9_MASTER_PUB_DECODE 148
# define SM9_F_SM9_OLD_PRIV_DECODE 149
# define SM9_F_SM9_PARAMS_DECODE 130
# define SM9_F_SM9_PRIV_DECODE 131
# define SM9_F_SM9_PRIV_ENCODE 132