@@ -6,6 +6,10 @@ if (!common.hasCrypto) {
6
6
console . log ( '1..0 # Skipped: missing crypto' ) ;
7
7
return ;
8
8
}
9
+ if ( common . hasFipsCrypto ) {
10
+ console . log ( '1..0 # Skipped: not supported in FIPS mode' ) ;
11
+ return ;
12
+ }
9
13
var crypto = require ( 'crypto' ) ;
10
14
11
15
function testCipher1 ( key ) {
@@ -62,71 +66,12 @@ function testCipher2(key) {
62
66
assert . equal ( txt , plaintext , 'encryption and decryption with Base64' ) ;
63
67
}
64
68
65
-
66
- function testCipher3 ( key , iv ) {
67
- // Test encyrption and decryption with explicit key and iv
68
- var plaintext =
69
- '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
70
- 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
71
- 'jAfaFg**' ;
72
- var cipher = crypto . createCipheriv ( 'des-ede3-cbc' , key , iv ) ;
73
- var ciph = cipher . update ( plaintext , 'utf8' , 'hex' ) ;
74
- ciph += cipher . final ( 'hex' ) ;
75
-
76
- var decipher = crypto . createDecipheriv ( 'des-ede3-cbc' , key , iv ) ;
77
- var txt = decipher . update ( ciph , 'hex' , 'utf8' ) ;
78
- txt += decipher . final ( 'utf8' ) ;
79
-
80
- assert . equal ( txt , plaintext , 'encryption and decryption with key and iv' ) ;
81
-
82
- // streaming cipher interface
83
- // NB: In real life, it's not guaranteed that you can get all of it
84
- // in a single read() like this. But in this case, we know it's
85
- // quite small, so there's no harm.
86
- var cStream = crypto . createCipheriv ( 'des-ede3-cbc' , key , iv ) ;
87
- cStream . end ( plaintext ) ;
88
- ciph = cStream . read ( ) ;
89
-
90
- var dStream = crypto . createDecipheriv ( 'des-ede3-cbc' , key , iv ) ;
91
- dStream . end ( ciph ) ;
92
- txt = dStream . read ( ) . toString ( 'utf8' ) ;
93
-
94
- assert . equal ( txt , plaintext , 'streaming cipher iv' ) ;
95
- }
96
-
97
-
98
- function testCipher4 ( key , iv ) {
99
- // Test encyrption and decryption with explicit key and iv
100
- var plaintext =
101
- '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
102
- 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
103
- 'jAfaFg**' ;
104
- var cipher = crypto . createCipheriv ( 'des-ede3-cbc' , key , iv ) ;
105
- var ciph = cipher . update ( plaintext , 'utf8' , 'buffer' ) ;
106
- ciph = Buffer . concat ( [ ciph , cipher . final ( 'buffer' ) ] ) ;
107
-
108
- var decipher = crypto . createDecipheriv ( 'des-ede3-cbc' , key , iv ) ;
109
- var txt = decipher . update ( ciph , 'buffer' , 'utf8' ) ;
110
- txt += decipher . final ( 'utf8' ) ;
111
-
112
- assert . equal ( txt , plaintext , 'encryption and decryption with key and iv' ) ;
113
- }
114
-
115
-
116
69
testCipher1 ( 'MySecretKey123' ) ;
117
70
testCipher1 ( new Buffer ( 'MySecretKey123' ) ) ;
118
71
119
72
testCipher2 ( '0123456789abcdef' ) ;
120
73
testCipher2 ( new Buffer ( '0123456789abcdef' ) ) ;
121
74
122
- testCipher3 ( '0123456789abcd0123456789' , '12345678' ) ;
123
- testCipher3 ( '0123456789abcd0123456789' , new Buffer ( '12345678' ) ) ;
124
- testCipher3 ( new Buffer ( '0123456789abcd0123456789' ) , '12345678' ) ;
125
- testCipher3 ( new Buffer ( '0123456789abcd0123456789' ) , new Buffer ( '12345678' ) ) ;
126
-
127
- testCipher4 ( new Buffer ( '0123456789abcd0123456789' ) , new Buffer ( '12345678' ) ) ;
128
-
129
-
130
75
// Base64 padding regression test, see #4837.
131
76
( function ( ) {
132
77
var c = crypto . createCipher ( 'aes-256-cbc' , 'secret' ) ;
0 commit comments