2222 */
2323
2424import nacl from '@openpgp/tweetnacl/nacl-fast-light' ;
25- import { Curve , jwkToRawPublic , rawPublicToJWK , privateToJWK , validateStandardParams } from './curves ' ;
25+ import { CurveWithOID , jwkToRawPublic , rawPublicToJWK , privateToJWK , validateStandardParams } from './oid_curves ' ;
2626import * as aesKW from '../../aes_kw' ;
2727import { getRandomBytes } from '../../random' ;
2828import hash from '../../hash' ;
@@ -86,7 +86,7 @@ async function kdf(hashAlgo, X, length, param, stripLeading = false, stripTraili
8686/**
8787 * Generate ECDHE ephemeral key and secret from public key
8888 *
89- * @param {Curve } curve - Elliptic curve object
89+ * @param {CurveWithOID } curve - Elliptic curve object
9090 * @param {Uint8Array } Q - Recipient public key
9191 * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}> }
9292 * @async
@@ -129,7 +129,7 @@ async function genPublicEphemeralKey(curve, Q) {
129129export async function encrypt ( oid , kdfParams , data , Q , fingerprint ) {
130130 const m = pkcs5 . encode ( data ) ;
131131
132- const curve = new Curve ( oid ) ;
132+ const curve = new CurveWithOID ( oid ) ;
133133 const { publicKey, sharedKey } = await genPublicEphemeralKey ( curve , Q ) ;
134134 const param = buildEcdhParam ( enums . publicKey . ecdh , oid , kdfParams , fingerprint ) ;
135135 const { keySize } = getCipher ( kdfParams . cipher ) ;
@@ -141,7 +141,7 @@ export async function encrypt(oid, kdfParams, data, Q, fingerprint) {
141141/**
142142 * Generate ECDHE secret from private key and public part of ephemeral key
143143 *
144- * @param {Curve } curve - Elliptic curve object
144+ * @param {CurveWithOID } curve - Elliptic curve object
145145 * @param {Uint8Array } V - Public part of ephemeral key
146146 * @param {Uint8Array } Q - Recipient public key
147147 * @param {Uint8Array } d - Recipient private key
@@ -189,7 +189,7 @@ async function genPrivateEphemeralKey(curve, V, Q, d) {
189189 * @async
190190 */
191191export async function decrypt ( oid , kdfParams , V , C , Q , d , fingerprint ) {
192- const curve = new Curve ( oid ) ;
192+ const curve = new CurveWithOID ( oid ) ;
193193 const { sharedKey } = await genPrivateEphemeralKey ( curve , V , Q , d ) ;
194194 const param = buildEcdhParam ( enums . publicKey . ecdh , oid , kdfParams , fingerprint ) ;
195195 const { keySize } = getCipher ( kdfParams . cipher ) ;
@@ -209,7 +209,7 @@ export async function decrypt(oid, kdfParams, V, C, Q, d, fingerprint) {
209209/**
210210 * Generate ECDHE secret from private key and public part of ephemeral key using webCrypto
211211 *
212- * @param {Curve } curve - Elliptic curve object
212+ * @param {CurveWithOID } curve - Elliptic curve object
213213 * @param {Uint8Array } V - Public part of ephemeral key
214214 * @param {Uint8Array } Q - Recipient public key
215215 * @param {Uint8Array } d - Recipient private key
@@ -262,7 +262,7 @@ async function webPrivateEphemeralKey(curve, V, Q, d) {
262262/**
263263 * Generate ECDHE ephemeral key and secret from public key using webCrypto
264264 *
265- * @param {Curve } curve - Elliptic curve object
265+ * @param {CurveWithOID } curve - Elliptic curve object
266266 * @param {Uint8Array } Q - Recipient public key
267267 * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}> }
268268 * @async
@@ -310,7 +310,7 @@ async function webPublicEphemeralKey(curve, Q) {
310310/**
311311 * Generate ECDHE secret from private key and public part of ephemeral key using indutny/elliptic
312312 *
313- * @param {Curve } curve - Elliptic curve object
313+ * @param {CurveWithOID } curve - Elliptic curve object
314314 * @param {Uint8Array } V - Public part of ephemeral key
315315 * @param {Uint8Array } d - Recipient private key
316316 * @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}> }
@@ -330,7 +330,7 @@ async function ellipticPrivateEphemeralKey(curve, V, d) {
330330/**
331331 * Generate ECDHE ephemeral key and secret from public key using indutny/elliptic
332332 *
333- * @param {Curve } curve - Elliptic curve object
333+ * @param {CurveWithOID } curve - Elliptic curve object
334334 * @param {Uint8Array } Q - Recipient public key
335335 * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}> }
336336 * @async
@@ -350,7 +350,7 @@ async function ellipticPublicEphemeralKey(curve, Q) {
350350/**
351351 * Generate ECDHE secret from private key and public part of ephemeral key using nodeCrypto
352352 *
353- * @param {Curve } curve - Elliptic curve object
353+ * @param {CurveWithOID } curve - Elliptic curve object
354354 * @param {Uint8Array } V - Public part of ephemeral key
355355 * @param {Uint8Array } d - Recipient private key
356356 * @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}> }
@@ -367,7 +367,7 @@ async function nodePrivateEphemeralKey(curve, V, d) {
367367/**
368368 * Generate ECDHE ephemeral key and secret from public key using nodeCrypto
369369 *
370- * @param {Curve } curve - Elliptic curve object
370+ * @param {CurveWithOID } curve - Elliptic curve object
371371 * @param {Uint8Array } Q - Recipient public key
372372 * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}> }
373373 * @async
0 commit comments