use of co.krypt.krypton.crypto.SSHKeyPairI in project krypton-android by kryptco.
the class KeyManagerInstrumentedTest method keyGeneration_isIdempotent.
@Test
public void keyGeneration_isIdempotent() throws Exception {
final Context context = InstrumentationRegistry.getTargetContext();
for (KeyType type : SUPPORTED_KEY_TYPES) {
SSHKeyPairI key1 = KeyManager.loadOrGenerateKeyPair(context, type, "test");
SSHKeyPairI key2 = KeyManager.loadOrGenerateKeyPair(context, type, "test");
assertEquals(key1, key2);
}
}
use of co.krypt.krypton.crypto.SSHKeyPairI in project krypton-android by kryptco.
the class KeyManagerInstrumentedTest method signTamperAndVerify_fails.
@Test
public void signTamperAndVerify_fails() throws Exception {
final Context context = InstrumentationRegistry.getTargetContext();
for (KeyType type : SUPPORTED_KEY_TYPES) {
for (SSHKeyPairI key : new SSHKeyPairI[] { KeyManager.loadOrGenerateKeyPair(context, type, "test"), new RSAKeyManager(context).loadOrGenerateNoDigestKeyPair("testnodigest") }) {
byte[] data = SecureRandom.getSeed(32);
for (String digest : SUPPORTED_DIGESTS) {
byte[] signature = key.signDigest(digest, data);
signature[signature.length - 1] ^= 0x01;
assertTrue(!key.verifyDigest(digest, signature, data));
}
}
}
}
use of co.krypt.krypton.crypto.SSHKeyPairI in project krypton-android by kryptco.
the class KeyManagerInstrumentedTest method signAndVerify_succeed.
@Test
public void signAndVerify_succeed() throws Exception {
final Context context = InstrumentationRegistry.getTargetContext();
for (KeyType type : SUPPORTED_KEY_TYPES) {
for (SSHKeyPairI key : new SSHKeyPairI[] { KeyManager.loadOrGenerateKeyPair(context, type, "test"), new RSAKeyManager(context).loadOrGenerateNoDigestKeyPair("testnodigest") }) {
byte[] data = SecureRandom.getSeed(32);
for (String digest : SUPPORTED_DIGESTS) {
byte[] signature = key.signDigest(digest, data);
assertTrue(key.verifyDigest(digest, signature, data));
}
}
}
}
use of co.krypt.krypton.crypto.SSHKeyPairI in project krypton-android by kryptco.
the class PGPublicKeySelfCertificationTest method keySigning_succeeds.
@Test
public void keySigning_succeeds() throws Exception {
for (KeyType keyType : new KeyType[] { KeyType.RSA, KeyType.Ed25519 }) {
SSHKeyPairI kp1 = KeyManager.loadOrGenerateKeyPair(InstrumentationRegistry.getTargetContext(), keyType, "test");
PGPPublicKey pubkey = new PGPPublicKey(kp1, Collections.singletonList(new UserID("Kevin King", "kevin@krypt.co")));
CertifiedPublicKey parsedPubkey = CertifiedPublicKey.parse(new DataInputStream(new ByteArrayInputStream(pubkey.serializedBytes())));
Assert.assertTrue(pubkey.signedIdentities.size() == parsedPubkey.identities.size());
Assert.assertFalse(pubkey.signedIdentities.get(0).signature.attributes.attributes.unhashedSubpackets.issuer.header.type.critical);
}
}
Aggregations