|
3 | 3 |
|
4 | 4 | /* eslint-env mocha */
|
5 | 5 |
|
6 |
| -import { expect } from 'chai' |
| 6 | +import * as chai from 'chai' |
| 7 | +import chaiAsPromised from 'chai-as-promised' |
7 | 8 | import { decrypt } from '../src/index'
|
8 | 9 | import { AlgorithmSuiteIdentifier } from '@aws-crypto/material-management-browser'
|
9 | 10 | import * as fixtures from './fixtures'
|
| 11 | +chai.use(chaiAsPromised) |
| 12 | +const { expect } = chai |
10 | 13 |
|
11 | 14 | describe('decrypt', () => {
|
12 | 15 | it('buffer', async () => {
|
@@ -52,4 +55,34 @@ describe('decrypt', () => {
|
52 | 55 | }
|
53 | 56 | )
|
54 | 57 | })
|
| 58 | + |
| 59 | + it('verify incomplete chipertext will fail for an un-signed algorithm suite', async () => { |
| 60 | + const data = fixtures.base64CiphertextAlgAes256GcmIv12Tag16HkdfWith4Frames() |
| 61 | + const keyring = fixtures.decryptKeyring() |
| 62 | + |
| 63 | + // First we make sure that the test vector is well formed |
| 64 | + await decrypt(keyring, data) |
| 65 | + |
| 66 | + // This is the real test: |
| 67 | + // trying to decrypt |
| 68 | + // on EVERY boundary |
| 69 | + for (let i = 0; data.byteLength > i; i++) { |
| 70 | + await expect(decrypt(keyring, data.slice(0, i))).to.rejectedWith(Error) |
| 71 | + } |
| 72 | + }) |
| 73 | + |
| 74 | + it('verify incomplete chipertext will fail for a signed algorithm suite', async () => { |
| 75 | + const data = fixtures.base64CiphertextAlgAes256GcmIv12Tag16HkdfSha384EcdsaP384With4Frames() |
| 76 | + const keyring = fixtures.decryptKeyring() |
| 77 | + |
| 78 | + // First we make sure that the test vector is well formed |
| 79 | + await decrypt(keyring, data) |
| 80 | + |
| 81 | + // This is the real test: |
| 82 | + // trying to decrypt |
| 83 | + // on EVERY boundary |
| 84 | + for (let i = 0; data.byteLength > i; i++) { |
| 85 | + await expect(decrypt(keyring, data.slice(0, i))).to.rejectedWith(Error) |
| 86 | + } |
| 87 | + }) |
55 | 88 | })
|
0 commit comments