Skip to content

Commit

Permalink
Remove unnecessary length check
Browse files Browse the repository at this point in the history
  • Loading branch information
aveenismail committed Aug 27, 2024
1 parent f20ebe3 commit e58fcb1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions ykcs11/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,19 @@ CK_RV check_create_rsa_key(CK_ATTRIBUTE_PTR templ, CK_ULONG n, CK_BYTE_PTR id,
}
break;

case CKA_MODULUS_BITS:
switch(*(CK_ULONG_PTR)templ[i].pValue) {
case 1024:
case 2048:
case 3072:
case 4096:
break;
default:
DBG("Unsupported MODULUS_BITS (key length)");
return CKR_ATTRIBUTE_VALUE_INVALID;
}
break;

case CKA_PRIME_1:
has_p = CK_TRUE;
*p = (CK_BYTE_PTR)templ[i].pValue;
Expand Down Expand Up @@ -2616,17 +2629,6 @@ CK_RV check_create_rsa_key(CK_ATTRIBUTE_PTR templ, CK_ULONG n, CK_BYTE_PTR id,
return CKR_TEMPLATE_INCOMPLETE;
}

if (*p_len != 64 && *p_len != 128 && *p_len != 192 && *p_len != 256) {
DBG("Invalid RSA component lengths");
return CKR_ATTRIBUTE_VALUE_INVALID;
}

if (*q_len != *p_len || *dp_len > *p_len ||
*dq_len > *p_len || *qinv_len > *p_len) {
DBG("Invalid RSA component lengths");
return CKR_ATTRIBUTE_VALUE_INVALID;
}

return CKR_OK;
}

Expand Down

0 comments on commit e58fcb1

Please sign in to comment.