Search in sources :

Example 6 with CertifiedPublicKey

use of co.krypt.krypton.pgp.publickey.CertifiedPublicKey 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

CertifiedPublicKey (co.krypt.krypton.pgp.publickey.CertifiedPublicKey)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DataInputStream (java.io.DataInputStream)6 Test (org.junit.Test)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataOutputStream (java.io.DataOutputStream)2 KeyType (co.krypt.krypton.crypto.KeyType)1 SSHKeyPairI (co.krypt.krypton.crypto.SSHKeyPairI)1 PGPPublicKey (co.krypt.krypton.pgp.PGPPublicKey)1 UserID (co.krypt.krypton.pgp.UserID)1 SignatureAttributesWithoutHashPrefix (co.krypt.krypton.pgp.packet.SignatureAttributesWithoutHashPrefix)1 UnsignedPublicKeySelfCertification (co.krypt.krypton.pgp.publickey.UnsignedPublicKeySelfCertification)1