node-forge 0.7.2 → 0.7.6
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/CHANGELOG.md +27 -0
- package/README.md +92 -2
- package/dist/forge.all.min.js +1 -1
- package/dist/forge.min.js +1 -1
- package/lib/baseN.js +186 -0
- package/lib/ed25519.js +996 -0
- package/lib/form.js +1 -1
- package/lib/index.js +1 -0
- package/lib/pkcs7.js +30 -16
- package/lib/util.js +36 -15
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
Forge ChangeLog
|
|
2
2
|
===============
|
|
3
3
|
|
|
4
|
+
## 0.7.6 - 2018-08-14
|
|
5
|
+
|
|
6
|
+
### Added
|
|
7
|
+
- Test on Node.js 10.x.
|
|
8
|
+
- Support for PKCS#7 detached signatures.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Improve webpack/browser detection.
|
|
12
|
+
|
|
13
|
+
## 0.7.5 - 2018-03-30
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- Remove use of `const`.
|
|
17
|
+
|
|
18
|
+
## 0.7.4 - 2018-03-07
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- Potential regex denial of service in form.js.
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- Support for ED25519.
|
|
25
|
+
- Support for baseN/base58.
|
|
26
|
+
|
|
27
|
+
## 0.7.3 - 2018-03-05
|
|
28
|
+
|
|
29
|
+
- Re-publish with npm 5.6.0 due to file timestamp issues.
|
|
30
|
+
|
|
4
31
|
## 0.7.2 - 2018-02-27
|
|
5
32
|
|
|
6
33
|
### Added
|
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ Documentation
|
|
|
53
53
|
|
|
54
54
|
### PKI
|
|
55
55
|
|
|
56
|
+
* [ED25519](#ed25519)
|
|
56
57
|
* [RSA](#rsa)
|
|
57
58
|
* [RSA-KEM](#rsakem)
|
|
58
59
|
* [X.509](#x509)
|
|
@@ -863,8 +864,92 @@ console.log(cipher.output.toHex());
|
|
|
863
864
|
PKI
|
|
864
865
|
---
|
|
865
866
|
|
|
866
|
-
Provides [X.509][] certificate
|
|
867
|
-
|
|
867
|
+
Provides [X.509][] certificate support, ED25519 key generation and
|
|
868
|
+
signing/verifying, and RSA public and private key encoding, decoding,
|
|
869
|
+
encryption/decryption, and signing/verifying.
|
|
870
|
+
|
|
871
|
+
<a name="ed25519" />
|
|
872
|
+
|
|
873
|
+
### ED25519
|
|
874
|
+
|
|
875
|
+
Special thanks to [TweetNaCl.js][] for providing the bulk of the implementation.
|
|
876
|
+
|
|
877
|
+
__Examples__
|
|
878
|
+
|
|
879
|
+
```js
|
|
880
|
+
var ed25519 = forge.pki.ed25519;
|
|
881
|
+
|
|
882
|
+
// generate a random ED25519 keypair
|
|
883
|
+
var keypair = ed25519.generateKeyPair();
|
|
884
|
+
// `keypair.publicKey` is a node.js Buffer or Uint8Array
|
|
885
|
+
// `keypair.privateKey` is a node.js Buffer or Uint8Array
|
|
886
|
+
|
|
887
|
+
// generate a random ED25519 keypair based on a random 32-byte seed
|
|
888
|
+
var seed = forge.random.getBytesSync(32);
|
|
889
|
+
var keypair = ed25519.generateKeyPair({seed: seed});
|
|
890
|
+
|
|
891
|
+
// generate a random ED25519 keypair based on a "password" 32-byte seed
|
|
892
|
+
var password = 'Mai9ohgh6ahxee0jutheew0pungoozil';
|
|
893
|
+
var seed = new forge.util.ByteBuffer(password, 'utf8');
|
|
894
|
+
var keypair = ed25519.generateKeyPair({seed: seed});
|
|
895
|
+
|
|
896
|
+
// sign a UTF-8 message
|
|
897
|
+
var signature = ED25519.sign({
|
|
898
|
+
message: 'test',
|
|
899
|
+
// also accepts `binary` if you want to pass a binary string
|
|
900
|
+
encoding: 'utf8',
|
|
901
|
+
// node.js Buffer, Uint8Array, forge ByteBuffer, binary string
|
|
902
|
+
privateKey: privateKey
|
|
903
|
+
});
|
|
904
|
+
// `signature` is a node.js Buffer or Uint8Array
|
|
905
|
+
|
|
906
|
+
// sign a message passed as a buffer
|
|
907
|
+
var signature = ED25519.sign({
|
|
908
|
+
// also accepts a forge ByteBuffer or Uint8Array
|
|
909
|
+
message: new Buffer('test', 'utf8'),
|
|
910
|
+
privateKey: privateKey
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
// sign a message digest (shorter "message" == better performance)
|
|
914
|
+
var md = forge.md.sha256.create();
|
|
915
|
+
md.update('test', 'utf8');
|
|
916
|
+
var signature = ED25519.sign({
|
|
917
|
+
md: md,
|
|
918
|
+
privateKey: privateKey
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
// verify a signature on a UTF-8 message
|
|
922
|
+
var verified = ED25519.verify({
|
|
923
|
+
message: 'test',
|
|
924
|
+
encoding: 'utf8',
|
|
925
|
+
// node.js Buffer, Uint8Array, forge ByteBuffer, or binary string
|
|
926
|
+
signature: signature,
|
|
927
|
+
// node.js Buffer, Uint8Array, forge ByteBuffer, or binary string
|
|
928
|
+
publicKey: publicKey
|
|
929
|
+
});
|
|
930
|
+
// `verified` is true/false
|
|
931
|
+
|
|
932
|
+
// sign a message passed as a buffer
|
|
933
|
+
var verified = ED25519.verify({
|
|
934
|
+
// also accepts a forge ByteBuffer or Uint8Array
|
|
935
|
+
message: new Buffer('test', 'utf8'),
|
|
936
|
+
// node.js Buffer, Uint8Array, forge ByteBuffer, or binary string
|
|
937
|
+
signature: signature,
|
|
938
|
+
// node.js Buffer, Uint8Array, forge ByteBuffer, or binary string
|
|
939
|
+
publicKey: publicKey
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
// verify a signature on a message digest
|
|
943
|
+
var md = forge.md.sha256.create();
|
|
944
|
+
md.update('test', 'utf8');
|
|
945
|
+
var verified = ED25519.verify({
|
|
946
|
+
md: md,
|
|
947
|
+
// node.js Buffer, Uint8Array, forge ByteBuffer, or binary string
|
|
948
|
+
signature: signature,
|
|
949
|
+
// node.js Buffer, Uint8Array, forge ByteBuffer, or binary string
|
|
950
|
+
publicKey: publicKey
|
|
951
|
+
});
|
|
952
|
+
```
|
|
868
953
|
|
|
869
954
|
<a name="rsa" />
|
|
870
955
|
|
|
@@ -1293,6 +1378,10 @@ p7.addSigner({
|
|
|
1293
1378
|
p7.sign();
|
|
1294
1379
|
var pem = forge.pkcs7.messageToPem(p7);
|
|
1295
1380
|
|
|
1381
|
+
// PKCS#7 Sign in detached mode.
|
|
1382
|
+
// Includes the signature and certificate without the signed data.
|
|
1383
|
+
p7.sign({detached: true});
|
|
1384
|
+
|
|
1296
1385
|
```
|
|
1297
1386
|
|
|
1298
1387
|
<a name="pkcs8" />
|
|
@@ -2007,3 +2096,4 @@ Financial support is welcome and helps contribute to futher development:
|
|
|
2007
2096
|
[freenode]: https://freenode.net/
|
|
2008
2097
|
[unpkg]: https://unpkg.com/
|
|
2009
2098
|
[webpack]: https://webpack.github.io/
|
|
2099
|
+
[TweetNaCl]: https://github.com/dchest/tweetnacl-js
|