(log, cb)
| 146 | |
| 147 | /* cb(err, cipherBundle, decipherBundle) */ |
| 148 | function _utestCreateBundlePair(log, cb) { |
| 149 | const algorithm = 'AES256'; |
| 150 | const headers = { |
| 151 | 'x-amz-scal-server-side-encryption': algorithm, |
| 152 | }; |
| 153 | const sseConfig = parseBucketEncryptionHeaders(headers); |
| 154 | KMS.bucketLevelEncryption( |
| 155 | dummyBucket, sseConfig, log, |
| 156 | (err, sseInfo) => { |
| 157 | if (err) { |
| 158 | cb(err); |
| 159 | return; |
| 160 | } |
| 161 | KMS.createCipherBundle( |
| 162 | sseInfo, log, (err, cipherBundle) => { |
| 163 | if (err) { |
| 164 | cb(err); |
| 165 | return; |
| 166 | } |
| 167 | const creatingSseInfo = sseInfo; |
| 168 | creatingSseInfo.cipheredDataKey = |
| 169 | Buffer.from(cipherBundle.cipheredDataKey, 'base64'); |
| 170 | KMS.createDecipherBundle( |
| 171 | sseInfo, 0, log, (err, decipherBundle) => { |
| 172 | if (err) { |
| 173 | cb(err); |
| 174 | return; |
| 175 | } |
| 176 | assert.strictEqual(typeof decipherBundle, |
| 177 | 'object'); |
| 178 | assert.strictEqual(decipherBundle.cryptoScheme, |
| 179 | cipherBundle.cryptoScheme); |
| 180 | assert.notEqual(decipherBundle.decipher, null); |
| 181 | cb(null, cipherBundle, decipherBundle); |
| 182 | }); |
| 183 | }); |
| 184 | }); |
| 185 | } |
| 186 | |
| 187 | it('should cipher and decipher a datastream', done => { |
| 188 | _utestCreateBundlePair(log, (err, cipherBundle, decipherBundle) => { |
no test coverage detected