Socket
Socket
Sign inDemoInstall

@cloudflare/blindrsa-ts

Package Overview
Dependencies
1
Maintainers
31
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.1

9

lib/src/blindrsa.d.ts

@@ -15,6 +15,10 @@ export declare enum PrepareType {

}
export interface BlindRSAPlatformParams {
supportsRSARAW: boolean;
}
export declare class BlindRSA {
readonly params: BlindRSAParams;
readonly params: BlindRSAParams & BlindRSAPlatformParams;
private static readonly NAME;
constructor(params: BlindRSAParams);
private static readonly NATIVE_SUPPORT_NAME;
constructor(params: BlindRSAParams & BlindRSAPlatformParams);
toString(): string;

@@ -25,2 +29,3 @@ prepare(msg: Uint8Array): Uint8Array;

blindSign(privateKey: CryptoKey, blindMsg: Uint8Array): Promise<Uint8Array>;
private rsaRawBlingSign;
finalize(publicKey: CryptoKey, msg: Uint8Array, blindSig: Uint8Array, inv: Uint8Array): Promise<Uint8Array>;

@@ -27,0 +32,0 @@ static generateKey(algorithm: Pick<RsaHashedKeyGenParams, 'modulusLength' | 'publicExponent' | 'hash'>): Promise<CryptoKeyPair>;

@@ -94,2 +94,5 @@ // Copyright (c) 2023 Cloudflare, Inc.

async blindSign(privateKey, blindMsg) {
if (this.params.supportsRSARAW) {
return this.rsaRawBlingSign(privateKey, blindMsg);
}
const { jwkKey, modulusLengthBytes: kLen } = await this.extractKeyParams(privateKey, 'private');

@@ -118,2 +121,13 @@ if (!jwkKey.n || !jwkKey.d) {

}
async rsaRawBlingSign(privateKey, blindMsg) {
const algorithmName = privateKey.algorithm.name;
privateKey.algorithm.name = BlindRSA.NATIVE_SUPPORT_NAME;
try {
const signature = await crypto.subtle.sign({ name: BlindRSA.NATIVE_SUPPORT_NAME }, privateKey, blindMsg);
return new Uint8Array(signature);
}
finally {
privateKey.algorithm.name = algorithmName;
}
}
async finalize(publicKey, msg, blindSig, inv) {

@@ -164,2 +178,3 @@ const { jwkKey, modulusLengthBytes: kLen } = await this.extractKeyParams(publicKey, 'public');

BlindRSA.NAME = 'RSA-PSS';
BlindRSA.NATIVE_SUPPORT_NAME = 'RSA-RAW';
//# sourceMappingURL=blindrsa.js.map

@@ -1,2 +0,2 @@

import { BlindRSA, type BlindRSAParams } from './blindrsa.js';
import { BlindRSA, type BlindRSAParams, type BlindRSAPlatformParams } from './blindrsa.js';
export { BlindRSA, type BlindRSAParams };

@@ -8,12 +8,12 @@ export declare const Params: Record<string, BlindRSAParams>;

readonly PSS: {
readonly Randomized: () => BlindRSA;
readonly Deterministic: () => BlindRSA;
readonly Randomized: (params?: BlindRSAPlatformParams) => BlindRSA;
readonly Deterministic: (params?: BlindRSAPlatformParams) => BlindRSA;
};
readonly PSSZero: {
readonly Randomized: () => BlindRSA;
readonly Deterministic: () => BlindRSA;
readonly Randomized: (params?: BlindRSAPlatformParams) => BlindRSA;
readonly Deterministic: (params?: BlindRSAPlatformParams) => BlindRSA;
};
};
};
export declare function getSuiteByName(name: string): BlindRSA;
export declare function getSuiteByName(name: string, params?: BlindRSAPlatformParams): BlindRSA;
//# sourceMappingURL=index.d.ts.map

@@ -14,3 +14,3 @@ // Copyright (c) 2023 Cloudflare, Inc.

// RFC9474: https://www.rfc-editor.org/info/rfc9474
import { BlindRSA, PrepareType } from './blindrsa.js';
import { BlindRSA, PrepareType, } from './blindrsa.js';
export { BlindRSA };

@@ -50,15 +50,15 @@ // Params allows to instantiate the RSABSSA protocol using BlindRSA class

PSS: {
Randomized: () => new BlindRSA(Params.RSABSSA_SHA384_PSS_Randomized),
Deterministic: () => new BlindRSA(Params.RSABSSA_SHA384_PSS_Deterministic),
Randomized: (params = { supportsRSARAW: false }) => new BlindRSA({ ...Params.RSABSSA_SHA384_PSS_Randomized, ...params }),
Deterministic: (params = { supportsRSARAW: false }) => new BlindRSA({ ...Params.RSABSSA_SHA384_PSS_Deterministic, ...params }),
},
PSSZero: {
Randomized: () => new BlindRSA(Params.RSABSSA_SHA384_PSSZERO_Randomized),
Deterministic: () => new BlindRSA(Params.RSABSSA_SHA384_PSSZERO_Deterministic),
Randomized: (params = { supportsRSARAW: false }) => new BlindRSA({ ...Params.RSABSSA_SHA384_PSSZERO_Randomized, ...params }),
Deterministic: (params = { supportsRSARAW: false }) => new BlindRSA({ ...Params.RSABSSA_SHA384_PSSZERO_Deterministic, ...params }),
},
},
};
export function getSuiteByName(name) {
export function getSuiteByName(name, params = { supportsRSARAW: false }) {
for (const suiteParams of Object.values(Params)) {
if (name.toLowerCase() === suiteParams.name.toLowerCase()) {
return new BlindRSA(suiteParams);
return new BlindRSA({ ...suiteParams, ...params });
}

@@ -65,0 +65,0 @@ }

{
"name": "@cloudflare/blindrsa-ts",
"version": "0.2.0",
"version": "0.3.1",
"description": "blindrsa-ts: A TypeScript Library for the RSA Blind Signature Protocol",

@@ -5,0 +5,0 @@ "author": "Armando Faz <armfazh@cloudflare.com>",

@@ -47,3 +47,8 @@ [![NPM](https://img.shields.io/npm/v/@cloudflare/blindrsa-ts?style=plastic)](https://www.npmjs.com/package/@cloudflare/blindrsa-ts) [![NPM](https://img.shields.io/npm/l/@cloudflare/blindrsa-ts?style=plastic)](LICENSE.txt)

#### Platform specific configuration
By default, this library uses the [WebCrypto API](https://w3c.github.io/webcrypto/). Certain platforms, such as [Cloudflare Workers](https://github.com/cloudflare/workerd/blob/6b63c701e263a311c2a3ce64e2aeada69afc32a1/src/workerd/api/crypto-impl-asymmetric.c%2B%2B#L827-L868), have implemented native operation. These can be enabled by passing `{ supportRSARAW: true }` when retrieving a suite.
At the time of writing, this dedicated optimisation is done only for the `BlindSign` operation. Key type does not have to be modified, and will be set to `RSA-RAW` by the library for the time of the operation.
#### Setup

@@ -50,0 +55,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc