Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89e5138
commit 4f7e2e6
Showing
5 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {PublicKey} from '../../src/crypto-wrapper' | ||
|
||
describe('test public key with stuff from production', () => { | ||
|
||
it('public key from base 64 from production', done => { | ||
let base64 = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk9Qnk67zh6zSre5n7qx+55q1plaTKgwZMLo00gE6gTf4n1jJPBCmifIqdCAxSVP1bQK4LTcHwsERDki1LWsk76bGKna73PFxkSO6AqOlggPxaMHc5B/zVaY4zDfPokRfui6Cy4/2k2WtOwnk2Jr0dMt/x15521EP7MNmRreobfTKt69dshkbhmU3WNrIrV/qYqVYjqj1dsDdHL6Cj4Euv5uA31y1VY/cMuEtOoq/POQ+SNYddgIP3ThPvFmNF/cHdpqN/E9OsXrctCettTvPXhD6J8OCM9ft2dlQle/dcuz+RY7mVynts4+ksMnICT5aHsaRX5TSEaEjGbAUi3WZUwIDAQAB' | ||
PublicKey.fromBase64(base64).then(_ => { | ||
done() | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {SymmetricKey} from '../../src/SymmetricKey' | ||
import {WebCryptoConfig} from '../../src/config/WebCryptoConfig' | ||
import {extractable} from './../CryptoKeyAssertions' | ||
import {SymmetricKeyConfigBuilder} from '../../src/config/SymmetricKeyConfig' | ||
import {SymmetricKeyDerivationConfigBuilder} from '../../src/config/SymmetricKeyDerivationConfig' | ||
import {KeyAlgorithm} from '../../src/config/KeyAlgorithm' | ||
import {PrivateKeyBase64, publicKeyBase64, symKeyBase64} from './../testData/Keys' | ||
import { | ||
ArrayBufferWithBinaryDataToBase64, ArrayBufferWithBinaryDataToString, Base64WithBinaryDataToArrayBuffer | ||
} from '@esentri/transformer-functions' | ||
import {Array1000Byte, Array100Byte} from './../testData/ArraysForEncryption' | ||
import {ArrayBufferEqual} from './../content/ArrayBufferFunctions' | ||
import * as fs from 'fs' | ||
import {InitializationVector, PrivateKey, PublicKey, WrappedKeyDeserialize, WrappedKeySerialize} from '../../src/crypto-wrapper' | ||
import {test} from 'shelljs' | ||
|
||
describe('test symmetric key with stuff from production', () => { | ||
|
||
it('private key (un)wrapping with symmetric key and (de)serialization', done => { | ||
PrivateKey.fromBase64(PrivateKeyBase64).then(privateKey => { | ||
SymmetricKey.fromPassword('hello world').then(symKey => { | ||
symKey.wrapKey(privateKey).then(wrappedPrivateKey => { | ||
WrappedKeySerialize(wrappedPrivateKey).then(serializedWrappedPrivateKey => { | ||
WrappedKeyDeserialize(serializedWrappedPrivateKey).then(deserializedWrappedPrivateKey => { | ||
symKey.unwrapPrivateKey( | ||
deserializedWrappedPrivateKey.base64, | ||
deserializedWrappedPrivateKey.vector!!, | ||
deserializedWrappedPrivateKey.config | ||
).then(unwrappedPrivateKey => { | ||
unwrappedPrivateKey.extractKey().then(extractedUnwrappedPrivateKey => { | ||
privateKey.extractKey().then(extractedPrivateKey => { | ||
expect(extractedUnwrappedPrivateKey).toEqual(extractedPrivateKey) | ||
expect(unwrappedPrivateKey.keyConfig()).toEqual(privateKey.keyConfig()) | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
}) |