Search in sources :

Example 6 with KeyType

use of co.krypt.krypton.crypto.KeyType 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);
    }
}
Also used : KeyType(co.krypt.krypton.crypto.KeyType) ByteArrayInputStream(java.io.ByteArrayInputStream) UserID(co.krypt.krypton.pgp.UserID) CertifiedPublicKey(co.krypt.krypton.pgp.publickey.CertifiedPublicKey) SSHKeyPairI(co.krypt.krypton.crypto.SSHKeyPairI) PGPPublicKey(co.krypt.krypton.pgp.PGPPublicKey) DataInputStream(java.io.DataInputStream) Test(org.junit.Test)

Aggregations

KeyType (co.krypt.krypton.crypto.KeyType)6 SSHKeyPairI (co.krypt.krypton.crypto.SSHKeyPairI)6 Test (org.junit.Test)5 Context (android.content.Context)4 RSAKeyManager (co.krypt.krypton.crypto.RSAKeyManager)2 Bundle (android.os.Bundle)1 Fragment (android.support.v4.app.Fragment)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 Analytics (co.krypt.krypton.analytics.Analytics)1 CryptoException (co.krypt.krypton.exception.CryptoException)1 MeStorage (co.krypt.krypton.me.MeStorage)1 PGPPublicKey (co.krypt.krypton.pgp.PGPPublicKey)1 UserID (co.krypt.krypton.pgp.UserID)1 CertifiedPublicKey (co.krypt.krypton.pgp.publickey.CertifiedPublicKey)1 Profile (co.krypt.krypton.protocol.Profile)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 InvalidKeyException (java.security.InvalidKeyException)1