Remove length checking for HMCAC importKey
This commit is contained in:
parent
93461d0973
commit
2148dd814d
|
@ -58,16 +58,6 @@ export class HmacProvider extends core.HmacProvider {
|
||||||
key.extractable = extractable;
|
key.extractable = extractable;
|
||||||
key.usages = keyUsages;
|
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;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
test/hmac.ts
25
test/hmac.ts
|
@ -2,7 +2,7 @@ import { Convert } from "pvtsutils";
|
||||||
import { Crypto } from "../src";
|
import { Crypto } from "../src";
|
||||||
import { ITestGenerateKeyAction, testCrypto } from "./helper";
|
import { ITestGenerateKeyAction, testCrypto } from "./helper";
|
||||||
|
|
||||||
context("HMAC", () => {
|
context.only("HMAC", () => {
|
||||||
|
|
||||||
const crypto = new Crypto();
|
const crypto = new Crypto();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ context("HMAC", () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
import: [
|
import: [
|
||||||
{
|
{ // JWK SHA-1
|
||||||
name: "JWK SHA-1",
|
name: "JWK SHA-1",
|
||||||
format: "jwk",
|
format: "jwk",
|
||||||
data: {
|
data: {
|
||||||
|
@ -87,7 +87,7 @@ context("HMAC", () => {
|
||||||
extractable: true,
|
extractable: true,
|
||||||
keyUsages: ["sign", "verify"],
|
keyUsages: ["sign", "verify"],
|
||||||
},
|
},
|
||||||
{
|
{ // JWK SHA-256
|
||||||
name: "JWK SHA-256",
|
name: "JWK SHA-256",
|
||||||
format: "jwk",
|
format: "jwk",
|
||||||
data: {
|
data: {
|
||||||
|
@ -104,7 +104,7 @@ context("HMAC", () => {
|
||||||
extractable: true,
|
extractable: true,
|
||||||
keyUsages: ["sign", "verify"],
|
keyUsages: ["sign", "verify"],
|
||||||
},
|
},
|
||||||
{
|
{ // JWK SHA-384
|
||||||
name: "JWK SHA-384",
|
name: "JWK SHA-384",
|
||||||
format: "jwk",
|
format: "jwk",
|
||||||
data: {
|
data: {
|
||||||
|
@ -121,7 +121,7 @@ context("HMAC", () => {
|
||||||
extractable: true,
|
extractable: true,
|
||||||
keyUsages: ["sign", "verify"],
|
keyUsages: ["sign", "verify"],
|
||||||
},
|
},
|
||||||
{
|
{ // JWK SHA-512
|
||||||
name: "JWK SHA-512",
|
name: "JWK SHA-512",
|
||||||
format: "jwk",
|
format: "jwk",
|
||||||
data: {
|
data: {
|
||||||
|
@ -138,8 +138,8 @@ context("HMAC", () => {
|
||||||
extractable: true,
|
extractable: true,
|
||||||
keyUsages: ["sign", "verify"],
|
keyUsages: ["sign", "verify"],
|
||||||
},
|
},
|
||||||
{
|
{ // raw 128
|
||||||
name: "raw",
|
name: "raw 128",
|
||||||
format: "raw",
|
format: "raw",
|
||||||
data: Convert.FromBase64("AQIDBAUGBwgJAAECAwQFBg"),
|
data: Convert.FromBase64("AQIDBAUGBwgJAAECAwQFBg"),
|
||||||
algorithm: {
|
algorithm: {
|
||||||
|
@ -149,6 +149,17 @@ context("HMAC", () => {
|
||||||
extractable: true,
|
extractable: true,
|
||||||
keyUsages: ["sign", "verify"],
|
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"],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Reference in New Issue