From b400e8c670bb6a30777ecb1ee0d5effc7c8392c4 Mon Sep 17 00:00:00 2001 From: vgoma Date: Thu, 27 Aug 2020 21:40:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=81=D1=82=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D1=8E=20=D1=85?= =?UTF-8?q?=D1=8D=D1=88=D0=B0=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B0=D0=BB=D0=B3=D0=BE=D1=80=D0=B8=D1=82?= =?UTF-8?q?=D0=BC=D0=B0=20=D0=93=D0=9E=D0=A1=D0=A2=20=D0=A0=2034.11-2012?= =?UTF-8?q?=20256=20=D0=B1=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/createHash.ts | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/api/createHash.ts b/src/api/createHash.ts index edc9f95..87d0d60 100644 --- a/src/api/createHash.ts +++ b/src/api/createHash.ts @@ -2,31 +2,16 @@ import { _afterPluginsLoaded } from '../helpers/_afterPluginsLoaded'; import { _extractMeaningfulErrorMessage } from '../helpers/_extractMeaningfulErrorMessage'; import { __cadesAsyncToken__, __createCadesPluginObject__, _generateCadesFn } from '../helpers/_generateCadesFn'; -type Algorithm = - | 'GOST_3411' - | 'GOST_3411_2012_256' - | 'GOST_3411_2012_512' - | 'GOST_3411_HMAC' - | 'GOST_3411_2012_256_HMAC' - | 'GOST_3411_2012_512_HMAC'; - /** - * Создает хэш сообщения по ГОСТ Р 34.11 + * Создает хэш сообщения по ГОСТ Р 34.11-2012 256 бит * https://ru.wikipedia.org/wiki/%D0%A1%D1%82%D1%80%D0%B8%D0%B1%D0%BE%D0%B3_(%D1%85%D0%B5%D1%88-%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D1%8F) * * @param unencryptedMessage - сообщение для хеширования - * @param algorithm - один из алгоритмов хеширования: - * GOST_3411 - * GOST_3411_2012_256 - * GOST_3411_2012_512 - по умолчанию - * GOST_3411_HMAC - * GOST_3411_2012_256_HMAC - * GOST_3411_2012_512_HMAC * * @returns хэш */ export const createHash = _afterPluginsLoaded( - async (unencryptedMessage: string | ArrayBuffer, algorithm: Algorithm = 'GOST_3411_2012_512'): Promise => { + async (unencryptedMessage: string | ArrayBuffer): Promise => { const { cadesplugin } = window; return eval( @@ -46,7 +31,7 @@ export const createHash = _afterPluginsLoaded( try { void ( __cadesAsyncToken__ + - cadesHashedData.propset_Algorithm(cadesplugin['CADESCOM_HASH_ALGORITHM_CP_' + algorithm]) + cadesHashedData.propset_Algorithm(cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256) ); void (__cadesAsyncToken__ + cadesHashedData.propset_DataEncoding(cadesplugin.CADESCOM_BASE64_TO_BINARY)); void (__cadesAsyncToken__ + cadesHashedData.Hash(messageBase64));