use of co.krypt.krypton.crypto.RSAKeyManager 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.RSAKeyManager 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));
}
}
}
}
Aggregations