Skip to content

Commit ff3aad6

Browse files
committed
More test vectors
1 parent 27eb26a commit ff3aad6

File tree

4 files changed

+469
-288
lines changed

4 files changed

+469
-288
lines changed

modules/kdf-ctr-mode-node/src/kdfctr.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ import { uInt32BE } from '@aws-crypto/serialize'
1414
const SEPARATION_INDICATOR = Buffer.from([0x00])
1515
const COUNTER_START_VALUE = 1
1616
export const INT32_MAX_LIMIT = 2147483647
17-
const SUPPORTED_IKM_LENGTHS = [32]
18-
const SUPPORTED_NONCE_LENGTHS = [16]
1917
const SUPPORTED_DERIVED_KEY_LENGTHS = [32]
20-
const SUPPORTED_DIGEST_ALGORITHMS = ['sha256']
18+
const SUPPORTED_DIGEST_ALGORITHMS = ['sha256', 'sha384']
2119

22-
export type SupportedDigestAlgorithms = 'sha256'
20+
export type SupportedDigestAlgorithms = 'sha256' | 'sha384'
2321
export type SupportedDerivedKeyLengths = 32
2422

2523
interface KdfCtrInput {
@@ -37,18 +35,8 @@ export function kdfCounterMode({
3735
purpose,
3836
expectedLength,
3937
}: KdfCtrInput): Buffer {
40-
/* Precondition: the ikm must be 32 bytes long */
41-
needs(
42-
SUPPORTED_IKM_LENGTHS.includes(ikm.length),
43-
`Unsupported IKM length ${ikm.length}`
44-
)
4538
/* Precondition: the nonce is required */
4639
needs(nonce, 'The nonce must be provided')
47-
/* Precondition: the nonce must be 16 bytes long */
48-
needs(
49-
SUPPORTED_NONCE_LENGTHS.includes(nonce.length),
50-
`Unsupported nonce length ${nonce.length}`
51-
)
5240
/* Precondition: the expected length must be 32 bytes */
5341
/* Precondition: the expected length * 8 must be under the max 32-bit signed integer */
5442
needs(

0 commit comments

Comments
 (0)