mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-24 06:25:50 +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.aes256:
|
||||
return aes(getCipherKeySize(algo));
|
||||
case enums.symmetric.cast5:
|
||||
case enums.symmetric.blowfish:
|
||||
case enums.symmetric.twofish:
|
||||
case enums.symmetric.tripledes: {
|
||||
const { TripleDES } = await import('./des');
|
||||
return TripleDES;
|
||||
const { legacyCiphers } = await import('./legacy_ciphers');
|
||||
const cipher = legacyCiphers.get(algo);
|
||||
if (!cipher) {
|
||||
throw new Error('Unsupported cipher algorithm');
|
||||
}
|
||||
case enums.symmetric.cast5: {
|
||||
const { default: CAST5 } = await import('./cast5');
|
||||
return CAST5;
|
||||
}
|
||||
case enums.symmetric.twofish: {
|
||||
const { default: TwoFish } = await import('./twofish');
|
||||
return TwoFish;
|
||||
}
|
||||
case enums.symmetric.blowfish: {
|
||||
const { default: BlowFish } = await import('./blowfish');
|
||||
return BlowFish;
|
||||
return cipher;
|
||||
}
|
||||
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