Skip to content

Commit

Permalink
Minor changes [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
larabr committed Nov 17, 2021
1 parent 4b5aadb commit 9630a77
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
35 changes: 14 additions & 21 deletions src/crypto/hash/index.js
Expand Up @@ -111,26 +111,19 @@ export default {
*/
digest: function(algo, data) {
switch (algo) {
case 1:
// - MD5 [HAC]
case enums.hash.md5:
return this.md5(data);
case 2:
// - SHA-1 [FIPS180]
case enums.hash.sha1:
return this.sha1(data);
case 3:
// - RIPE-MD/160 [HAC]
case enums.hash.ripemd:
return this.ripemd(data);
case 8:
// - SHA256 [FIPS180]
case enums.hash.sha256:
return this.sha256(data);
case 9:
// - SHA384 [FIPS180]
case enums.hash.sha384:
return this.sha384(data);
case 10:
// - SHA512 [FIPS180]
case enums.hash.sha512:
return this.sha512(data);
case 11:
// - SHA224 [FIPS180]
case enums.hash.sha224:
return this.sha224(data);
default:
throw new Error('Invalid hash function.');
Expand All @@ -144,18 +137,18 @@ export default {
*/
getHashByteLength: function(algo) {
switch (algo) {
case enums.hash.md5: // - MD5 [HAC]
case enums.hash.md5:
return 16;
case enums.hash.sha1: // - SHA-1 [FIPS180]
case enums.hash.ripemd: // - RIPE-MD/160 [HAC]
case enums.hash.sha1:
case enums.hash.ripemd:
return 20;
case enums.hash.sha256: // - SHA256 [FIPS180]
case enums.hash.sha256:
return 32;
case enums.hash.sha384: // - SHA384 [FIPS180]
case enums.hash.sha384:
return 48;
case enums.hash.sha512: // - SHA512 [FIPS180]
case enums.hash.sha512:
return 64;
case enums.hash.sha224: // - SHA224 [FIPS180]
case enums.hash.sha224:
return 28;
default:
throw new Error('Invalid hash algorithm.');
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/mode/gcm.js
Expand Up @@ -44,7 +44,7 @@ async function GCM(cipher, key) {
if (cipher !== enums.symmetric.aes128 &&
cipher !== enums.symmetric.aes192 &&
cipher !== enums.symmetric.aes256) {
throw new Error('EAX mode supports only AES cipher');
throw new Error('GCM mode supports only AES cipher');
}

if (util.getWebCrypto() && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
Expand Down

0 comments on commit 9630a77

Please sign in to comment.