@@ -14,7 +14,7 @@ define(function(require) {
14
14
keySize = 512 ,
15
15
keyId = 'F6F60E9B42CDFF4C' ,
16
16
pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n' +
17
- 'Version: OpenPGP.js v0.7.1 \r\n' +
17
+ 'Version: OpenPGP.js v0.7.2 \r\n' +
18
18
'Comment: Whiteout Mail - https://whiteout.io\r\n' +
19
19
'\r\n' +
20
20
'xk0EUlhMvAEB/2MZtCUOAYvyLFjDp3OBMGn3Ev8FwjzyPbIF0JUw+L7y2XR5\r\n' +
@@ -25,7 +25,7 @@ define(function(require) {
25
25
'=6XMW\r\n' +
26
26
'-----END PGP PUBLIC KEY BLOCK-----\r\n\r\n' ,
27
27
privkey = '-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n' +
28
- 'Version: OpenPGP.js v0.7.1 \r\n' +
28
+ 'Version: OpenPGP.js v0.7.2 \r\n' +
29
29
'Comment: Whiteout Mail - https://whiteout.io\r\n' +
30
30
'\r\n' +
31
31
'xcBeBFJYTLwBAf9jGbQlDgGL8ixYw6dzgTBp9xL/BcI88j2yBdCVMPi+8tl0\r\n' +
@@ -80,7 +80,27 @@ define(function(require) {
80
80
expect ( keys . keyId ) . to . exist ;
81
81
expect ( keys . privateKeyArmored ) . to . exist ;
82
82
expect ( keys . publicKeyArmored ) . to . exist ;
83
- done ( ) ;
83
+
84
+ // test encrypt/decrypt
85
+ pgp . importKeys ( {
86
+ passphrase : passphrase ,
87
+ privateKeyArmored : keys . privateKeyArmored ,
88
+ publicKeyArmored : keys . publicKeyArmored
89
+ } , function ( err ) {
90
+ expect ( err ) . to . not . exist ;
91
+
92
+ pgp . encrypt ( 'secret' , [ keys . publicKeyArmored ] , function ( err , ct ) {
93
+ expect ( err ) . to . not . exist ;
94
+ expect ( ct ) . to . exist ;
95
+
96
+ pgp . decrypt ( ct , keys . publicKeyArmored , function ( err , pt , signValid ) {
97
+ expect ( err ) . to . not . exist ;
98
+ expect ( pt ) . to . equal ( 'secret' ) ;
99
+ expect ( signValid ) . to . be . true ;
100
+ done ( ) ;
101
+ } ) ;
102
+ } ) ;
103
+ } ) ;
84
104
} ) ;
85
105
} ) ;
86
106
it ( 'should work without passphrase' , function ( done ) {
@@ -93,7 +113,27 @@ define(function(require) {
93
113
expect ( keys . keyId ) . to . exist ;
94
114
expect ( keys . privateKeyArmored ) . to . exist ;
95
115
expect ( keys . publicKeyArmored ) . to . exist ;
96
- done ( ) ;
116
+
117
+ // test encrypt/decrypt
118
+ pgp . importKeys ( {
119
+ passphrase : undefined ,
120
+ privateKeyArmored : keys . privateKeyArmored ,
121
+ publicKeyArmored : keys . publicKeyArmored
122
+ } , function ( err ) {
123
+ expect ( err ) . to . not . exist ;
124
+
125
+ pgp . encrypt ( 'secret' , [ keys . publicKeyArmored ] , function ( err , ct ) {
126
+ expect ( err ) . to . not . exist ;
127
+ expect ( ct ) . to . exist ;
128
+
129
+ pgp . decrypt ( ct , keys . publicKeyArmored , function ( err , pt , signValid ) {
130
+ expect ( err ) . to . not . exist ;
131
+ expect ( pt ) . to . equal ( 'secret' ) ;
132
+ expect ( signValid ) . to . be . true ;
133
+ done ( ) ;
134
+ } ) ;
135
+ } ) ;
136
+ } ) ;
97
137
} ) ;
98
138
} ) ;
99
139
} ) ;
0 commit comments