Skip to content

Commit 18d845c

Browse files
author
Andras Fekete
committed
Add helpful failure messages
1 parent bc04f84 commit 18d845c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/wp_ecc_kmgmt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,11 +1869,13 @@ static int wp_ecc_decode_params(wp_Ecc* ecc, unsigned char* data, word32 len)
18691869
ok = 0;
18701870
}
18711871
if (ok && (data[0] != 0x06)) {
1872+
WOLFPROV_MSG(WP_LOG_PK, "Invalid data");
18721873
ok = 0;
18731874
}
18741875
if (ok) {
18751876
oidLen = data[1];
18761877
if ((oidLen >= 0x80) || (oidLen + 2 > len)) {
1878+
WOLFPROV_MSG(WP_LOG_PK, "OID out of bounds");
18771879
ok = 0;
18781880
}
18791881
}
@@ -1884,17 +1886,20 @@ static int wp_ecc_decode_params(wp_Ecc* ecc, unsigned char* data, word32 len)
18841886
ecc->curveId = wp_ecc_get_curve_id_from_oid(data + 2, oidLen);
18851887
#endif
18861888
if (ecc->curveId == ECC_CURVE_INVALID) {
1889+
WOLFPROV_MSG(WP_LOG_PK, "Invalid curve");
18871890
ok = 0;
18881891
}
18891892
}
18901893

18911894
if (ok) {
18921895
rc = wc_ecc_set_curve(&ecc->key, 0, ecc->curveId);
18931896
if (rc != 0) {
1897+
WOLFPROV_MSG(WP_LOG_PK, "Can't set curve: %d",rc);
18941898
ok = 0;
18951899
}
18961900
}
18971901
if (ok && (!wp_ecc_set_bits(ecc))) {
1902+
WOLFPROV_MSG(WP_LOG_PK, "Can't set bits");
18981903
ok = 0;
18991904
}
19001905

0 commit comments

Comments
 (0)