-
Notifications
You must be signed in to change notification settings - Fork 213
Description
When using MessageImprint.create, the first argument is the hash algorithm, but there's no way to get it to use ECDSA-based hash algorithms.
This appears to be because the first thing create does is to call crypto.getOIDByAlgorithm, with the first passed argument being the constructed object { name: hashAlgorithm } — so, in the case of ECSDA, that argument is { name: "ECDSA" }.
The crypto.getOIDByAlgorithm function expects an Algorithm object as its first argument, and then the first thing it does is switches based on algorithm.name, which in this case in ECDSA. But the matching case then wants to further switch based on the value of algorithm.hash to get the key size:
case "ECDSA":
switch ((algorithm as any).hash.name.toUpperCase()) {
case "SHA-1":
result = "1.2.840.10045.4.1";
break;
case "SHA-256":
result = "1.2.840.10045.4.3.2";
break;
case "SHA-384":
result = "1.2.840.10045.4.3.3";
break;
case "SHA-512":
result = "1.2.840.10045.4.3.4";
break;
default:
}
And since MessageImprint.create is what created the object that was passed in, there's no way for a caller of MessageImprint.create to specify that algorithm.hash value.
Would there be a way to add an overloaded MessageImprint.create function that allowed the caller to specify the full object (containing both the algorithm string and hash string)?