mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-03-30 15:08:32 +00:00
Drop config.minBytesForWebCrypto
WebCrypto performance is now on-par or better than non-native libs even for small messages
This commit is contained in:
parent
b3ef95e60e
commit
7c9549ce88
1
openpgp.d.ts
vendored
1
openpgp.d.ts
vendored
@ -335,7 +335,6 @@ interface Config {
|
||||
s2kType: enums.s2k.iterated | enums.s2k.argon2;
|
||||
s2kIterationCountByte: number;
|
||||
s2kArgon2Params: { passes: number, parallelism: number; memoryExponent: number; };
|
||||
minBytesForWebCrypto: number;
|
||||
maxUserIDLength: number;
|
||||
knownNotations: string[];
|
||||
useIndutnyElliptic: boolean;
|
||||
|
@ -190,12 +190,6 @@ export default {
|
||||
* @property {Set<Integer>} constantTimePKCS1DecryptionSupportedSymmetricAlgorithms {@link module:enums.symmetric}
|
||||
*/
|
||||
constantTimePKCS1DecryptionSupportedSymmetricAlgorithms: new Set([enums.symmetric.aes128, enums.symmetric.aes192, enums.symmetric.aes256]),
|
||||
|
||||
/**
|
||||
* @memberof module:config
|
||||
* @property {Integer} minBytesForWebCrypto The minimum amount of bytes for which to use native WebCrypto APIs when available
|
||||
*/
|
||||
minBytesForWebCrypto: 1000,
|
||||
/**
|
||||
* @memberof module:config
|
||||
* @property {Boolean} ignoreUnsupportedPackets Ignore unsupported/unrecognizable packets on parsing instead of throwing an error
|
||||
|
@ -14,7 +14,6 @@ import { ripemd160 } from 'hash.js/lib/hash/ripemd';
|
||||
import * as stream from '@openpgp/web-stream-tools';
|
||||
import md5 from './md5';
|
||||
import util from '../../util';
|
||||
import defaultConfig from '../../config';
|
||||
import enums from '../../enums';
|
||||
|
||||
const webCrypto = util.getWebCrypto();
|
||||
@ -34,11 +33,11 @@ function nodeHash(type) {
|
||||
}
|
||||
|
||||
function hashjsHash(hash, webCryptoHash) {
|
||||
return async function(data, config = defaultConfig) {
|
||||
return async function(data) {
|
||||
if (stream.isArrayStream(data)) {
|
||||
data = await stream.readToEnd(data);
|
||||
}
|
||||
if (!util.isStream(data) && webCrypto && webCryptoHash && data.length >= config.minBytesForWebCrypto) {
|
||||
if (!util.isStream(data) && webCrypto && webCryptoHash) {
|
||||
return new Uint8Array(await webCrypto.digest(webCryptoHash, data));
|
||||
}
|
||||
const hashInstance = hash();
|
||||
@ -49,7 +48,7 @@ function hashjsHash(hash, webCryptoHash) {
|
||||
}
|
||||
|
||||
function nobleHash(hash, webCryptoHash) {
|
||||
return async function(data, config = defaultConfig) {
|
||||
return async function(data) {
|
||||
if (stream.isArrayStream(data)) {
|
||||
data = await stream.readToEnd(data);
|
||||
}
|
||||
@ -58,7 +57,7 @@ function nobleHash(hash, webCryptoHash) {
|
||||
return stream.transform(data, value => {
|
||||
hashInstance.update(value);
|
||||
}, () => hashInstance.digest());
|
||||
} else if (webCrypto && webCryptoHash && data.length >= config.minBytesForWebCrypto) {
|
||||
} else if (webCrypto && webCryptoHash) {
|
||||
return new Uint8Array(await webCrypto.digest(webCryptoHash, data));
|
||||
} else {
|
||||
return hash(data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user