From 80e9805d22319b0d41e7060ec9bf86dfa6bc948d Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 30 Dec 2017 15:14:23 +0000 Subject: [PATCH] AsymmetricCrypto: we actually using pkcs8 not 1. --- src/api/Crypto.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/Crypto.ts b/src/api/Crypto.ts index 75c8d2c..fe46e38 100644 --- a/src/api/Crypto.ts +++ b/src/api/Crypto.ts @@ -134,20 +134,20 @@ export class AsymmetricCryptoManager { static generateKeyPair() { const keyPair = new NodeRSA(); keyPair.generateKeyPair(3072, 65537); - const pubkey = keyPair.exportKey('pkcs1-public-der') as Buffer; - const privkey = keyPair.exportKey('pkcs1-private-der') as Buffer; + const pubkey = keyPair.exportKey('pkcs8-public-der') as Buffer; + const privkey = keyPair.exportKey('pkcs8-private-der') as Buffer; return new AsymmetricKeyPair( bufferToArray(pubkey), bufferToArray(privkey)); } constructor(keyPair: AsymmetricKeyPair) { this.keyPair = new NodeRSA(); - this.keyPair.importKey(Buffer.from(keyPair.privateKey), 'pkcs1-der'); + this.keyPair.importKey(Buffer.from(keyPair.privateKey), 'pkcs8-der'); } encryptBytes(publicKey: byte[], content: byte[]): byte[] { const key = new NodeRSA(); - key.importKey(Buffer.from(publicKey), 'pkcs1-public-der'); + key.importKey(Buffer.from(publicKey), 'pkcs8-public-der'); return bufferToArray(key.encrypt(Buffer.from(content), 'buffer')); }