|
@@ -519,10 +519,390 @@ int _ecc_new_api(void)
|
|
return CRYPT_OK;
|
|
return CRYPT_OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
|
|
|
|
+{
|
|
|
|
+ if (should_type != is->type) return CRYPT_ERROR;
|
|
|
|
+ if (should_type == PK_PRIVATE) {
|
|
|
|
+ if (mp_cmp(should->k, is->k) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ }
|
|
|
|
+ if (mp_cmp(should->dp.prime, is->dp.prime) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ if (mp_cmp(should->dp.A, is->dp.A) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ if (mp_cmp(should->dp.B, is->dp.B) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ if (mp_cmp(should->dp.order, is->dp.order) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ if (mp_cmp(should->dp.base.x, is->dp.base.x) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ if (mp_cmp(should->dp.base.y, is->dp.base.y) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ if (mp_cmp(should->pubkey.x, is->pubkey.x) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ if (mp_cmp(should->pubkey.y, is->pubkey.y) != LTC_MP_EQ) return CRYPT_ERROR;
|
|
|
|
+ if (should->dp.size != is->dp.size) return CRYPT_ERROR;
|
|
|
|
+ if (should->dp.cofactor != is->dp.cofactor) return CRYPT_ERROR;
|
|
|
|
+ return CRYPT_OK;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int _ecc_import_export(void) {
|
|
|
|
+ const ltc_ecc_curve *cu;
|
|
|
|
+ ecc_key key, pri, pub;
|
|
|
|
+ unsigned char out[300];
|
|
|
|
+ unsigned long outlen;
|
|
|
|
+
|
|
|
|
+ /* the following test keys were generated by:
|
|
|
|
+ # no password
|
|
|
|
+ openssl ecparam -name secp256k1 -genkey -out main-key.pem
|
|
|
|
+ openssl ec -in main-key.pem -param_enc explicit -out long_pri.der -outform DER
|
|
|
|
+ openssl ec -in main-key.pem -param_enc explicit -conv_form compressed -out long_pric.der -outform DER
|
|
|
|
+ openssl ec -in main-key.pem -param_enc explicit -pubout -out long_pub.der -outform DER
|
|
|
|
+ openssl ec -in main-key.pem -param_enc explicit -pubout -conv_form compressed -out long_pubc.der -outform DER
|
|
|
|
+ openssl ec -in main-key.pem -param_enc named_curve -out short_pri.der -outform DER
|
|
|
|
+ openssl ec -in main-key.pem -param_enc named_curve -conv_form compressed -out short_pric.der -outform DER
|
|
|
|
+ openssl ec -in main-key.pem -param_enc named_curve -pubout -out short_pub.der -outform DER
|
|
|
|
+ openssl ec -in main-key.pem -param_enc named_curve -pubout -conv_form compressed -out short_pubc.der -outform DER
|
|
|
|
+ # X.509 EC certificates
|
|
|
|
+ openssl req -new -x509 -keyform der -key long_pri.der -sha512 -subj '/CN=Test Cert EC' -out x509_cert_long.der -outform der -days 365000
|
|
|
|
+ openssl req -new -x509 -keyform der -key long_pric.der -sha512 -subj '/CN=Test Cert EC' -out x509_cert_longc.der -outform der -days 365000
|
|
|
|
+ openssl req -new -x509 -keyform der -key short_pri.der -sha512 -subj '/CN=Test Cert EC' -out x509_cert_short.der -outform der -days 365000
|
|
|
|
+ openssl req -new -x509 -keyform der -key short_pric.der -sha512 -subj '/CN=Test Cert EC' -out x509_cert_shortc.der -outform der -days 365000
|
|
|
|
+ */
|
|
|
|
+ static const unsigned char long_pri[] = { /* private + long public, explicit curve params */
|
|
|
|
+ 0x30, 0x82, 0x01, 0x13, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91,
|
|
|
|
+ 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0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5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01,
|
|
|
|
+ 0x01, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1,
|
|
|
|
+ 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5,
|
|
|
|
+ 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7,
|
|
|
|
+ 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e,
|
|
|
|
+ 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char long_pric[] = { /* private + compressed public, explicit curve params */
|
|
|
|
+ 0x30, 0x81, 0xd3, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b,
|
|
|
|
+ 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f,
|
|
|
|
+ 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x81, 0x85, 0x30, 0x81, 0x82, 0x02, 0x01,
|
|
|
|
+ 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff,
|
|
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30,
|
|
|
|
+ 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x21, 0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc,
|
|
|
|
+ 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce,
|
|
|
|
+ 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc,
|
|
|
|
+ 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01,
|
|
|
|
+ 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
|
|
|
|
+ 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
|
|
|
|
+ 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char long_pub[] = { /* long public, explicit curve params */
|
|
|
|
+ 0x30, 0x81, 0xf5, 0x30, 0x81, 0xae, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30,
|
|
|
|
+ 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01,
|
|
|
|
+ 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
|
|
|
|
+ 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x41, 0x04, 0x79, 0xbe,
|
|
|
|
+ 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b,
|
|
|
|
+ 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x48, 0x3a,
|
|
|
|
+ 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17,
|
|
|
|
+ 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8, 0x02, 0x21,
|
|
|
|
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
|
|
|
|
+ 0x41, 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
|
|
|
|
+ 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
|
|
|
|
+ 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a,
|
|
|
|
+ 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5,
|
|
|
|
+ 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char long_pubc[] = { /* compressed public, explicit curve params */
|
|
|
|
+ 0x30, 0x81, 0xb5, 0x30, 0x81, 0x8e, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30,
|
|
|
|
+ 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01,
|
|
|
|
+ 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
|
|
|
|
+ 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x21, 0x02, 0x79, 0xbe,
|
|
|
|
+ 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b,
|
|
|
|
+ 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x02, 0x21,
|
|
|
|
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
|
|
|
|
+ 0x41, 0x02, 0x01, 0x01, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
|
|
|
|
+ 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
|
|
|
|
+ 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char short_pri[] = { /* private + long public, curve by OID */
|
|
|
|
+ 0x30, 0x74, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba,
|
|
|
|
+ 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f,
|
|
|
|
+ 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x07, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a,
|
|
|
|
+ 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
|
|
|
|
+ 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
|
|
|
|
+ 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c,
|
|
|
|
+ 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b,
|
|
|
|
+ 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char short_pric[] = { /* private + compressed public, curve by OID */
|
|
|
|
+ 0x30, 0x54, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba,
|
|
|
|
+ 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f,
|
|
|
|
+ 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x07, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a,
|
|
|
|
+ 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
|
|
|
|
+ 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
|
|
|
|
+ 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char short_pub[] = { /* long public, curve by OID */
|
|
|
|
+ 0x30, 0x56, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b,
|
|
|
|
+ 0x81, 0x04, 0x00, 0x0a, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
|
|
|
|
+ 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
|
|
|
|
+ 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a,
|
|
|
|
+ 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5,
|
|
|
|
+ 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char short_pubc[] = { /* compressed public, curve by OID */
|
|
|
|
+ 0x30, 0x36, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b,
|
|
|
|
+ 0x81, 0x04, 0x00, 0x0a, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
|
|
|
|
+ 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
|
|
|
|
+ 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char raw_pri[] = { /* raw private key */
|
|
|
|
+ 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7,
|
|
|
|
+ 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char raw_pub[] = { /* raw public key - long form */
|
|
|
|
+ 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba,
|
|
|
|
+ 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5,
|
|
|
|
+ 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63,
|
|
|
|
+ 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79,
|
|
|
|
+ 0x4d
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char raw_pubc[] = { /* raw public key - compressed form */
|
|
|
|
+ 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba,
|
|
|
|
+ 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5,
|
|
|
|
+ 0x16
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char x509_cert_long[] = { /* X.509 cert, long pubkey, explicit curve params */
|
|
|
|
+ 0x30, 0x82, 0x02, 0x13, 0x30, 0x82, 0x01, 0xba, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
|
|
|
|
+ 0xaf, 0x14, 0xe3, 0x53, 0x36, 0x06, 0x79, 0x34, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
|
|
|
|
+ 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
|
|
|
|
+ 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
|
|
|
|
+ 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
|
|
|
|
+ 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
|
|
|
|
+ 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
|
|
|
|
+ 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x81, 0xf5, 0x30, 0x81, 0xae, 0x06, 0x07,
|
|
|
|
+ 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30, 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06,
|
|
|
|
+ 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00,
|
|
|
|
+ 0x04, 0x01, 0x07, 0x04, 0x41, 0x04, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0,
|
|
|
|
+ 0x62, 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 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x66,
|
|
|
|
+ 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85, 0x70,
|
|
|
|
+ 0xf9, 0x1f, 0x2c, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
|
|
|
|
+ 0x66, 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85,
|
|
|
|
+ 0x70, 0xf9, 0x1f, 0x2c, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
|
|
|
|
+ 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x47,
|
|
|
|
+ 0x00, 0x30, 0x44, 0x02, 0x1f, 0x2a, 0x62, 0x64, 0x05, 0x67, 0xb0, 0x2c, 0xa0, 0xa3, 0xb8, 0x61,
|
|
|
|
+ 0x4e, 0x87, 0x06, 0x69, 0xf2, 0xda, 0x78, 0xd6, 0x0e, 0x8d, 0x9b, 0xf1, 0x43, 0x5f, 0xf6, 0x40,
|
|
|
|
+ 0x9d, 0x9d, 0xbd, 0xce, 0x02, 0x21, 0x00, 0xe9, 0x6f, 0x79, 0xb4, 0x4a, 0x00, 0xf7, 0xfa, 0x81,
|
|
|
|
+ 0x25, 0x29, 0xec, 0x79, 0xb2, 0xfa, 0x86, 0xf8, 0x84, 0xd1, 0x78, 0xe7, 0xf8, 0xfd, 0x76, 0x2d,
|
|
|
|
+ 0x4f, 0xfe, 0x02, 0x72, 0xba, 0x6c, 0xca
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char x509_cert_longc[] = { /* X.509 cert, compressed pubkey, explicit curve params */
|
|
|
|
+ 0x30, 0x82, 0x01, 0xd3, 0x30, 0x82, 0x01, 0x7a, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
|
|
|
|
+ 0x90, 0x5b, 0x48, 0x32, 0x37, 0x4b, 0x72, 0x54, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
|
|
|
|
+ 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
|
|
|
|
+ 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
|
|
|
|
+ 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
|
|
|
|
+ 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
|
|
|
|
+ 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
|
|
|
|
+ 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x81, 0xb5, 0x30, 0x81, 0x8e, 0x06, 0x07,
|
|
|
|
+ 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30, 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06,
|
|
|
|
+ 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,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0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
|
|
|
|
+ 0xca, 0x2a, 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6,
|
|
|
|
+ 0x49, 0x9f, 0x98, 0xcf, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
|
|
|
|
+ 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x47,
|
|
|
|
+ 0x00, 0x30, 0x44, 0x02, 0x20, 0x24, 0x7a, 0xc1, 0xb4, 0x7d, 0x1c, 0x3c, 0x23, 0xc6, 0xad, 0xea,
|
|
|
|
+ 0x04, 0x27, 0x27, 0x65, 0xb8, 0x72, 0x93, 0x46, 0xc9, 0xe9, 0x60, 0x8f, 0xca, 0x96, 0x30, 0x60,
|
|
|
|
+ 0xb3, 0x22, 0xf7, 0x3b, 0x01, 0x02, 0x20, 0x48, 0x30, 0x2a, 0x58, 0x18, 0x46, 0xdb, 0x50, 0x3e,
|
|
|
|
+ 0xad, 0xc3, 0xca, 0xcd, 0x6d, 0x83, 0xd4, 0xc3, 0xc4, 0xa4, 0x8f, 0x37, 0xc3, 0x1d, 0x83, 0x3c,
|
|
|
|
+ 0xd3, 0x1f, 0x8f, 0x38, 0x29, 0x75, 0x2c
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char x509_cert_short[] = { /* X.509 cert, long pubkey, curve by OID */
|
|
|
|
+ 0x30, 0x82, 0x01, 0x74, 0x30, 0x82, 0x01, 0x1a, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
|
|
|
|
+ 0xbd, 0x81, 0x04, 0x29, 0x43, 0x12, 0x79, 0xce, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
|
|
|
|
+ 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
|
|
|
|
+ 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
|
|
|
|
+ 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
|
|
|
|
+ 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
|
|
|
|
+ 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
|
|
|
|
+ 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x56, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86,
|
|
|
|
+ 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x03, 0x42, 0x00, 0x04,
|
|
|
|
+ 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6,
|
|
|
|
+ 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16,
|
|
|
|
+ 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62,
|
|
|
|
+ 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe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x3f,
|
|
|
|
+ 0xfa, 0x2a, 0x6d, 0xe0, 0x2a, 0x83, 0x55, 0x5d
|
|
|
|
+ };
|
|
|
|
+ static const unsigned char x509_cert_shortc[] = { /* X.509 cert, compressed pubkey, curve by OID */
|
|
|
|
+ 0x30, 0x82, 0x01, 0x54, 0x30, 0x81, 0xfa, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x85,
|
|
|
|
+ 0x45, 0x77, 0x75, 0x02, 0x95, 0xf7, 0x06, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
|
|
|
|
+ 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c,
|
|
|
|
+ 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17, 0x0d,
|
|
|
|
+ 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f, 0x33,
|
|
|
|
+ 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30, 0x17,
|
|
|
|
+ 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20,
|
|
|
|
+ 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x36, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48,
|
|
|
|
+ 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x03, 0x22, 0x00, 0x03, 0x2a,
|
|
|
|
+ 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xc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|
|
|
+ 0x9d, 0x7b, 0x70, 0x3e, 0xf5, 0x7d, 0xa4, 0xfd, 0x3c, 0xc6, 0x49, 0x93, 0xd3, 0x5b, 0xef, 0xc9,
|
|
|
|
+ 0xae, 0x97, 0xaf, 0x64, 0x64, 0xf9, 0x69, 0xd8
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if (ltc_mp.sqrtmod_prime == NULL) return CRYPT_NOP; /* we need compressed points which requires sqrtmod_prime */
|
|
|
|
+
|
|
|
|
+ DO(ecc_import_openssl(short_pub, sizeof(short_pub), &pub));
|
|
|
|
+ DO(ecc_import_openssl(short_pri, sizeof(short_pri), &pri));
|
|
|
|
+ DO(ecc_get_curve("SECP256K1", &cu));
|
|
|
|
+
|
|
|
|
+ /* import - raw keys */
|
|
|
|
+ DO(ecc_set_dp(cu, &key));
|
|
|
|
+ DO(ecc_set_key(raw_pri, sizeof(raw_pri), PK_PRIVATE, &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PRIVATE, &pri, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_set_dp(cu, &key));
|
|
|
|
+ DO(ecc_set_key(raw_pub, sizeof(raw_pub), PK_PUBLIC, &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_set_dp(cu, &key));
|
|
|
|
+ DO(ecc_set_key(raw_pubc, sizeof(raw_pubc), PK_PUBLIC, &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+
|
|
|
|
+ /* import - openssl compatible DER format */
|
|
|
|
+ DO(ecc_import_openssl(long_pri, sizeof(long_pri), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PRIVATE, &pri, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_openssl(long_pric, sizeof(long_pric), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PRIVATE, &pri, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_openssl(long_pub, sizeof(long_pub), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_openssl(long_pubc, sizeof(long_pubc), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_openssl(short_pri, sizeof(short_pri), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PRIVATE, &pri, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_openssl(short_pric, sizeof(short_pric), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PRIVATE, &pri, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_openssl(short_pub, sizeof(short_pub), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_openssl(short_pubc, sizeof(short_pubc), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+
|
|
|
|
+ /* import - X.509 EC certificates */
|
|
|
|
+ DO(ecc_import_x509(x509_cert_long, sizeof(x509_cert_long), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_x509(x509_cert_longc, sizeof(x509_cert_longc), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_x509(x509_cert_short, sizeof(x509_cert_short), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+ DO(ecc_import_x509(x509_cert_shortc, sizeof(x509_cert_shortc), &key));
|
|
|
|
+ DO(_ecc_key_cmp(PK_PUBLIC, &pub, &key));
|
|
|
|
+ ecc_free(&key);
|
|
|
|
+
|
|
|
|
+ /* export - openssl compatible DER format */
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_export_openssl(out, &outlen, PK_PRIVATE, &pri));
|
|
|
|
+ if (compare_testvector(out, outlen, long_pri, sizeof(long_pri), "e-long_pri", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_COMPRESSED, &pri));
|
|
|
|
+ if (compare_testvector(out, outlen, long_pric, sizeof(long_pric), "e-long_pric", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_export_openssl(out, &outlen, PK_PUBLIC, &pub));
|
|
|
|
+ if (compare_testvector(out, outlen, long_pub, sizeof(long_pub), "e-long_pub", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_COMPRESSED, &pub));
|
|
|
|
+ if (compare_testvector(out, outlen, long_pubc, sizeof(long_pubc), "e-long_pubc", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_CURVEOID, &pri));
|
|
|
|
+ if (compare_testvector(out, outlen, short_pri, sizeof(short_pri), "e-short_pri", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_CURVEOID|PK_COMPRESSED, &pri));
|
|
|
|
+ if (compare_testvector(out, outlen, short_pric, sizeof(short_pric), "e-short_pric", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_CURVEOID, &pub));
|
|
|
|
+ if (compare_testvector(out, outlen, short_pub, sizeof(short_pub), "e-short_pub", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_CURVEOID|PK_COMPRESSED, &pub));
|
|
|
|
+ if (compare_testvector(out, outlen, short_pubc, sizeof(short_pubc), "e-short_pubc", 0)) return CRYPT_ERROR;
|
|
|
|
+
|
|
|
|
+ /* export - raw keys */
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_get_key(out, &outlen, PK_PRIVATE, &pri));
|
|
|
|
+ if (compare_testvector(out, outlen, raw_pri, sizeof(raw_pri), "e-raw_pri", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_get_key(out, &outlen, PK_PUBLIC, &pub));
|
|
|
|
+ if (compare_testvector(out, outlen, raw_pub, sizeof(raw_pub), "e-raw_pub", 0)) return CRYPT_ERROR;
|
|
|
|
+ outlen = sizeof(out);
|
|
|
|
+ DO(ecc_get_key(out, &outlen, PK_PUBLIC|PK_COMPRESSED, &pub));
|
|
|
|
+ if (compare_testvector(out, outlen, raw_pubc, sizeof(raw_pubc), "e-raw_pubc", 0)) return CRYPT_ERROR;
|
|
|
|
+
|
|
|
|
+ ecc_free(&pri);
|
|
|
|
+ ecc_free(&pub);
|
|
|
|
+ return CRYPT_OK;
|
|
|
|
+}
|
|
|
|
+
|
|
int ecc_tests(void)
|
|
int ecc_tests(void)
|
|
{
|
|
{
|
|
DO(_ecc_old_api()); /* up to 1.18 */
|
|
DO(_ecc_old_api()); /* up to 1.18 */
|
|
DO(_ecc_new_api());
|
|
DO(_ecc_new_api());
|
|
|
|
+ DO(_ecc_import_export());
|
|
DO(_ecc_test_mp());
|
|
DO(_ecc_test_mp());
|
|
DO(_ecc_issue108());
|
|
DO(_ecc_issue108());
|
|
#ifdef LTC_ECC_SHAMIR
|
|
#ifdef LTC_ECC_SHAMIR
|