Remove length checking for HMCAC importKey

This commit is contained in:
microshine 2019-03-28 16:31:50 +03:00
parent 93461d0973
commit 2148dd814d
2 changed files with 18 additions and 17 deletions

View File

@ -58,16 +58,6 @@ export class HmacProvider extends core.HmacProvider {
key.extractable = extractable;
key.usages = keyUsages;
// check key length
switch (key.algorithm.length) {
case 128:
case 192:
case 256:
break;
default:
throw new core.OperationError("keyData: Is wrong key length");
}
return key;
}

View File

@ -2,7 +2,7 @@ import { Convert } from "pvtsutils";
import { Crypto } from "../src";
import { ITestGenerateKeyAction, testCrypto } from "./helper";
context("HMAC", () => {
context.only("HMAC", () => {
const crypto = new Crypto();
@ -69,7 +69,7 @@ context("HMAC", () => {
},
],
import: [
{
{ // JWK SHA-1
name: "JWK SHA-1",
format: "jwk",
data: {
@ -87,7 +87,7 @@ context("HMAC", () => {
extractable: true,
keyUsages: ["sign", "verify"],
},
{
{ // JWK SHA-256
name: "JWK SHA-256",
format: "jwk",
data: {
@ -104,7 +104,7 @@ context("HMAC", () => {
extractable: true,
keyUsages: ["sign", "verify"],
},
{
{ // JWK SHA-384
name: "JWK SHA-384",
format: "jwk",
data: {
@ -121,7 +121,7 @@ context("HMAC", () => {
extractable: true,
keyUsages: ["sign", "verify"],
},
{
{ // JWK SHA-512
name: "JWK SHA-512",
format: "jwk",
data: {
@ -138,8 +138,8 @@ context("HMAC", () => {
extractable: true,
keyUsages: ["sign", "verify"],
},
{
name: "raw",
{ // raw 128
name: "raw 128",
format: "raw",
data: Convert.FromBase64("AQIDBAUGBwgJAAECAwQFBg"),
algorithm: {
@ -149,6 +149,17 @@ context("HMAC", () => {
extractable: true,
keyUsages: ["sign", "verify"],
},
{ // raw 160
name: "raw 160",
format: "raw",
data: new Uint8Array(20),
algorithm: {
name: "HMAC",
hash: "SHA-512",
} as HmacImportParams,
extractable: true,
keyUsages: ["sign", "verify"],
},
],
},
},