mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-24 03:28:13 +09:00
145389768d
* pub-relay * relay actorをApplicationにする * Disable koa-compress * Homeはリレーに送らない * Disable debug * UI * cleanupなど
37 lines
780 B
TypeScript
37 lines
780 B
TypeScript
import * as crypto from 'crypto';
|
|
import * as util from 'util';
|
|
|
|
const generateKeyPair = util.promisify(crypto.generateKeyPair);
|
|
|
|
export async function genRsaKeyPair(modulusLength = 2048) {
|
|
return await generateKeyPair('rsa', {
|
|
modulusLength,
|
|
publicKeyEncoding: {
|
|
type: 'spki',
|
|
format: 'pem'
|
|
},
|
|
privateKeyEncoding: {
|
|
type: 'pkcs8',
|
|
format: 'pem',
|
|
cipher: undefined,
|
|
passphrase: undefined
|
|
}
|
|
});
|
|
}
|
|
|
|
export async function genEcKeyPair(namedCurve: 'prime256v1' | 'secp384r1' | 'secp521r1' | 'curve25519' = 'prime256v1') {
|
|
return await generateKeyPair('ec', {
|
|
namedCurve,
|
|
publicKeyEncoding: {
|
|
type: 'spki',
|
|
format: 'pem'
|
|
},
|
|
privateKeyEncoding: {
|
|
type: 'pkcs8',
|
|
format: 'pem',
|
|
cipher: undefined,
|
|
passphrase: undefined
|
|
}
|
|
});
|
|
}
|