During some operations with RSA-PSS algorithm I had this error:
Error: Parameter 'saltLength' should be a multiple of 8
So, the "saltLength" parameter is using only as a part of RSASSA-PSS-params which in turn came from RFC4055. In the RFC we have this definition of RSASSA-PSS-params:
As you can see the "saltLength" parameter has a default value equal to 20 and let me explain why. As you can see the "RSASSA-PSS-params" also has default value for "hashAlgorithm" parameter and the default value is SHA-1. And as a result of SHA-1 algorithm we have value with length equal to 20. That is why we have "saltLength" default value as 20.
Also let me quote some part of WebCrypto API specification for "exportKey" operation for RSA-PSS algorithm:
Set the saltLength field to the length in octets of the digest algorithm identified by the name attribute of the hash attribute of the [[algorithm]] internal slot of key
So, in fact the "saltLength" value must be equal in length to output of hashAlgorithm used inside "RSASSA-PSS-params".
Please remove the check "if (alg.saltLength % 8) ..." because it is completely incorrect.
During some operations with RSA-PSS algorithm I had this error:
So, the "saltLength" parameter is using only as a part of RSASSA-PSS-params which in turn came from RFC4055. In the RFC we have this definition of RSASSA-PSS-params:
As you can see the "saltLength" parameter has a default value equal to 20 and let me explain why. As you can see the "RSASSA-PSS-params" also has default value for "hashAlgorithm" parameter and the default value is SHA-1. And as a result of SHA-1 algorithm we have value with length equal to 20. That is why we have "saltLength" default value as 20.
Also let me quote some part of WebCrypto API specification for "exportKey" operation for RSA-PSS algorithm:
So, in fact the "saltLength" value must be equal in length to output of hashAlgorithm used inside "RSASSA-PSS-params".
Please remove the check "if (alg.saltLength % 8) ..." because it is completely incorrect.