node-forge 0.7.3 → 0.7.4

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 CHANGED
@@ -1,6 +1,15 @@
1
1
  Forge ChangeLog
2
2
  ===============
3
3
 
4
+ ## 0.7.4 - 2018-03-07
5
+
6
+ ### Fixed
7
+ - Potential regex denial of service in form.js.
8
+
9
+ ### Added
10
+ - Support for ED25519.
11
+ - Support for baseN/base58.
12
+
4
13
  ## 0.7.3 - 2018-03-05
5
14
 
6
15
  - Re-publish with npm 5.6.0 due to file timestamp issues.
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 and RSA public and private key encoding,
867
- decoding, encryption/decryption, and signing/verifying.
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
 
@@ -2007,3 +2092,4 @@ Financial support is welcome and helps contribute to futher development:
2007
2092
  [freenode]: https://freenode.net/
2008
2093
  [unpkg]: https://unpkg.com/
2009
2094
  [webpack]: https://webpack.github.io/
2095
+ [TweetNaCl]: https://github.com/dchest/tweetnacl-js