-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added test for CryptoKeyPairHandle generation
This test is currently failing due to an issue in rs-crypto-node
- Loading branch information
1 parent
fba214d
commit d602cad
Showing
2 changed files
with
60 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import { CryptoSignatures } from "@nmshd/crypto"; | ||
import { KeyPairSpec } from "@nmshd/rs-crypto-types"; | ||
import { expect } from "chai"; | ||
import { CryptoSignatureKeypairHandle } from "src/crypto-layer/signature/CryptoSignatureKeypair"; | ||
import { CryptoSignaturePrivateKeyHandle } from "src/crypto-layer/signature/CryptoSignaturePrivateKeyHandle"; | ||
import { CryptoSignaturePublicKeyHandle } from "src/crypto-layer/signature/CryptoSignaturePublicKeyHandle"; | ||
|
||
export class CryptoSignatureKeypairHandleTest { | ||
public static run(): void { | ||
describe("CryptoSignatureKeypairHandle", function () { | ||
describe("generateKeyPairHandle() SoftwareProvider", function () { | ||
it("generateKeyPairHandle() with P256", async function () { | ||
const spec: KeyPairSpec = { | ||
asym_spec: "P256", | ||
cipher: null, | ||
signing_hash: "Sha2_512", | ||
ephemeral: false, | ||
non_exportable: false | ||
}; | ||
const cryptoKeyPairHandle = await CryptoSignatures.generateKeypairHandle( | ||
{ providerName: "SoftwareProvider" }, | ||
spec | ||
); | ||
expect(cryptoKeyPairHandle).to.exist; | ||
expect(cryptoKeyPairHandle).to.be.instanceOf(CryptoSignatureKeypairHandle); | ||
expect(cryptoKeyPairHandle.privateKey).to.exist; | ||
expect(cryptoKeyPairHandle.publicKey).to.exist; | ||
expect(cryptoKeyPairHandle.privateKey).to.be.instanceOf(CryptoSignaturePrivateKeyHandle); | ||
expect(cryptoKeyPairHandle.publicKey).to.be.instanceOf(CryptoSignaturePublicKeyHandle); | ||
expect(cryptoKeyPairHandle.privateKey.keyPairHandle).to.exist; | ||
expect(cryptoKeyPairHandle.publicKey.keyPairHandle).to.exist; | ||
expect(cryptoKeyPairHandle.privateKey.keyPairHandle).to.be.equal( | ||
cryptoKeyPairHandle.publicKey.keyPairHandle | ||
); | ||
expect(cryptoKeyPairHandle.privateKey.id).to.exist; | ||
expect(cryptoKeyPairHandle.publicKey.id).to.exist; | ||
expect(cryptoKeyPairHandle.privateKey.id).to.be.string(cryptoKeyPairHandle.publicKey.id); | ||
expect(cryptoKeyPairHandle.privateKey.provider).to.exist; | ||
expect(cryptoKeyPairHandle.publicKey.provider).to.exist; | ||
expect(cryptoKeyPairHandle.privateKey.provider).to.equal(cryptoKeyPairHandle.publicKey.provider); | ||
expect(cryptoKeyPairHandle.privateKey.providerName).to.exist; | ||
expect(cryptoKeyPairHandle.publicKey.providerName).to.exist; | ||
expect(cryptoKeyPairHandle.privateKey.providerName).to.be.string( | ||
cryptoKeyPairHandle.publicKey.providerName | ||
); | ||
expect(cryptoKeyPairHandle.privateKey.providerName).to.be.string("SoftwareProvider"); | ||
expect(await cryptoKeyPairHandle.privateKey.keyPairHandle.id()).to.be.string( | ||
cryptoKeyPairHandle.privateKey.id | ||
); | ||
expect(await cryptoKeyPairHandle.publicKey.keyPairHandle.id()).to.be.string( | ||
cryptoKeyPairHandle.publicKey.id | ||
); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
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