Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion modules/decrypt-browser/test/decrypt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

/* eslint-env mocha */

import { expect } from 'chai'
import * as chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { decrypt } from '../src/index'
import { AlgorithmSuiteIdentifier } from '@aws-crypto/material-management-browser'
import * as fixtures from './fixtures'
chai.use(chaiAsPromised)
const { expect } = chai

describe('decrypt', () => {
it('buffer', async () => {
Expand Down Expand Up @@ -52,4 +55,34 @@ describe('decrypt', () => {
}
)
})

it('verify incomplete chipertext will fail for an un-signed algorithm suite', async () => {
const data = fixtures.base64CiphertextAlgAes256GcmIv12Tag16HkdfWith4Frames()
const keyring = fixtures.decryptKeyring()

// First we make sure that the test vector is well formed
await decrypt(keyring, data)

// This is the real test:
// trying to decrypt
// on EVERY boundary
for (let i = 0; data.byteLength > i; i++) {
await expect(decrypt(keyring, data.slice(0, i))).to.rejectedWith(Error)
}
})

it('verify incomplete chipertext will fail for a signed algorithm suite', async () => {
const data = fixtures.base64CiphertextAlgAes256GcmIv12Tag16HkdfSha384EcdsaP384With4Frames()
const keyring = fixtures.decryptKeyring()

// First we make sure that the test vector is well formed
await decrypt(keyring, data)

// This is the real test:
// trying to decrypt
// on EVERY boundary
for (let i = 0; data.byteLength > i; i++) {
await expect(decrypt(keyring, data.slice(0, i))).to.rejectedWith(Error)
}
})
})
Loading