Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct data corruption tests #613

Merged
merged 1 commit into from
Mar 27, 2020
Merged
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
14 changes: 7 additions & 7 deletions src/wrappers/themis/wasm/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('wasm-themis', function() {
})
it('detect data corruption', function() {
let key = new themis.KeyPair().privateKey
key[20] = 256 - key[20]
key[20] = ~key[20]
assert.throws(() => new themis.PrivateKey(key))
})
it('handles type mismatches', function() {
Expand Down Expand Up @@ -197,7 +197,7 @@ describe('wasm-themis', function() {
it('detects corrupted data', function() {
let cell = new themis.SecureCellSeal(masterKey1)
let encrypted = cell.encrypt(testInput)
encrypted[20] = 256 - encrypted[20]
encrypted[20] = ~encrypted[20]
assert.throws(() => cell.decrypt(encrypted),
expectError(ThemisErrorCode.FAIL)
)
Expand Down Expand Up @@ -299,15 +299,15 @@ describe('wasm-themis', function() {
it('detects corrupted data', function() {
let cell = new themis.SecureCellTokenProtect(masterKey1)
let result = cell.encrypt(testInput)
result.data[5] = 256 - result.data[5]
result.data[5] = ~result.data[5]
assert.throws(() => cell.decrypt(result.data, result.token),
expectError(ThemisErrorCode.FAIL)
)
})
it('detects corrupted token', function() {
let cell = new themis.SecureCellTokenProtect(masterKey1)
let result = cell.encrypt(testInput)
result.token[8] = 256 - result.token[8]
result.token[8] = ~result.token[8]
assert.throws(() => cell.decrypt(result.data, result.token),
expectError(ThemisErrorCode.FAIL)
)
Expand Down Expand Up @@ -380,7 +380,7 @@ describe('wasm-themis', function() {
it('does not detect corrupted data', function() {
let cell = new themis.SecureCellContextImprint(masterKey1)
let encrypted = cell.encrypt(testInput, testContext)
encrypted[5] = 256 - encrypted[5]
encrypted[5] = ~encrypted[5]
let decrypted = cell.decrypt(encrypted, testContext)
assert.notDeepStrictEqual(testInput, decrypted)
})
Expand Down Expand Up @@ -446,7 +446,7 @@ describe('wasm-themis', function() {
it('detects corrupted data', function() {
let secureMessage = new themis.SecureMessage(new themis.KeyPair())
let encrypted = secureMessage.encrypt(testInput)
encrypted[10] = 256 - encrypted[10]
encrypted[10] = ~encrypted[10]
assert.throws(() => secureMessage.decrypt(encrypted),
expectError(ThemisErrorCode.FAIL)
)
Expand Down Expand Up @@ -532,7 +532,7 @@ describe('wasm-themis', function() {
let signer = new themis.SecureMessageSign(keyPair.privateKey)
let verifier = new themis.SecureMessageVerify(keyPair.publicKey)
let signed = signer.sign(testInput)
signed[12] = 256 - signed[12]
signed[12] = ~signed[12]
assert.throws(() => verifier.verify(signed),
expectError(ThemisErrorCode.FAIL)
)
Expand Down