Skip to content

Commit

Permalink
adjusted comments
Browse files Browse the repository at this point in the history
  • Loading branch information
keldonin committed Jun 30, 2021
1 parent 920e699 commit 6f16c61
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/pkcs11_cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,9 @@ func_rc pkcs11_cat_object_with_handle(pkcs11Context *p11Context, CK_OBJECT_HANDL
/* extract param into OID */
/* for Edwards curve, it may come it two flavours:
* - as an OID, in which case it will be parsed by d2i_ASN1_OBJECT
* - as a named curve, of the form 0x13 0x0c 'e' 'd' 'w' 'a' 'r' 'd' 's' '2' ...
* the later case cannot be parsed as a DER encoded object
* this is why perform first a comparison with the curve names.
* - as a PrintableString 'edwards25519' or 'edwards448'
* the later case cannot be converted directly to an OID
* and is therefore detected upfront.
*/
pp = oecparams->pValue;
if(pkcs11_is_ed_param_named_25519(pp, oecparams->ulValueLen)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/pkcs11_cert_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,9 @@ EVP_PKEY *pkcs11_SPKI_from_ED(pkcs11AttrList *attrlist )
/* extract param into OID */
/* for Edwards curve, it may come it two flavours:
* - as an OID, in which case it will be parsed by d2i_ASN1_OBJECT
* - as a named curve, of the form 0x13 0x0c 'e' 'd' 'w' 'a' 'r' 'd' 's' '2' ...
* the later case cannot be parsed as a DER encoded object
* this is why perform first a comparison with the curve names.
* - as a PrintableString 'edwards25519' or 'edwards448'
* the later case cannot be converted directly to an OID
* and is therefore detected upfront.
*/
pp = oecparams->pValue;
if(pkcs11_is_ed_param_named_25519(pp, oecparams->ulValueLen)) {
Expand Down
9 changes: 7 additions & 2 deletions lib/pkcs11_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
static const uint8_t id_edwards25519[] = { 0x13, 0x0C, 'e', 'd', 'w', 'a', 'r', 'd', 's', '2', '5', '5', '1', '9' };
static const uint8_t id_edwards448[] = { 0x13, 0x0A, 'e', 'd', 'w', 'a', 'r', 'd', 's', '4', '4', '8' };

/* The following functions tell whether EC_PARAM is of the form of named curve, for Edwards curves */
/* Edwards curves may be specified it two flavours:
* - as an OID, in which case it will be parsed by d2i_ASN1_OBJECT
* - as a PrintableString 'edwards25519' or 'edwards448'
* the later case cannot be converted directly to an OID
* The two following functions implement that detection.
*/

inline bool pkcs11_is_ed_param_named_25519(const uint8_t *ecparam, size_t ecparamlen)
{
return ecparamlen==sizeof id_edwards25519 && memcmp(ecparam, id_edwards25519, sizeof id_edwards25519)==0;
Expand All @@ -44,7 +50,6 @@ inline bool pkcs11_is_ed_param_named_448(const uint8_t *ecparam, size_t ecparaml
}



bool pkcs11_ex_curvename2oid(char *name, CK_BYTE **where, CK_ULONG *len, key_type_t keytype)
{
bool rc = false;
Expand Down
6 changes: 3 additions & 3 deletions lib/pkcs11_more.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ func_rc pkcs11_more_object_with_label(pkcs11Context *p11Context, char *label)
/* extract param into OID */
/* for Edwards curve, it may come it two flavours:
* - as an OID, in which case it will be parsed by d2i_ASN1_OBJECT
* - as a named curve, of the form 0x13 0x0c 'e' 'd' 'w' 'a' 'r' 'd' 's' '2' ...
* the later case cannot be parsed as a DER encoded object
* this is why perform first a comparison with the curve names.
* - as a PrintableString 'edwards25519' or 'edwards448'
* the later case cannot be converted directly to an OID
* and is therefore detected upfront.
*/
pp = oecparams->pValue;
if(pkcs11_is_ed_param_named_25519(pp, oecparams->ulValueLen)) {
Expand Down

0 comments on commit 6f16c61

Please sign in to comment.