ED25519_SIGNED_ALGORITHM

This commit is contained in:
tamaina 2024-02-27 03:06:19 +00:00
parent 5876a28f1e
commit eb8bef486d
2 changed files with 6 additions and 6 deletions

View file

@ -8,7 +8,7 @@ import * as util from 'node:util';
const generateKeyPair = util.promisify(crypto.generateKeyPair);
export const ED25519_SIGN_ALGORITHM = 'sha256';
export const ED25519_SIGNED_ALGORITHM = 'sha256';
export async function genRsaKeyPair(modulusLength = 4096) {
return await generateKeyPair('rsa', {
@ -44,13 +44,13 @@ export async function genEd25519KeyPair() {
export async function genRSAAndEd25519KeyPair(rsaModulusLength = 4096) {
const rsa = await genRsaKeyPair(rsaModulusLength);
const ed25519 = await genEd25519KeyPair();
const ed25519PublicKeySignature = crypto.sign(ED25519_SIGN_ALGORITHM, Buffer.from(ed25519.publicKey), rsa.privateKey).toString('base64');
const ed25519PublicKeySignature = crypto.sign(ED25519_SIGNED_ALGORITHM, Buffer.from(ed25519.publicKey), rsa.privateKey).toString('base64');
return {
publicKey: rsa.publicKey,
privateKey: rsa.privateKey,
ed25519PublicKey: ed25519.publicKey,
ed25519PrivateKey: ed25519.privateKey,
ed25519PublicKeySignature,
ed25519SignatureAlgorithm: `rsa-${ED25519_SIGN_ALGORITHM}`,
ed25519SignatureAlgorithm: `rsa-${ED25519_SIGNED_ALGORITHM}`,
};
}