mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-24 14:35:51 +00:00
Bundle legacy ciphers in a single chunk
This commit is contained in:
parent
057f5fe33b
commit
55f3ea22f2
@ -7,24 +7,19 @@ export async function getCipher(algo) {
|
|||||||
case enums.symmetric.aes192:
|
case enums.symmetric.aes192:
|
||||||
case enums.symmetric.aes256:
|
case enums.symmetric.aes256:
|
||||||
return aes(getCipherKeySize(algo));
|
return aes(getCipherKeySize(algo));
|
||||||
|
case enums.symmetric.cast5:
|
||||||
|
case enums.symmetric.blowfish:
|
||||||
|
case enums.symmetric.twofish:
|
||||||
case enums.symmetric.tripledes: {
|
case enums.symmetric.tripledes: {
|
||||||
const { TripleDES } = await import('./des');
|
const { legacyCiphers } = await import('./legacy_ciphers');
|
||||||
return TripleDES;
|
const cipher = legacyCiphers.get(algo);
|
||||||
}
|
if (!cipher) {
|
||||||
case enums.symmetric.cast5: {
|
throw new Error('Unsupported cipher algorithm');
|
||||||
const { default: CAST5 } = await import('./cast5');
|
}
|
||||||
return CAST5;
|
return cipher;
|
||||||
}
|
|
||||||
case enums.symmetric.twofish: {
|
|
||||||
const { default: TwoFish } = await import('./twofish');
|
|
||||||
return TwoFish;
|
|
||||||
}
|
|
||||||
case enums.symmetric.blowfish: {
|
|
||||||
const { default: BlowFish } = await import('./blowfish');
|
|
||||||
return BlowFish;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new Error('Unsupported symmetric-key algorithm');
|
throw new Error('Unsupported cipher algorithm');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
src/crypto/cipher/legacy_ciphers.js
Normal file
17
src/crypto/cipher/legacy_ciphers.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* This file is needed to dynamic import the legacy ciphers.
|
||||||
|
* Separate dynamic imports are not convenient as they result in multiple chunks.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TripleDES } from './des';
|
||||||
|
import CAST5 from './cast5';
|
||||||
|
import TwoFish from './twofish';
|
||||||
|
import BlowFish from './blowfish';
|
||||||
|
import enums from '../../enums';
|
||||||
|
|
||||||
|
export const legacyCiphers = new Map([
|
||||||
|
[enums.symmetric.tripledes, TripleDES],
|
||||||
|
[enums.symmetric.cast5, CAST5],
|
||||||
|
[enums.symmetric.blowfish, BlowFish],
|
||||||
|
[enums.symmetric.twofish, TwoFish]
|
||||||
|
]);
|
||||||
Loading…
x
Reference in New Issue
Block a user