use of co.krypt.krypton.pgp.publickey.CertifiedPublicKey in project krypton-android by kryptco.
the class PGPPublicKeyTest method publicKey3_parses.
@Test
public void publicKey3_parses() throws Exception {
CertifiedPublicKey pk = CertifiedPublicKey.parse(new DataInputStream(new ByteArrayInputStream(AsciiArmor.parse(testPubKey3).data)));
Assert.assertTrue(pk.publicKeyPacket.attributes.algorithm == PublicKeyAlgorithm.ED25519);
Assert.assertTrue(pk.identities.size() == 1);
Assert.assertTrue(pk.identities.get(0).second.size() == 1);
}
use of co.krypt.krypton.pgp.publickey.CertifiedPublicKey in project krypton-android by kryptco.
the class PGPSignatureTest method signedPublicKeyHashPrefixAndReserializedBytes_match.
@Test
public void signedPublicKeyHashPrefixAndReserializedBytes_match() throws Exception {
byte[] signedKeyData = AsciiArmor.parse(testPubKey2).data;
CertifiedPublicKey pk = CertifiedPublicKey.parse(new DataInputStream(new ByteArrayInputStream(signedKeyData)));
SignatureAttributesWithoutHashPrefix att = pk.identities.get(0).second.get(0).attributes.attributes;
UnsignedPublicKeySelfCertification certification = new UnsignedPublicKeySelfCertification(pk.publicKeyPacket, pk.identities.get(0).first.userID, att.getHashAlgorithm(), att.hashedSubpackets.created.created, // this pubkey has no flags
null);
Assert.assertTrue(SignableUtils.hashPrefix(att.hashAlgorithm, certification) == pk.identities.get(0).second.get(0).attributes.hashPrefix);
ByteArrayOutputStream reserialized = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(reserialized);
pk.publicKeyPacket.serialize(out);
pk.identities.get(0).first.serialize(out);
pk.identities.get(0).second.get(0).serialize(out);
out.close();
Assert.assertTrue(Arrays.equals(reserialized.toByteArray(), signedKeyData));
}
use of co.krypt.krypton.pgp.publickey.CertifiedPublicKey in project krypton-android by kryptco.
the class PGPPublicKeyTest method publicKey1_parses.
@Test
public void publicKey1_parses() throws Exception {
CertifiedPublicKey pk = CertifiedPublicKey.parse(new DataInputStream(new ByteArrayInputStream(AsciiArmor.parse(testPubKey1).data)));
Assert.assertTrue(pk.publicKeyPacket.attributes.algorithm == PublicKeyAlgorithm.RSA_ENCRYPT_OR_SIGN);
Assert.assertTrue(pk.identities.size() == 1);
Assert.assertTrue(pk.identities.get(0).second.size() == 2);
Assert.assertTrue(Arrays.equals(pk.publicKeyPacket.fingerprint(), Base16.decode("F7A83D5CE65C42817A4AB7647A1037F5EF07891E")));
long keyID = pk.publicKeyPacket.keyID();
ByteArrayOutputStream keyIDBuf = new ByteArrayOutputStream();
DataOutputStream keyIDOut = new DataOutputStream(keyIDBuf);
keyIDOut.writeLong(keyID);
keyIDOut.close();
Assert.assertTrue(Arrays.equals(keyIDBuf.toByteArray(), Base16.decode("7A1037F5EF07891E")));
}
use of co.krypt.krypton.pgp.publickey.CertifiedPublicKey in project krypton-android by kryptco.
the class PGPPublicKeyTest method publicKey2_parses.
@Test
public void publicKey2_parses() throws Exception {
CertifiedPublicKey pk = CertifiedPublicKey.parse(new DataInputStream(new ByteArrayInputStream(AsciiArmor.parse(testPubKey2).data)));
Assert.assertTrue(pk.publicKeyPacket.attributes.algorithm == PublicKeyAlgorithm.RSA_SIGN_ONLY);
Assert.assertTrue(pk.identities.size() == 1);
Assert.assertTrue(pk.identities.get(0).second.size() == 1);
}
use of co.krypt.krypton.pgp.publickey.CertifiedPublicKey in project krypton-android by kryptco.
the class PGPPublicKeyTest method publicKey4_pkUserIDAndIncompleteSignature_parsesPartialIdentity.
@Test
public void publicKey4_pkUserIDAndIncompleteSignature_parsesPartialIdentity() throws Exception {
CertifiedPublicKey pk = CertifiedPublicKey.parse(new DataInputStream(new ByteArrayInputStream(AsciiArmor.parse(testPubKey4).data)));
Assert.assertTrue(pk.publicKeyPacket.attributes.algorithm == PublicKeyAlgorithm.ED25519);
Assert.assertTrue(pk.identities.size() == 1);
Assert.assertTrue(pk.identities.get(0).second.size() == 0);
}
Aggregations