mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-18 06:08:58 +00:00
Don't mutate prototypes of Uint8Array, ReadableStream and ReadableStreamDefaultWriter
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
* @requires asmcrypto.js
|
||||
* @requires hash.js
|
||||
* @requires crypto/hash/md5
|
||||
* @requires stream
|
||||
* @requires util
|
||||
* @module crypto/hash
|
||||
*/
|
||||
@@ -19,6 +20,7 @@ import sha384 from 'hash.js/lib/hash/sha/384';
|
||||
import sha512 from 'hash.js/lib/hash/sha/512';
|
||||
import { ripemd160 } from 'hash.js/lib/hash/ripemd';
|
||||
import md5 from './md5';
|
||||
import stream from '../../stream';
|
||||
import util from '../../util';
|
||||
|
||||
const rusha = new Rusha();
|
||||
@@ -36,7 +38,7 @@ function node_hash(type) {
|
||||
function hashjs_hash(hash) {
|
||||
return function(data) {
|
||||
const hashInstance = hash();
|
||||
return data.transform((done, value) => {
|
||||
return stream.transform(data, (done, value) => {
|
||||
if (!done) {
|
||||
hashInstance.update(value);
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* @requires crypto/public_key
|
||||
* @requires crypto/pkcs1
|
||||
* @requires enums
|
||||
* @requires stream
|
||||
* @requires util
|
||||
* @module crypto/signature
|
||||
*/
|
||||
@@ -12,6 +13,7 @@ import BN from 'bn.js';
|
||||
import publicKey from './public_key';
|
||||
import pkcs1 from './pkcs1';
|
||||
import enums from '../enums';
|
||||
import stream from '../stream';
|
||||
import util from '../util';
|
||||
|
||||
export default {
|
||||
@@ -29,7 +31,7 @@ export default {
|
||||
* @async
|
||||
*/
|
||||
verify: async function(algo, hash_algo, msg_MPIs, pub_MPIs, data) {
|
||||
data = await data.readToEnd();
|
||||
data = await stream.readToEnd(data);
|
||||
switch (algo) {
|
||||
case enums.publicKey.rsa_encrypt_sign:
|
||||
case enums.publicKey.rsa_encrypt:
|
||||
@@ -83,7 +85,7 @@ export default {
|
||||
* @async
|
||||
*/
|
||||
sign: async function(algo, hash_algo, key_params, data) {
|
||||
data = await data.readToEnd();
|
||||
data = await stream.readToEnd(data);
|
||||
switch (algo) {
|
||||
case enums.publicKey.rsa_encrypt_sign:
|
||||
case enums.publicKey.rsa_encrypt:
|
||||
|
||||
Reference in New Issue
Block a user