Skip to content

Commit

Permalink
Use ML-KEM instead of Kyber, implement message decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
larabr committed Feb 27, 2024
1 parent 4f7b9da commit a5e6462
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 54 deletions.
42 changes: 8 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"bn.js": "^4.11.8",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"crystals-kyber-js": "^1.0.0",
"crystals-kyber-js": "larabr/crystals-kyber-js#e87c7319cbc56246a67fe94ff63b11bb421854ff",
"eslint": "^8.34.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
Expand Down
7 changes: 4 additions & 3 deletions src/crypto/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export async function publicKeyEncrypt(keyAlgo, symmetricAlgo, publicParams, pri
case enums.publicKey.pqc_mlkem_x25519: {
const { eccPublicKey, mlkemPublicKey } = publicParams;
const { eccCipherText, mlkemCipherText, wrappedKey } = await publicKey.postQuantum.kem.encrypt(keyAlgo, eccPublicKey, mlkemPublicKey, data);
return { eccCipherText, mlkemCipherText, C: new ShortByteString(wrappedKey) };
const C = ECDHXSymmetricKey.fromObject({ algorithm: symmetricAlgo, wrappedKey });
return { eccCipherText, mlkemCipherText, C };
}
default:
return [];
Expand Down Expand Up @@ -168,7 +169,7 @@ export async function publicKeyDecrypt(keyAlgo, publicKeyParams, privateKeyParam
const { eccSecretKey, mlkemSecretKey } = privateKeyParams;
const { eccPublicKey } = publicKeyParams;
const { eccCipherText, mlkemCipherText, C } = sessionKeyParams;
return publicKey.postQuantum.kem.decrypt(keyAlgo, eccCipherText, mlkemCipherText, eccSecretKey, eccPublicKey, mlkemSecretKey, C.data);
return publicKey.postQuantum.kem.decrypt(keyAlgo, eccCipherText, mlkemCipherText, eccSecretKey, eccPublicKey, mlkemSecretKey, C.wrappedKey);
}
default:
throw new Error('Unknown public key encryption algorithm.');
Expand Down Expand Up @@ -392,7 +393,7 @@ export function parseEncSessionKeyParams(algo, bytes) {
case enums.publicKey.pqc_mlkem_x25519: {
const eccCipherText = util.readExactSubarray(bytes, read, read + getCurvePayloadSize(enums.publicKey.x25519)); read += eccCipherText.length;
const mlkemCipherText = util.readExactSubarray(bytes, read, read + 1088); read += mlkemCipherText.length;
const C = new ShortByteString(); read += C.read(bytes.subarray(read));
const C = new ECDHXSymmetricKey(); C.read(bytes.subarray(read));
return { eccCipherText, mlkemCipherText, C }; // eccCipherText || mlkemCipherText || len(C) || C
}
default:
Expand Down
5 changes: 4 additions & 1 deletion src/crypto/public_key/post_quantum/kem/kem.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ async function multiKeyCombine(eccKeyShare, eccCipherText, mlkemKeyShare, mlkemC
// "OpenPGPCompositeKeyDerivationFunction"
// counter - the fixed 4 byte value 0x00000001
// customizationString - the UTF-8 encoding of the string "KDF"
if (outputBits !== 256) {
throw new Error('Unsupported output size');
}
const { kmac256 } = await import('@openpgp/noble-hashes/sha3-addons');
// const { eccKeyShare, eccCiphertext } = await publicKey.pqc.kem.ecdhX(keyAlgo, publicParams.A);
// const { keyShare: mlkemKeyShare, cipherText: mlkemCipherText } = await publicKey.pqc.kem.ml(keyAlgo, publicParams.publicKey);
const eccData = util.concatUint8Array([eccKeyShare, eccCipherText]); // eccKeyShare || eccCipherText
const mlkemData = util.concatUint8Array([mlkemKeyShare, mlkemCipherText]); //mlkemKeyShare || mlkemCipherText
// const fixedInfo = new Uint8Array([keyAlgo]);
const encData = util.concatUint8Array([
new Uint8Array([1, 0, 0, 0]),
new Uint8Array([0, 0, 0, 1]),
eccData,
mlkemData,
fixedInfo
Expand Down
12 changes: 6 additions & 6 deletions src/crypto/public_key/post_quantum/kem/ml_kem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import enums from '../../../../enums';
export async function generate(algo) {
switch (algo) {
case enums.publicKey.pqc_mlkem_x25519: {
const { Kyber768 } = await import('crystals-kyber-js');
const kyberInstance = new Kyber768();
const { MlKem768 } = await import('crystals-kyber-js');
const kyberInstance = new MlKem768();
const [encapsulationKey, decapsulationKey] = await kyberInstance.generateKeyPair();

return { mlkemPublicKey: encapsulationKey, mlkemSecretKey: decapsulationKey };
Expand All @@ -17,8 +17,8 @@ export async function generate(algo) {
export async function encaps(algo, mlkemRecipientPublicKey) {
switch (algo) {
case enums.publicKey.pqc_mlkem_x25519: {
const { Kyber768 } = await import('crystals-kyber-js');
const kyberInstance = new Kyber768();
const { MlKem768 } = await import('crystals-kyber-js');
const kyberInstance = new MlKem768();
const [mlkemCipherText, mlkemKeyShare] = await kyberInstance.encap(mlkemRecipientPublicKey);

return { mlkemCipherText, mlkemKeyShare };
Expand All @@ -31,8 +31,8 @@ export async function encaps(algo, mlkemRecipientPublicKey) {
export async function decaps(algo, mlkemCipherText, mlkemSecretKey) {
switch (algo) {
case enums.publicKey.pqc_mlkem_x25519: {
const { Kyber768 } = await import('crystals-kyber-js');
const kyberInstance = new Kyber768();
const { MlKem768 } = await import('crystals-kyber-js');
const kyberInstance = new MlKem768();
const mlkemKeyShare = await kyberInstance.decap(mlkemCipherText, mlkemSecretKey);

return mlkemKeyShare;
Expand Down
2 changes: 1 addition & 1 deletion src/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default {
/** Ed448 (Sign only) */
ed448: 28,
/** Post-quantum ML-KEM-768 + X25519 (Encrypt only) */
pqc_mlkem_x25519: 29,
pqc_mlkem_x25519: 105,
/** Post-quantum ML-DSA-64 + Ed25519 (Sign only) */
pqc_mldsa_ed25519: 35,

Expand Down
3 changes: 2 additions & 1 deletion src/key/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ export function validateDecryptionKeyPacket(keyPacket, signature, config) {
case enums.publicKey.elgamal:
case enums.publicKey.ecdh:
case enums.publicKey.x25519:
case enums.publicKey.x448: {
case enums.publicKey.x448:
case enums.publicKey.pqc_mlkem_x25519: {
const isValidSigningKeyPacket = !signature.keyFlags || (signature.keyFlags[0] & enums.keyFlags.signData) !== 0;
if (isValidSigningKeyPacket && config.allowInsecureDecryptionWithSigningKeys) {
// This is only relevant for RSA keys, all other signing algorithms cannot decrypt
Expand Down
21 changes: 15 additions & 6 deletions src/packet/public_key_encrypted_session_key.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ class PublicKeyEncryptedSessionKeyPacket {
}
this.publicKeyAlgorithm = bytes[offset++];
this.encrypted = crypto.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(offset));
if (this.version === 3 && (
this.publicKeyAlgorithm === enums.publicKey.x25519 || this.publicKeyAlgorithm === enums.publicKey.x448)) {
if (hasCleartextCipherAlgo(this.version, this.publicKeyAlgorithm)) {
this.sessionKeyAlgorithm = enums.write(enums.symmetric, this.encrypted.C.algorithm);
}
}
Expand Down Expand Up @@ -201,10 +200,7 @@ class PublicKeyEncryptedSessionKeyPacket {

const { sessionKey, sessionKeyAlgorithm } = decodeSessionKey(this.version, this.publicKeyAlgorithm, decryptedData, randomSessionKey);

// v3 Montgomery curves have cleartext cipher algo
if (this.version === 3 && (
this.publicKeyAlgorithm !== enums.publicKey.x25519 && this.publicKeyAlgorithm !== enums.publicKey.x448)
) {
if (this.version === 3 && !hasCleartextCipherAlgo(this.version, this.publicKeyAlgorithm)) {
this.sessionKeyAlgorithm = sessionKeyAlgorithm;
}
this.sessionKey = sessionKey;
Expand All @@ -229,6 +225,7 @@ function encodeSessionKey(version, keyAlgo, cipherAlgo, sessionKeyData) {
]);
case enums.publicKey.x25519:
case enums.publicKey.x448:
case enums.publicKey.pqc_mlkem_x25519:
return sessionKeyData;
default:
throw new Error('Unsupported public key algorithm');
Expand Down Expand Up @@ -277,10 +274,22 @@ function decodeSessionKey(version, keyAlgo, decryptedData, randomSessionKey) {
}
case enums.publicKey.x25519:
case enums.publicKey.x448:
case enums.publicKey.pqc_mlkem_x25519:
return {
sessionKey: decryptedData
};
default:
throw new Error('Unsupported public key algorithm');
}
}

function hasCleartextCipherAlgo(version, publicKeyAlgo) {
switch (publicKeyAlgo) {
case enums.publicKey.x25519:
case enums.publicKey.x448:
case enums.publicKey.pqc_mlkem_x25519:
return version === 3;
default:
return false;
}
}
119 changes: 118 additions & 1 deletion test/crypto/postQuantum.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,124 @@ export default () => describe('PQC', function () {
expect(decryptedSessionKey).to.deep.equal(sessionKey.data);
});

it('ML-DSA + Ed25519 - Generate/sign/verify', async function () {
it('ML-KEM + X25519 - Test vector', async function () {
const armoredMessage = `-----BEGIN PGP MESSAGE-----
wcPUA/qyFfu1TBzoaRaET03uDIyjNeUBk84Hj31jS8SkuW7T/fY78wQZOA89
MWj0RSoythNA9LJY7749Zlunxl896ws3tIfvy7FzMZ0/6kPEYvADZby9kwpv
X6Ia3DNAKlhiJfXM7oWXaPUQ/rZWnLm+eEnhmkXqE82Vz3nfml7h3k5LQJo6
f43LX2+euqHDMhdxpffMD1INkABN1Ttzth/ezQ2/5Uob/YvxT4lROGmBTl9g
ua9xFN2Wo4cMxe5XxLYy8QUp+kH5Q+EdPmW9HYFu3YA1xFEALstmx9xM2oRg
KA84QZUVxcBmQekHbFiXkYpGVaZwqa/3oDqTW2tQvqDucShWkwXBryDYrPqm
cSOCdbOlyWxWHRTamgvBy0351dnEVTT+pm9DYDkpmdb0ToBpPebC8sy/WHWV
mRLLkvUPe+IGkgL/1ehNMPVvEACRScV5GviYvs26NruofJMQXZ3BbxARcZ++
vOTVXl+kC7x+LbQOS4gAyN3RdfBSxrKPH2LBYI7Ccd1pUl/u0AnS6fksDT6n
ofECxwvkLks/CEmGyWaxNCfAVVAPz8S4g3f8jxhK4jtRWhD0PpY3MLCH3bug
JlYTzQm2J59NT9Knm+9PXSKny/5GV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pCXk
V4QynkbLqeyTbolrfQhREPoCC0YLTYBcoxg0FNqKqi7IBpgnPpbmfWcGn9wIwAJVvKo1GDoYV9KA
DynXm/jmCOAaK4ExiPOzUV3ylNrRCFiYZ/PkrzpSDEC1RiUcXrSCEGiijjAZSs1RW7u76w5jrVih
Q6x9kNYynTTP26h//8XEBwGW3QWoaLcXUJNpP2JmC6cwd4ls1tP3ekewIkWaP94i9FVzNo2y8zIo
nZprJ43z0ED7FVkv16sS6iUPH356gFR4SBpjrGJswn4EGBYIACYWIQQVaO2LA7vDcV4dXKo2as2L
T7U/5QUCZdXkZAUJA8JnAAIbDAAKCRA2as2LT7U/5R8EAP9rVvp9knEAoaaIoslkfkVy18RNymWe
gxa3/Jm0tqLUHAEAyyV5473sqcilThIyTdMYnpu1TCFoX+IBvj3U4JML+As=
=jowz
-----END PGP PRIVATE KEY BLOCK-----` });

const { data: decryptedData } = await openpgp.decrypt({
message: await openpgp.readMessage({ armoredMessage }),
decryptionKeys: privateKey
});
expect(decryptedData).to.equal('hello world\n');
});
const digest = new Uint8Array(32).fill(1);
const hashAlgo = openpgp.enums.hash.sha256;

Expand Down

0 comments on commit a5e6462

Please sign in to comment.