@sebastienrousseau/crypto-cli 0.0.9 → 0.0.24
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.
- package/README.md +360 -0
- package/dist/program/hpke.d.ts +4 -0
- package/dist/program/hpke.d.ts.map +1 -0
- package/dist/program/hpke.js +111 -0
- package/dist/program/index.d.ts.map +1 -1
- package/dist/program/index.js +8 -0
- package/dist/program/kms.d.ts +8 -0
- package/dist/program/kms.d.ts.map +1 -0
- package/dist/program/kms.js +247 -0
- package/dist/program/opaque.d.ts +4 -0
- package/dist/program/opaque.d.ts.map +1 -0
- package/dist/program/opaque.js +209 -0
- package/dist/program/stream-multi.d.ts +7 -0
- package/dist/program/stream-multi.d.ts.map +1 -0
- package/dist/program/stream-multi.js +163 -0
- package/dist/program/stream.d.ts +6 -0
- package/dist/program/stream.d.ts.map +1 -0
- package/dist/program/stream.js +102 -0
- package/package.json +8 -13
package/README.md
CHANGED
|
@@ -263,6 +263,13 @@ Commands:
|
|
|
263
263
|
valid
|
|
264
264
|
password Hash or verify a password (Argon2id)
|
|
265
265
|
cbom Generate or audit a Cryptographic Bill of Materials
|
|
266
|
+
stream Post-quantum hybrid streaming AEAD operations
|
|
267
|
+
opaque OPAQUE zero-knowledge password authentication (RFC
|
|
268
|
+
9807)
|
|
269
|
+
hpke Hybrid Public Key Encryption (HPKE RFC 9180 and PQ
|
|
270
|
+
hybrid)
|
|
271
|
+
kms Key Management Service (KMS) operations across
|
|
272
|
+
native cloud providers
|
|
266
273
|
```
|
|
267
274
|
|
|
268
275
|
#### `crypto-cli hash`
|
|
@@ -484,6 +491,359 @@ Options:
|
|
|
484
491
|
-h, --help print help
|
|
485
492
|
```
|
|
486
493
|
|
|
494
|
+
#### `crypto-cli stream`
|
|
495
|
+
|
|
496
|
+
```text
|
|
497
|
+
Usage: crypto-cli stream [options] [command]
|
|
498
|
+
|
|
499
|
+
Post-quantum hybrid streaming AEAD operations
|
|
500
|
+
|
|
501
|
+
Options:
|
|
502
|
+
-h, --help print help
|
|
503
|
+
|
|
504
|
+
Commands:
|
|
505
|
+
encrypt [options] [file] Encrypt with post-quantum hybrid STREAM AEAD
|
|
506
|
+
(X25519 + ML-KEM-768)
|
|
507
|
+
decrypt [options] [file] Decrypt post-quantum hybrid STREAM ciphertext;
|
|
508
|
+
exits 1 on error
|
|
509
|
+
multi-encrypt [options] [file] Encrypt for multiple recipients with
|
|
510
|
+
post-quantum hybrid STREAM AEAD
|
|
511
|
+
multi-decrypt [options] [file] Decrypt multi-recipient post-quantum hybrid
|
|
512
|
+
STREAM ciphertext; exits 1 on error
|
|
513
|
+
help [command] display help for command
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
#### `crypto-cli stream encrypt`
|
|
517
|
+
|
|
518
|
+
```text
|
|
519
|
+
Usage: crypto-cli stream encrypt [options] [file]
|
|
520
|
+
|
|
521
|
+
Encrypt with post-quantum hybrid STREAM AEAD (X25519 + ML-KEM-768)
|
|
522
|
+
|
|
523
|
+
Arguments:
|
|
524
|
+
file file to encrypt; '-' or omitted reads standard
|
|
525
|
+
input
|
|
526
|
+
|
|
527
|
+
Options:
|
|
528
|
+
-x, --x25519-public <hex> recipient X25519 public key (hex)
|
|
529
|
+
-m, --ml-kem-public <hex> recipient ML-KEM-768 public key (hex)
|
|
530
|
+
-c, --chunk-size <bytes> chunk size in bytes (minimum 64, default 65536)
|
|
531
|
+
--json print the result as one line of JSON
|
|
532
|
+
-h, --help print help
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
#### `crypto-cli stream decrypt`
|
|
536
|
+
|
|
537
|
+
```text
|
|
538
|
+
Usage: crypto-cli stream decrypt [options] [file]
|
|
539
|
+
|
|
540
|
+
Decrypt post-quantum hybrid STREAM ciphertext; exits 1 on error
|
|
541
|
+
|
|
542
|
+
Arguments:
|
|
543
|
+
file output of stream encrypt (base64 or its --json
|
|
544
|
+
line)
|
|
545
|
+
|
|
546
|
+
Options:
|
|
547
|
+
-x, --x25519-secret <hex> recipient X25519 secret key (hex)
|
|
548
|
+
-m, --ml-kem-secret <hex> recipient ML-KEM-768 secret key (hex)
|
|
549
|
+
-c, --chunk-size <bytes> chunk size in bytes
|
|
550
|
+
--json print the result as one line of JSON
|
|
551
|
+
-h, --help print help
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
#### `crypto-cli stream multi-encrypt`
|
|
555
|
+
|
|
556
|
+
```text
|
|
557
|
+
Usage: crypto-cli stream multi-encrypt [options] [file]
|
|
558
|
+
|
|
559
|
+
Encrypt for multiple recipients with post-quantum hybrid STREAM AEAD
|
|
560
|
+
|
|
561
|
+
Arguments:
|
|
562
|
+
file file to encrypt; '-' or omitted reads
|
|
563
|
+
standard input
|
|
564
|
+
|
|
565
|
+
Options:
|
|
566
|
+
-r, --recipients <json-or-path> JSON array string or file path containing
|
|
567
|
+
recipient public key descriptors
|
|
568
|
+
-c, --chunk-size <bytes> chunk size in bytes (minimum 1024, default
|
|
569
|
+
65536)
|
|
570
|
+
--json print the result as one line of JSON
|
|
571
|
+
-h, --help print help
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
#### `crypto-cli stream multi-decrypt`
|
|
575
|
+
|
|
576
|
+
```text
|
|
577
|
+
Usage: crypto-cli stream multi-decrypt [options] [file]
|
|
578
|
+
|
|
579
|
+
Decrypt multi-recipient post-quantum hybrid STREAM ciphertext; exits 1 on error
|
|
580
|
+
|
|
581
|
+
Arguments:
|
|
582
|
+
file output of stream multi-encrypt (base64 or its
|
|
583
|
+
--json line)
|
|
584
|
+
|
|
585
|
+
Options:
|
|
586
|
+
-x, --x25519-secret <hex> recipient X25519 secret key (hex)
|
|
587
|
+
-m, --ml-kem-secret <hex> recipient ML-KEM-768 secret key (hex)
|
|
588
|
+
-i, --recipient-id <id> optional recipient identifier for direct slot
|
|
589
|
+
lookup
|
|
590
|
+
-c, --chunk-size <bytes> chunk size in bytes
|
|
591
|
+
--json print the result as one line of JSON
|
|
592
|
+
-h, --help print help
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
#### `crypto-cli opaque`
|
|
596
|
+
|
|
597
|
+
```text
|
|
598
|
+
Usage: crypto-cli opaque [options] [command]
|
|
599
|
+
|
|
600
|
+
OPAQUE zero-knowledge password authentication (RFC 9807)
|
|
601
|
+
|
|
602
|
+
Options:
|
|
603
|
+
-h, --help print help
|
|
604
|
+
|
|
605
|
+
Commands:
|
|
606
|
+
setup [options] Generate server long-term keys and fake record
|
|
607
|
+
register [options] <id> Register a password with an OPAQUE server
|
|
608
|
+
login [options] <id> Authenticate against an OPAQUE server
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
#### `crypto-cli opaque setup`
|
|
612
|
+
|
|
613
|
+
```text
|
|
614
|
+
Usage: crypto-cli opaque setup [options]
|
|
615
|
+
|
|
616
|
+
Generate server long-term keys and fake record
|
|
617
|
+
|
|
618
|
+
Options:
|
|
619
|
+
-s, --suite <name> ciphersuite (choices: "P256-SHA256",
|
|
620
|
+
"ristretto255-SHA512", default: "P256-SHA256")
|
|
621
|
+
--json print result as JSON
|
|
622
|
+
-h, --help print help
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
#### `crypto-cli opaque register`
|
|
626
|
+
|
|
627
|
+
```text
|
|
628
|
+
Usage: crypto-cli opaque register [options] <id>
|
|
629
|
+
|
|
630
|
+
Register a password with an OPAQUE server
|
|
631
|
+
|
|
632
|
+
Options:
|
|
633
|
+
-u, --server-url <url> server base URL
|
|
634
|
+
-s, --suite <name> ciphersuite (choices: "P256-SHA256",
|
|
635
|
+
"ristretto255-SHA512", default: "P256-SHA256")
|
|
636
|
+
--json print result as JSON
|
|
637
|
+
--password-file <path> read the password from a file: one trailing line break
|
|
638
|
+
is ignored
|
|
639
|
+
--password-stdin read the password from standard input
|
|
640
|
+
-h, --help print help
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
#### `crypto-cli opaque login`
|
|
644
|
+
|
|
645
|
+
```text
|
|
646
|
+
Usage: crypto-cli opaque login [options] <id>
|
|
647
|
+
|
|
648
|
+
Authenticate against an OPAQUE server
|
|
649
|
+
|
|
650
|
+
Options:
|
|
651
|
+
-u, --server-url <url> server base URL
|
|
652
|
+
-s, --suite <name> ciphersuite (choices: "P256-SHA256",
|
|
653
|
+
"ristretto255-SHA512", default: "P256-SHA256")
|
|
654
|
+
--json print result as JSON
|
|
655
|
+
--password-file <path> read the password from a file: one trailing line break
|
|
656
|
+
is ignored
|
|
657
|
+
--password-stdin read the password from standard input
|
|
658
|
+
-h, --help print help
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
#### `crypto-cli hpke`
|
|
662
|
+
|
|
663
|
+
```text
|
|
664
|
+
Usage: crypto-cli hpke [options] [command]
|
|
665
|
+
|
|
666
|
+
Hybrid Public Key Encryption (HPKE RFC 9180 and PQ hybrid)
|
|
667
|
+
|
|
668
|
+
Options:
|
|
669
|
+
-h, --help print help
|
|
670
|
+
|
|
671
|
+
Commands:
|
|
672
|
+
keygen [options] Generate an HPKE key pair
|
|
673
|
+
seal [options] [file] Encrypt a message using HPKE
|
|
674
|
+
open [options] [file] Decrypt an HPKE ciphertext
|
|
675
|
+
help [command] display help for command
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
#### `crypto-cli hpke keygen`
|
|
679
|
+
|
|
680
|
+
```text
|
|
681
|
+
Usage: crypto-cli hpke keygen [options]
|
|
682
|
+
|
|
683
|
+
Generate an HPKE key pair
|
|
684
|
+
|
|
685
|
+
Options:
|
|
686
|
+
-k, --kem <kem> key encapsulation mechanism (choices: "x25519-ml-kem-768",
|
|
687
|
+
"x25519", "p256", default: "x25519-ml-kem-768")
|
|
688
|
+
--json print key pair as JSON
|
|
689
|
+
-h, --help print help
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
#### `crypto-cli hpke seal`
|
|
693
|
+
|
|
694
|
+
```text
|
|
695
|
+
Usage: crypto-cli hpke seal [options] [file]
|
|
696
|
+
|
|
697
|
+
Encrypt a message using HPKE
|
|
698
|
+
|
|
699
|
+
Options:
|
|
700
|
+
-p, --public-key <hex> recipient public key (hex)
|
|
701
|
+
-k, --kem <kem> key encapsulation mechanism (choices:
|
|
702
|
+
"x25519-ml-kem-768", "x25519", "p256", default:
|
|
703
|
+
"x25519-ml-kem-768")
|
|
704
|
+
-a, --aead <aead> authenticated encryption algorithm (choices:
|
|
705
|
+
"chacha20-poly1305", "aes-128-gcm", default:
|
|
706
|
+
"chacha20-poly1305")
|
|
707
|
+
--info <info> application-supplied info string
|
|
708
|
+
--aad <aad> additional authenticated data
|
|
709
|
+
--json print ciphertext and encapsulated key as JSON
|
|
710
|
+
-h, --help print help
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
#### `crypto-cli hpke open`
|
|
714
|
+
|
|
715
|
+
```text
|
|
716
|
+
Usage: crypto-cli hpke open [options] [file]
|
|
717
|
+
|
|
718
|
+
Decrypt an HPKE ciphertext
|
|
719
|
+
|
|
720
|
+
Options:
|
|
721
|
+
-s, --secret-key <hex> recipient private key (hex)
|
|
722
|
+
-e, --encapsulated-key <hex> encapsulated key (hex)
|
|
723
|
+
-k, --kem <kem> key encapsulation mechanism (choices:
|
|
724
|
+
"x25519-ml-kem-768", "x25519", "p256", default:
|
|
725
|
+
"x25519-ml-kem-768")
|
|
726
|
+
-a, --aead <aead> authenticated encryption algorithm (choices:
|
|
727
|
+
"chacha20-poly1305", "aes-128-gcm", default:
|
|
728
|
+
"chacha20-poly1305")
|
|
729
|
+
--info <info> application-supplied info string
|
|
730
|
+
--aad <aad> additional authenticated data
|
|
731
|
+
--json print plaintext and hex as JSON
|
|
732
|
+
-h, --help print help
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
#### `crypto-cli kms`
|
|
736
|
+
|
|
737
|
+
```text
|
|
738
|
+
Usage: crypto-cli kms [options] [command]
|
|
739
|
+
|
|
740
|
+
Key Management Service (KMS) operations across native cloud providers
|
|
741
|
+
|
|
742
|
+
Options:
|
|
743
|
+
-h, --help print help
|
|
744
|
+
|
|
745
|
+
Commands:
|
|
746
|
+
create-key [options] Create a new managed key in KMS
|
|
747
|
+
generate-data-key [options] Generate a Data Encryption Key (DEK) via KMS
|
|
748
|
+
wrap [options] [file] Wrap (encrypt) a key using a KMS key
|
|
749
|
+
unwrap [options] [file] Unwrap a wrapped key using a KMS key
|
|
750
|
+
encrypt [options] [file] Encrypt data using a KMS key
|
|
751
|
+
decrypt [options] [file] Decrypt ciphertext using a KMS key
|
|
752
|
+
help [command] display help for command
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
#### `crypto-cli kms create-key`
|
|
756
|
+
|
|
757
|
+
```text
|
|
758
|
+
Usage: crypto-cli kms create-key [options]
|
|
759
|
+
|
|
760
|
+
Create a new managed key in KMS
|
|
761
|
+
|
|
762
|
+
Options:
|
|
763
|
+
-a, --algorithm <alg> Key algorithm (default: "aes-256-gcm")
|
|
764
|
+
-u, --usage <usage> Key usage (choices: "encrypt", "sign", "wrap", default:
|
|
765
|
+
"encrypt")
|
|
766
|
+
-p, --provider <name> KMS provider (local, aws, gcp, vault, azure) (default:
|
|
767
|
+
"local")
|
|
768
|
+
--json Emit output as JSON
|
|
769
|
+
-h, --help print help
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
#### `crypto-cli kms generate-data-key`
|
|
773
|
+
|
|
774
|
+
```text
|
|
775
|
+
Usage: crypto-cli kms generate-data-key [options]
|
|
776
|
+
|
|
777
|
+
Generate a Data Encryption Key (DEK) via KMS
|
|
778
|
+
|
|
779
|
+
Options:
|
|
780
|
+
-k, --key-id <id> Key ID
|
|
781
|
+
-s, --key-spec <spec> Key spec (e.g. AES_256) (default: "AES_256")
|
|
782
|
+
-p, --provider <name> KMS provider (default: "local")
|
|
783
|
+
--json Emit output as JSON
|
|
784
|
+
-h, --help print help
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
#### `crypto-cli kms wrap`
|
|
788
|
+
|
|
789
|
+
```text
|
|
790
|
+
Usage: crypto-cli kms wrap [options] [file]
|
|
791
|
+
|
|
792
|
+
Wrap (encrypt) a key using a KMS key
|
|
793
|
+
|
|
794
|
+
Options:
|
|
795
|
+
-k, --key-id <id> Wrapping Key ID
|
|
796
|
+
-w, --key <hex> Raw key material to wrap
|
|
797
|
+
-p, --provider <name> KMS provider (default: "local")
|
|
798
|
+
--json Emit output as JSON
|
|
799
|
+
-h, --help print help
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
#### `crypto-cli kms unwrap`
|
|
803
|
+
|
|
804
|
+
```text
|
|
805
|
+
Usage: crypto-cli kms unwrap [options] [file]
|
|
806
|
+
|
|
807
|
+
Unwrap a wrapped key using a KMS key
|
|
808
|
+
|
|
809
|
+
Options:
|
|
810
|
+
-k, --key-id <id> Wrapping Key ID
|
|
811
|
+
-w, --wrapped-key <str> Wrapped key string
|
|
812
|
+
-p, --provider <name> KMS provider (default: "local")
|
|
813
|
+
--json Emit output as JSON
|
|
814
|
+
-h, --help print help
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
#### `crypto-cli kms encrypt`
|
|
818
|
+
|
|
819
|
+
```text
|
|
820
|
+
Usage: crypto-cli kms encrypt [options] [file]
|
|
821
|
+
|
|
822
|
+
Encrypt data using a KMS key
|
|
823
|
+
|
|
824
|
+
Options:
|
|
825
|
+
-k, --key-id <id> Key ID
|
|
826
|
+
-d, --data <text> Plaintext data to encrypt
|
|
827
|
+
-p, --provider <name> KMS provider (default: "local")
|
|
828
|
+
--json Emit output as JSON
|
|
829
|
+
-h, --help print help
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
#### `crypto-cli kms decrypt`
|
|
833
|
+
|
|
834
|
+
```text
|
|
835
|
+
Usage: crypto-cli kms decrypt [options] [file]
|
|
836
|
+
|
|
837
|
+
Decrypt ciphertext using a KMS key
|
|
838
|
+
|
|
839
|
+
Options:
|
|
840
|
+
-k, --key-id <id> Key ID
|
|
841
|
+
-c, --ciphertext <str> Ciphertext to decrypt
|
|
842
|
+
-p, --provider <name> KMS provider (default: "local")
|
|
843
|
+
--json Emit output as JSON
|
|
844
|
+
-h, --help print help
|
|
845
|
+
```
|
|
846
|
+
|
|
487
847
|
<!-- cli-usage:end -->
|
|
488
848
|
|
|
489
849
|
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke.d.ts","sourceRoot":"","sources":["../../src/program/hpke.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAM5C,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAyG1E,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,CA0DpE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerHpke = registerHpke;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const modern_1 = require("@sebastienrousseau/crypto-lib/modern");
|
|
6
|
+
const io_1 = require("./io");
|
|
7
|
+
const KEM_CHOICES = [
|
|
8
|
+
"x25519-ml-kem-768",
|
|
9
|
+
"x25519",
|
|
10
|
+
"p256",
|
|
11
|
+
];
|
|
12
|
+
const AEAD_CHOICES = [
|
|
13
|
+
"chacha20-poly1305",
|
|
14
|
+
"aes-128-gcm",
|
|
15
|
+
];
|
|
16
|
+
function stringToHex(text) {
|
|
17
|
+
const isHex = /^[0-9a-fA-F]*$/.test(text) && text.length % 2 === 0;
|
|
18
|
+
return isHex ? text : Buffer.from(text, "utf8").toString("hex");
|
|
19
|
+
}
|
|
20
|
+
function executeKeygen(opts, ctx) {
|
|
21
|
+
const kp = (0, modern_1.hpkeGenerateKeyPair)(opts.kem);
|
|
22
|
+
const data = {
|
|
23
|
+
kem: opts.kem,
|
|
24
|
+
publicKey: kp.publicKey,
|
|
25
|
+
privateKey: kp.privateKey,
|
|
26
|
+
};
|
|
27
|
+
const desc = [
|
|
28
|
+
`Algorithm: ${opts.kem}`,
|
|
29
|
+
`Public Key: ${kp.publicKey}`,
|
|
30
|
+
`Private Key: ${kp.privateKey}`,
|
|
31
|
+
].join("\n");
|
|
32
|
+
(0, io_1.emit)(ctx.io, Boolean(opts.json), data, desc);
|
|
33
|
+
}
|
|
34
|
+
async function executeSeal(file, opts, ctx) {
|
|
35
|
+
const raw = await (0, io_1.readInput)(file, ctx.io);
|
|
36
|
+
const plaintextHex = raw.toString("hex");
|
|
37
|
+
const res = (0, modern_1.hpkeSeal)({
|
|
38
|
+
recipientPublicKey: opts.publicKey,
|
|
39
|
+
plaintext: plaintextHex,
|
|
40
|
+
suite: { kem: opts.kem, aead: opts.aead },
|
|
41
|
+
...(opts.info !== undefined ? { info: stringToHex(opts.info) } : {}),
|
|
42
|
+
...(opts.aad !== undefined ? { aad: stringToHex(opts.aad) } : {}),
|
|
43
|
+
});
|
|
44
|
+
const data = {
|
|
45
|
+
encapsulatedKey: res.encapsulatedKey,
|
|
46
|
+
ciphertext: res.ciphertext,
|
|
47
|
+
};
|
|
48
|
+
const desc = [
|
|
49
|
+
`Encapsulated: ${res.encapsulatedKey}`,
|
|
50
|
+
`Ciphertext: ${res.ciphertext}`,
|
|
51
|
+
].join("\n");
|
|
52
|
+
(0, io_1.emit)(ctx.io, Boolean(opts.json), data, desc);
|
|
53
|
+
}
|
|
54
|
+
async function executeOpen(file, opts, ctx) {
|
|
55
|
+
const raw = await (0, io_1.readInput)(file, ctx.io);
|
|
56
|
+
const ciphertext = (0, io_1.valueOrJsonField)(raw, "ciphertext").trim();
|
|
57
|
+
const res = (0, modern_1.hpkeOpen)({
|
|
58
|
+
recipientPrivateKey: opts.secretKey,
|
|
59
|
+
encapsulatedKey: opts.encapsulatedKey,
|
|
60
|
+
ciphertext,
|
|
61
|
+
suite: { kem: opts.kem, aead: opts.aead },
|
|
62
|
+
...(opts.info !== undefined ? { info: stringToHex(opts.info) } : {}),
|
|
63
|
+
...(opts.aad !== undefined ? { aad: stringToHex(opts.aad) } : {}),
|
|
64
|
+
});
|
|
65
|
+
const plaintext = Buffer.from(res.plaintext, "hex").toString("utf8");
|
|
66
|
+
const data = { plaintext, hex: res.plaintext };
|
|
67
|
+
(0, io_1.emit)(ctx.io, Boolean(opts.json), data, plaintext);
|
|
68
|
+
}
|
|
69
|
+
function registerHpke(program, ctx) {
|
|
70
|
+
const hpke = program
|
|
71
|
+
.command("hpke")
|
|
72
|
+
.description("Hybrid Public Key Encryption (HPKE RFC 9180 and PQ hybrid)");
|
|
73
|
+
hpke
|
|
74
|
+
.command("keygen")
|
|
75
|
+
.description("Generate an HPKE key pair")
|
|
76
|
+
.addOption(new commander_1.Option("-k, --kem <kem>", "key encapsulation mechanism")
|
|
77
|
+
.choices(KEM_CHOICES)
|
|
78
|
+
.default("x25519-ml-kem-768"))
|
|
79
|
+
.option("--json", "print key pair as JSON")
|
|
80
|
+
.action((opts) => executeKeygen(opts, ctx));
|
|
81
|
+
hpke
|
|
82
|
+
.command("seal [file]")
|
|
83
|
+
.description("Encrypt a message using HPKE")
|
|
84
|
+
.requiredOption("-p, --public-key <hex>", "recipient public key (hex)")
|
|
85
|
+
.addOption(new commander_1.Option("-k, --kem <kem>", "key encapsulation mechanism")
|
|
86
|
+
.choices(KEM_CHOICES)
|
|
87
|
+
.default("x25519-ml-kem-768"))
|
|
88
|
+
.addOption(new commander_1.Option("-a, --aead <aead>", "authenticated encryption algorithm")
|
|
89
|
+
.choices(AEAD_CHOICES)
|
|
90
|
+
.default("chacha20-poly1305"))
|
|
91
|
+
.option("--info <info>", "application-supplied info string")
|
|
92
|
+
.option("--aad <aad>", "additional authenticated data")
|
|
93
|
+
.option("--json", "print ciphertext and encapsulated key as JSON")
|
|
94
|
+
.action((file, opts) => executeSeal(file, opts, ctx));
|
|
95
|
+
hpke
|
|
96
|
+
.command("open [file]")
|
|
97
|
+
.description("Decrypt an HPKE ciphertext")
|
|
98
|
+
.requiredOption("-s, --secret-key <hex>", "recipient private key (hex)")
|
|
99
|
+
.requiredOption("-e, --encapsulated-key <hex>", "encapsulated key (hex)")
|
|
100
|
+
.addOption(new commander_1.Option("-k, --kem <kem>", "key encapsulation mechanism")
|
|
101
|
+
.choices(KEM_CHOICES)
|
|
102
|
+
.default("x25519-ml-kem-768"))
|
|
103
|
+
.addOption(new commander_1.Option("-a, --aead <aead>", "authenticated encryption algorithm")
|
|
104
|
+
.choices(AEAD_CHOICES)
|
|
105
|
+
.default("chacha20-poly1305"))
|
|
106
|
+
.option("--info <info>", "application-supplied info string")
|
|
107
|
+
.option("--aad <aad>", "additional authenticated data")
|
|
108
|
+
.option("--json", "print plaintext and hex as JSON")
|
|
109
|
+
.action((file, opts) => executeOpen(file, opts, ctx));
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=hpke.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/program/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAKpD,OAAO,EAAoB,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/program/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAKpD,OAAO,EAAoB,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AASrE,OAAO,EACL,IAAI,EACJ,gBAAgB,EAChB,SAAS,EACT,KAAK,KAAK,EACV,KAAK,UAAU,GAChB,MAAM,MAAM,CAAC;AASd,eAAO,MAAM,YAAY,GAAI,KAAK,UAAU,EAAE,SAAS,MAAM,KAAG,OAyB/D,CAAC;AAmBF,eAAO,MAAM,GAAG,GAAU,MAAM,MAAM,EAAE,EAAE,IAAI,KAAK,KAAG,OAAO,CAAC,MAAM,CASnE,CAAC;AAWF,eAAO,MAAM,IAAI,GACf,MAAM,MAAM,EAAE,EACd,IAAI,KAAK,EACT,MAAM,MAAM,OAAO,CAAC,IAAI,CAAC,KACxB,OAAO,CAAC,MAAM,CAShB,CAAC"}
|
package/dist/program/index.js
CHANGED
|
@@ -10,6 +10,10 @@ const io_1 = require("./io");
|
|
|
10
10
|
const keygen_1 = require("./keygen");
|
|
11
11
|
const password_1 = require("./password");
|
|
12
12
|
const sign_1 = require("./sign");
|
|
13
|
+
const stream_1 = require("./stream");
|
|
14
|
+
const opaque_1 = require("./opaque");
|
|
15
|
+
const hpke_1 = require("./hpke");
|
|
16
|
+
const kms_1 = require("./kms");
|
|
13
17
|
var io_2 = require("./io");
|
|
14
18
|
Object.defineProperty(exports, "EXIT", { enumerable: true, get: function () { return io_2.EXIT; } });
|
|
15
19
|
Object.defineProperty(exports, "exitOnClosedPipe", { enumerable: true, get: function () { return io_2.exitOnClosedPipe; } });
|
|
@@ -32,6 +36,10 @@ const buildProgram = (ctx, version) => {
|
|
|
32
36
|
(0, sign_1.registerVerify)(program, ctx);
|
|
33
37
|
(0, password_1.registerPassword)(program, ctx);
|
|
34
38
|
(0, cbom_1.registerCbom)(program, ctx);
|
|
39
|
+
(0, stream_1.registerStream)(program, ctx);
|
|
40
|
+
(0, opaque_1.registerOpaque)(program, ctx);
|
|
41
|
+
(0, hpke_1.registerHpke)(program, ctx);
|
|
42
|
+
(0, kms_1.registerKms)(program, ctx);
|
|
35
43
|
return program;
|
|
36
44
|
};
|
|
37
45
|
exports.buildProgram = buildProgram;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { type KmsProvider } from "@sebastienrousseau/crypto-kms";
|
|
3
|
+
import { type RunContext } from "./io";
|
|
4
|
+
export declare function registerCliKmsProvider(name: string, provider: KmsProvider): void;
|
|
5
|
+
export declare function resetCliKmsProviders(): void;
|
|
6
|
+
export declare function resolveCliKmsProvider(name?: string): KmsProvider;
|
|
7
|
+
export declare function registerKms(program: Command, ctx: RunContext): void;
|
|
8
|
+
//# sourceMappingURL=kms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms.d.ts","sourceRoot":"","sources":["../../src/program/kms.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAM1E,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,WAAW,GACpB,IAAI,CAEN;AAGD,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C;AA+CD,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAQhE;AAkQD,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,CASnE"}
|