From eb8bef486d82618c3a6b2ee6d7094eea685fb1f1 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 27 Feb 2024 03:06:19 +0000 Subject: [PATCH] ED25519_SIGNED_ALGORITHM --- packages/backend/src/core/UserKeypairService.ts | 6 +++--- packages/backend/src/misc/gen-key-pair.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/UserKeypairService.ts b/packages/backend/src/core/UserKeypairService.ts index 7946f410cf..78a18b438d 100644 --- a/packages/backend/src/core/UserKeypairService.ts +++ b/packages/backend/src/core/UserKeypairService.ts @@ -12,7 +12,7 @@ import { RedisKVCache } from '@/misc/cache.js'; import type { MiUserKeypair } from '@/models/UserKeypair.js'; import { DI } from '@/di-symbols.js'; import { bindThis } from '@/decorators.js'; -import { ED25519_SIGN_ALGORITHM, genEd25519KeyPair } from '@/misc/gen-key-pair.js'; +import { ED25519_SIGNED_ALGORITHM, genEd25519KeyPair } from '@/misc/gen-key-pair.js'; import { GlobalEventService, GlobalEvents } from '@/core/GlobalEventService.js'; @Injectable() @@ -56,12 +56,12 @@ export class UserKeypairService implements OnApplicationShutdown { const keypair = await this.cache.fetch(userId); if (keypair.ed25519PublicKey != null) return; const ed25519 = await genEd25519KeyPair(); - const ed25519PublicKeySignature = sign(ED25519_SIGN_ALGORITHM, Buffer.from(ed25519.publicKey), keypair.privateKey).toString('base64'); + const ed25519PublicKeySignature = sign(ED25519_SIGNED_ALGORITHM, Buffer.from(ed25519.publicKey), keypair.privateKey).toString('base64'); await this.userKeypairsRepository.update({ userId }, { ed25519PublicKey: ed25519.publicKey, ed25519PrivateKey: ed25519.privateKey, ed25519PublicKeySignature, - ed25519SignatureAlgorithm: `rsa-${ED25519_SIGN_ALGORITHM}`, + ed25519SignatureAlgorithm: `rsa-${ED25519_SIGNED_ALGORITHM}`, }); this.globalEventService.publishInternalEvent('userKeypairUpdated', { userId }); } diff --git a/packages/backend/src/misc/gen-key-pair.ts b/packages/backend/src/misc/gen-key-pair.ts index 7b2e84d991..51ea093b29 100644 --- a/packages/backend/src/misc/gen-key-pair.ts +++ b/packages/backend/src/misc/gen-key-pair.ts @@ -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}`, }; }