Skip to content

Commit 1a6c964

Browse files
OTR: Uses jwk instead of spki for exchanging public keys.
1 parent 719ea7c commit 1a6c964

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/rocketchat-otr/client/rocketchat.otr.room.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ RocketChat.OTR.Room = class {
1717
this.establishing.set(true);
1818
this.firstPeer = true;
1919
this.generateKeyPair().then(() => {
20-
RocketChat.Notifications.notifyUser(this.peerId, 'otr', 'handshake', { roomId: this.roomId, userId: this.userId, publicKey: EJSON.stringify(new Uint8Array(this.exportedPublicKey)), refresh: refresh });
20+
RocketChat.Notifications.notifyUser(this.peerId, 'otr', 'handshake', { roomId: this.roomId, userId: this.userId, publicKey: EJSON.stringify(this.exportedPublicKey), refresh: refresh });
2121
});
2222
}
2323

2424
acknowledge() {
25-
RocketChat.Notifications.notifyUser(this.peerId, 'otr', 'acknowledge', { roomId: this.roomId, userId: this.userId, publicKey: EJSON.stringify(new Uint8Array(this.exportedPublicKey)) });
25+
RocketChat.Notifications.notifyUser(this.peerId, 'otr', 'acknowledge', { roomId: this.roomId, userId: this.userId, publicKey: EJSON.stringify(this.exportedPublicKey) });
2626
}
2727

2828
deny() {
@@ -71,7 +71,7 @@ RocketChat.OTR.Room = class {
7171
namedCurve: 'P-256'
7272
}, false, ['deriveKey', 'deriveBits']).then((keyPair) => {
7373
this.keyPair = keyPair;
74-
return crypto.subtle.exportKey('spki', keyPair.publicKey);
74+
return crypto.subtle.exportKey('jwk', keyPair.publicKey);
7575
})
7676
.then((exportedPublicKey) => {
7777
this.exportedPublicKey = exportedPublicKey;
@@ -85,7 +85,7 @@ RocketChat.OTR.Room = class {
8585
}
8686

8787
importPublicKey(publicKey) {
88-
return window.crypto.subtle.importKey('spki', EJSON.parse(publicKey), {
88+
return window.crypto.subtle.importKey('jwk', EJSON.parse(publicKey), {
8989
name: 'ECDH',
9090
namedCurve: 'P-256'
9191
}, false, []).then((peerPublicKey) => {

0 commit comments

Comments
 (0)