已合并
Support X25519 cert #996
rayoia创建于 1月13日
Support X25519 cert #996
已合并
共 2 个文件变更+27-0
| @@ -127,6 +127,7 @@ BslOidInfo g_oidTable[] = { | |||
| 127 | {{3, "\125\4\11", BSL_OID_GLOBAL}, "STREET", BSL_CID_AT_STREETADDRESS}, | 127 | {{3, "\125\4\11", BSL_OID_GLOBAL}, "STREET", BSL_CID_AT_STREETADDRESS}, |
| 128 | {{5, "\53\201\4\0\41", BSL_OID_GLOBAL}, "PRIME224", BSL_CID_NIST_PRIME224}, | 128 | {{5, "\53\201\4\0\41", BSL_OID_GLOBAL}, "PRIME224", BSL_CID_NIST_PRIME224}, |
| 129 | {{3, "\53\145\160", BSL_OID_GLOBAL}, "ED25519", BSL_CID_ED25519}, | 129 | {{3, "\53\145\160", BSL_OID_GLOBAL}, "ED25519", BSL_CID_ED25519}, |
| 130 | + {{3, "\53\145\156", BSL_OID_GLOBAL}, "X25519", BSL_CID_X25519}, | ||
| 130 | {{9, "\52\206\110\206\367\15\1\1\12", BSL_OID_GLOBAL}, "RSASSAPSS", BSL_CID_RSASSAPSS}, | 131 | {{9, "\52\206\110\206\367\15\1\1\12", BSL_OID_GLOBAL}, "RSASSAPSS", BSL_CID_RSASSAPSS}, |
| 131 | {{9, "\52\206\110\206\367\15\1\1\10", BSL_OID_GLOBAL}, "MGF1", BSL_CID_MGF1}, | 132 | {{9, "\52\206\110\206\367\15\1\1\10", BSL_OID_GLOBAL}, "MGF1", BSL_CID_MGF1}, |
| 132 | {{8, "\52\201\34\317\125\1\150\2", BSL_OID_GLOBAL}, "SM4-CBC", BSL_CID_SM4_CBC}, | 133 | {{8, "\52\201\34\317\125\1\150\2", BSL_OID_GLOBAL}, "SM4-CBC", BSL_CID_SM4_CBC}, |
| @@ -419,6 +419,26 @@ static int32_t ParseEd25519PubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT | |||
| 419 | } | 419 | } |
| 420 | 420 | ||
| 421 | 421 | ||
| 422 | + | ||
| 423 | +static int32_t ParseX25519PubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT_EAL_PkeyCtx **ealPubKey) | ||
| 424 | +{ | ||
| 425 | + CRYPT_EAL_PkeyCtx *pctx = CRYPT_EAL_PkeyNewCtx(CRYPT_PKEY_X25519); | ||
| 426 | + if (pctx == NULL) { | ||
| 427 | + BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); | ||
| 428 | + return CRYPT_MEM_ALLOC_FAIL; | ||
| 429 | + } | ||
| 430 | + CRYPT_EAL_PkeyPub pub = {.id = CRYPT_PKEY_X25519, .key.curve25519Pub = {.data = buff, .len = buffLen}}; | ||
| 431 | + int32_t ret = CRYPT_EAL_PkeySetPub(pctx, &pub); | ||
| 432 | + if (ret != CRYPT_SUCCESS) { | ||
| 433 | + CRYPT_EAL_PkeyFreeCtx(pctx); | ||
| 434 | + BSL_ERR_PUSH_ERROR(ret); | ||
| 435 | + return ret; | ||
| 436 | + } | ||
| 437 | + *ealPubKey = pctx; | ||
| 438 | + return ret; | ||
| 439 | +} | ||
| 440 | + | ||
| 441 | + | ||
| 422 | static int32_t ParsePk8PrikeyAsn1(CRYPT_ENCODE_DECODE_Pk8PrikeyInfo *pk8PrikeyInfo, CRYPT_EAL_PkeyCtx **ealPriKey) | 442 | static int32_t ParsePk8PrikeyAsn1(CRYPT_ENCODE_DECODE_Pk8PrikeyInfo *pk8PrikeyInfo, CRYPT_EAL_PkeyCtx **ealPriKey) |
| 423 | { | 443 | { |
| 424 | 444 | ||
| @@ -478,6 +498,12 @@ int32_t ParseSubPubkeyAsn1(BSL_ASN1_Buffer *encode, CRYPT_EAL_PkeyCtx **ealPubKe | |||
| 478 | return ParseEd25519PubkeyAsn1Buff(bitPubkey.buff, bitPubkey.len, ealPubKey); | 498 | return ParseEd25519PubkeyAsn1Buff(bitPubkey.buff, bitPubkey.len, ealPubKey); |
| 479 | } | 499 | } |
| 480 | 500 | ||
| 501 | + | ||
| 502 | + (void)algParam; | ||
| 503 | + if (cid == BSL_CID_X25519) { | ||
| 504 | + return ParseX25519PubkeyAsn1Buff(bitPubkey.buff, bitPubkey.len, ealPubKey); | ||
| 505 | + } | ||
| 506 | + | ||
| 481 | 507 | ||
| 482 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_UNKNOWN_OID); | 508 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_UNKNOWN_OID); |
| 483 | return CRYPT_DECODE_UNKNOWN_OID; | 509 | return CRYPT_DECODE_UNKNOWN_OID; |