fix: imports and SecureByteContext in node
This commit is contained in:
parent
76b2a284d5
commit
6e02559f4e
2 changed files with 8 additions and 6 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -7,4 +7,6 @@ coverage/
|
|||
.nyc_output/
|
||||
build/
|
||||
*.node
|
||||
settings.json
|
||||
settings.json
|
||||
*.pem
|
||||
client_keys/
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* Matches the Python implementation using RSA-OAEP with SHA-256
|
||||
*/
|
||||
|
||||
import { getCrypto, pemToArrayBuffer, arrayBufferToPem, stringToArrayBuffer, arrayBufferToString } from './utils';
|
||||
import { getCrypto, pemToArrayBuffer, arrayBufferToPem, stringToArrayBuffer, arrayBufferToString, generateRandomBytes } from './utils';
|
||||
import { SecureByteContext } from '../memory/secure';
|
||||
|
||||
export class RSAOperations {
|
||||
|
|
@ -162,8 +162,8 @@ export class RSAOperations {
|
|||
);
|
||||
|
||||
// Wrap salt so it is zeroed after use
|
||||
const saltBytes = crypto.getRandomValues(new Uint8Array(16));
|
||||
const saltContext = new SecureByteContext(saltBytes.buffer, true);
|
||||
const saltBytes = generateRandomBytes(16);
|
||||
const saltContext = new SecureByteContext(saltBytes.buffer as ArrayBuffer, true);
|
||||
return saltContext.use(async (saltBuf) => {
|
||||
const saltView = new Uint8Array(saltBuf);
|
||||
const derivedKey = await this.subtle.deriveKey(
|
||||
|
|
@ -175,8 +175,8 @@ export class RSAOperations {
|
|||
);
|
||||
|
||||
// Wrap IV so it is zeroed after use
|
||||
const ivBytes = crypto.getRandomValues(new Uint8Array(16));
|
||||
const ivContext = new SecureByteContext(ivBytes.buffer, true);
|
||||
const ivBytes = generateRandomBytes(16);
|
||||
const ivContext = new SecureByteContext(ivBytes.buffer as ArrayBuffer, true);
|
||||
return ivContext.use(async (ivBuf) => {
|
||||
const ivView = new Uint8Array(ivBuf);
|
||||
const encrypted = await this.subtle.encrypt(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue