@reallyme/crypto 0.4.8 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,12 +10,12 @@ export declare const REALLYME_KEY_AGREEMENT_ALGORITHMS: readonly ["X25519", "P-2
10
10
  export type ReallyMeKeyAgreementAlgorithm = (typeof REALLYME_KEY_AGREEMENT_ALGORITHMS)[number];
11
11
  export declare const REALLYME_MAC_ALGORITHMS: readonly ["HMAC-SHA-256", "HMAC-SHA-384", "HMAC-SHA-512"];
12
12
  export type ReallyMeMacAlgorithm = (typeof REALLYME_MAC_ALGORITHMS)[number];
13
- export declare const REALLYME_KDF_ALGORITHMS: readonly ["HKDF-SHA256", "HKDF-SHA384", "Argon2id", "KMAC256", "PBKDF2-HMAC-SHA-256", "PBKDF2-HMAC-SHA-512", "JWA-CONCAT-KDF-SHA256"];
13
+ export declare const REALLYME_KDF_ALGORITHMS: readonly ["HKDF-SHA256", "HKDF-SHA384", "HKDF-SHA512", "Argon2id", "KMAC256", "PBKDF2-HMAC-SHA-256", "PBKDF2-HMAC-SHA-512", "JWA-CONCAT-KDF-SHA256"];
14
14
  export type ReallyMeKdfAlgorithm = (typeof REALLYME_KDF_ALGORITHMS)[number];
15
15
  /** PBKDF2 selectors accepted by the password-based `deriveKey` facade. */
16
16
  export type ReallyMePbkdf2Algorithm = Extract<ReallyMeKdfAlgorithm, "PBKDF2-HMAC-SHA-256" | "PBKDF2-HMAC-SHA-512">;
17
17
  /** HKDF selectors accepted by the `deriveHkdf` facade. */
18
- export type ReallyMeHkdfAlgorithm = Extract<ReallyMeKdfAlgorithm, "HKDF-SHA256" | "HKDF-SHA384">;
18
+ export type ReallyMeHkdfAlgorithm = Extract<ReallyMeKdfAlgorithm, "HKDF-SHA256" | "HKDF-SHA384" | "HKDF-SHA512">;
19
19
  /** JWA Concat KDF selector accepted by its dedicated facade. */
20
20
  export type ReallyMeJwaConcatKdfAlgorithm = Extract<ReallyMeKdfAlgorithm, "JWA-CONCAT-KDF-SHA256">;
21
21
  /** KMAC KDF selector accepted by its dedicated facade. */
@@ -69,6 +69,7 @@ export const REALLYME_MAC_ALGORITHMS = [
69
69
  export const REALLYME_KDF_ALGORITHMS = [
70
70
  "HKDF-SHA256",
71
71
  "HKDF-SHA384",
72
+ "HKDF-SHA512",
72
73
  "Argon2id",
73
74
  "KMAC256",
74
75
  "PBKDF2-HMAC-SHA-256",
@@ -123,6 +123,8 @@ export const createReallyMeSymmetricFacade = (resolveWasmProvider) => ({
123
123
  return ReallyMeHkdf.deriveSha256(inputKeyMaterial, salt, info, outputLength);
124
124
  case "HKDF-SHA384":
125
125
  return ReallyMeHkdf.deriveSha384(inputKeyMaterial, salt, info, outputLength);
126
+ case "HKDF-SHA512":
127
+ return ReallyMeHkdf.deriveSha512(inputKeyMaterial, salt, info, outputLength);
126
128
  default:
127
129
  throw new ReallyMeCryptoError("unsupported-algorithm");
128
130
  }
package/dist/hkdf.d.ts CHANGED
@@ -5,4 +5,5 @@ export declare const HKDF_MAX_OUTPUT_LENGTH = 4096;
5
5
  export declare const ReallyMeHkdf: {
6
6
  readonly deriveSha256: (inputKeyMaterial: Uint8Array, salt: Uint8Array, info: Uint8Array, outputLength: number) => Uint8Array;
7
7
  readonly deriveSha384: (inputKeyMaterial: Uint8Array, salt: Uint8Array, info: Uint8Array, outputLength: number) => Uint8Array;
8
+ readonly deriveSha512: (inputKeyMaterial: Uint8Array, salt: Uint8Array, info: Uint8Array, outputLength: number) => Uint8Array;
8
9
  };
package/dist/hkdf.js CHANGED
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { hkdf } from "@noble/hashes/hkdf.js";
5
- import { sha256, sha384 } from "@noble/hashes/sha2.js";
5
+ import { sha256, sha384, sha512 } from "@noble/hashes/sha2.js";
6
6
  import { ReallyMeCryptoError } from "./errors.js";
7
7
  import { ensureByteArray } from "./validateBytes.js";
8
8
  export const HKDF_MIN_INPUT_KEY_MATERIAL_LENGTH = 1;
@@ -18,6 +18,10 @@ export const ReallyMeHkdf = {
18
18
  validate(inputKeyMaterial, salt, info, outputLength);
19
19
  return hkdf(sha384, inputKeyMaterial, salt, info, outputLength);
20
20
  },
21
+ deriveSha512(inputKeyMaterial, salt, info, outputLength) {
22
+ validate(inputKeyMaterial, salt, info, outputLength);
23
+ return hkdf(sha512, inputKeyMaterial, salt, info, outputLength);
24
+ },
21
25
  };
22
26
  function validate(inputKeyMaterial, salt, info, outputLength) {
23
27
  ensureByteArray(inputKeyMaterial);
@@ -154,6 +154,12 @@ export type CryptoOperationRequest = Message<"reallyme.crypto.v1.CryptoOperation
154
154
  */
155
155
  value: CryptoMacVerifyRequest;
156
156
  case: "macVerify";
157
+ } | {
158
+ /**
159
+ * @generated from field: reallyme.crypto.v1.CryptoShakeExpandRequest shake_expand = 6;
160
+ */
161
+ value: CryptoShakeExpandRequest;
162
+ case: "shakeExpand";
157
163
  } | {
158
164
  /**
159
165
  * @generated from field: reallyme.crypto.v1.CryptoSignatureGenerateKeyPairRequest signature_generate_key_pair = 10;
@@ -405,6 +411,12 @@ export type CryptoOperationResult = Message<"reallyme.crypto.v1.CryptoOperationR
405
411
  */
406
412
  value: CryptoVerificationResult;
407
413
  case: "macVerify";
414
+ } | {
415
+ /**
416
+ * @generated from field: reallyme.crypto.v1.CryptoShakeExpandResult shake_expand = 6;
417
+ */
418
+ value: CryptoShakeExpandResult;
419
+ case: "shakeExpand";
408
420
  } | {
409
421
  /**
410
422
  * @generated from field: reallyme.crypto.v1.CryptoKeyPair signature_generate_key_pair = 10;
@@ -751,7 +763,7 @@ export type HpkeSuiteIdentifier = Message<"reallyme.crypto.v1.HpkeSuiteIdentifie
751
763
  export declare const HpkeSuiteIdentifierSchema: GenMessage<HpkeSuiteIdentifier>;
752
764
  /**
753
765
  * CryptoHkdfSuiteIdentifier is metadata for the direct HKDF primitive. The
754
- * hash field is the existing HashAlgorithm subset SHA2-256, SHA2-384 and
766
+ * hash field is the HashAlgorithm subset SHA2-256, SHA2-384, SHA2-512 and
755
767
  * SHA3-256. SHA3-256 recognition does not enable its optional implementation
756
768
  * or add an executable KdfAlgorithm selector or provider capability.
757
769
  *
@@ -1590,6 +1602,51 @@ export type CryptoHashResult = Message<"reallyme.crypto.v1.CryptoHashResult"> &
1590
1602
  * Use `create(CryptoHashResultSchema)` to create a new message.
1591
1603
  */
1592
1604
  export declare const CryptoHashResultSchema: GenMessage<CryptoHashResult>;
1605
+ /**
1606
+ * Standalone FIPS 202 SHAKE expansion over the exact input bytes. Both input
1607
+ * and output can contain sensitive material. The operation requires the output
1608
+ * length in octets, accepts an explicit zero, and rejects lengths above the
1609
+ * SHAKE_EXPAND_MAX_OUTPUT_LENGTH resource limit before allocating output.
1610
+ *
1611
+ * @generated from message reallyme.crypto.v1.CryptoShakeExpandRequest
1612
+ */
1613
+ export type CryptoShakeExpandRequest = Message<"reallyme.crypto.v1.CryptoShakeExpandRequest"> & {
1614
+ /**
1615
+ * @generated from field: reallyme.crypto.v1.ShakeAlgorithm algorithm = 1;
1616
+ */
1617
+ algorithm: ShakeAlgorithm;
1618
+ /**
1619
+ * @generated from field: bytes input = 2;
1620
+ */
1621
+ input: Uint8Array;
1622
+ /**
1623
+ * @generated from field: optional uint32 output_length = 3;
1624
+ */
1625
+ outputLength?: number | undefined;
1626
+ };
1627
+ /**
1628
+ * Describes the message reallyme.crypto.v1.CryptoShakeExpandRequest.
1629
+ * Use `create(CryptoShakeExpandRequestSchema)` to create a new message.
1630
+ */
1631
+ export declare const CryptoShakeExpandRequestSchema: GenMessage<CryptoShakeExpandRequest>;
1632
+ /**
1633
+ * @generated from message reallyme.crypto.v1.CryptoShakeExpandResult
1634
+ */
1635
+ export type CryptoShakeExpandResult = Message<"reallyme.crypto.v1.CryptoShakeExpandResult"> & {
1636
+ /**
1637
+ * @generated from field: reallyme.crypto.v1.ShakeAlgorithm algorithm = 1;
1638
+ */
1639
+ algorithm: ShakeAlgorithm;
1640
+ /**
1641
+ * @generated from field: bytes output = 2;
1642
+ */
1643
+ output: Uint8Array;
1644
+ };
1645
+ /**
1646
+ * Describes the message reallyme.crypto.v1.CryptoShakeExpandResult.
1647
+ * Use `create(CryptoShakeExpandResultSchema)` to create a new message.
1648
+ */
1649
+ export declare const CryptoShakeExpandResultSchema: GenMessage<CryptoShakeExpandResult>;
1593
1650
  /**
1594
1651
  * Incremental hashing is a local, exclusively owned SDK lifecycle. A successful
1595
1652
  * start creates a fresh context; updates append exact bytes in order, including
@@ -6712,6 +6769,30 @@ export declare enum HashAlgorithm {
6712
6769
  * Describes the enum reallyme.crypto.v1.HashAlgorithm.
6713
6770
  */
6714
6771
  export declare const HashAlgorithmSchema: GenEnum<HashAlgorithm>;
6772
+ /**
6773
+ * ShakeAlgorithm identifies the FIPS 202 extendable-output functions. These
6774
+ * selectors carry no fixed digest width. The caller requests the output length.
6775
+ *
6776
+ * @generated from enum reallyme.crypto.v1.ShakeAlgorithm
6777
+ */
6778
+ export declare enum ShakeAlgorithm {
6779
+ /**
6780
+ * @generated from enum value: SHAKE_ALGORITHM_UNSPECIFIED = 0;
6781
+ */
6782
+ UNSPECIFIED = 0,
6783
+ /**
6784
+ * @generated from enum value: SHAKE_ALGORITHM_SHAKE128 = 100;
6785
+ */
6786
+ SHAKE128 = 100,
6787
+ /**
6788
+ * @generated from enum value: SHAKE_ALGORITHM_SHAKE256 = 110;
6789
+ */
6790
+ SHAKE256 = 110
6791
+ }
6792
+ /**
6793
+ * Describes the enum reallyme.crypto.v1.ShakeAlgorithm.
6794
+ */
6795
+ export declare const ShakeAlgorithmSchema: GenEnum<ShakeAlgorithm>;
6715
6796
  /**
6716
6797
  * MacAlgorithm identifies message-authentication-code suites. Values 100-199
6717
6798
  * are HMAC suites over SHA-2.
@@ -6766,6 +6847,10 @@ export declare enum KdfAlgorithm {
6766
6847
  * @generated from enum value: KDF_ALGORITHM_HKDF_SHA384 = 110;
6767
6848
  */
6768
6849
  HKDF_SHA384 = 110,
6850
+ /**
6851
+ * @generated from enum value: KDF_ALGORITHM_HKDF_SHA512 = 120;
6852
+ */
6853
+ HKDF_SHA512 = 120,
6769
6854
  /**
6770
6855
  * @generated from enum value: KDF_ALGORITHM_ARGON2ID = 200;
6771
6856
  */