@Test public void unpackKey() throws Exception { AbstractKey k1 = TestKeys.privateKey(3).getPublicKey(); AbstractKey kx = AbstractKey.fromBinder(k1.toBinder()); assertEquals(k1, kx); k1 = SymmetricKey.fromPassword("helluva", 4096); kx = AbstractKey.fromBinder(k1.toBinder()); assertEquals(k1, kx); k1 = TestKeys.privateKey(2); kx = AbstractKey.fromBinder(k1.toBinder()); assertEquals(k1, kx); }
public AbstractKey unpackKey(byte[] data) throws EncryptionError { switch (algorythm) { case RSAPublic: return new PublicKey(data, this); case RSAPrivate: return new PrivateKey(data, this); case AES256: return new SymmetricKey(data, this); } throw new EncryptionError("can't unpack key: " + this); }
KeyInfo { public AbstractKey unpackKey(byte[] data) throws EncryptionError { switch (algorythm) { case RSAPublic: return new PublicKey(data, this); case RSAPrivate: return new PrivateKey(data, this); case AES256: return new SymmetricKey(data, this); } throw new EncryptionError("can't unpack key: " + this); } }
KeyInfo { public AbstractKey unpackKey(byte[] data) throws EncryptionError { switch (algorythm) { case RSAPublic: return new PublicKey(data, this); case RSAPrivate: return new PrivateKey(data, this); case AES256: return new SymmetricKey(data, this); } throw new EncryptionError("can't unpack key: " + this); } KeyInfo(Algorythm algorythm, byte[] tag, int keyLength);  KeyInfo(Algorythm algorythm, byte[] tag);  KeyInfo(PRF PRF, int rounds, byte[] salt, byte[] tag);  KeyInfo(byte[] packedInfo); }
KeyInfo { public AbstractKey unpackKey(byte[] data) throws EncryptionError { switch (algorythm) { case RSAPublic: return new PublicKey(data, this); case RSAPrivate: return new PrivateKey(data, this); case AES256: return new SymmetricKey(data, this); } throw new EncryptionError("can't unpack key: " + this); } KeyInfo(Algorythm algorythm, byte[] tag, int keyLength);  KeyInfo(Algorythm algorythm, byte[] tag);  KeyInfo(PRF PRF, int rounds, byte[] salt, byte[] tag);  KeyInfo(byte[] packedInfo); byte[] getSalt(); boolean matchType(KeyInfo otherInfo); boolean matchType(AbstractKey otherKey); boolean matchTag(KeyInfo keyInfo); void setTag(byte[] tag); String getBase64Tag(); boolean isPassword(); byte[] getTag(); int getRounds(); Algorythm getAlgorythm(); PRF getPRF(); int getKeyLength(); byte[] pack(); SymmetricKey derivePassword(String password); AbstractKey unpackKey(byte[] data); @Override String toString(); }
KeyInfo { public AbstractKey unpackKey(byte[] data) throws EncryptionError { switch (algorythm) { case RSAPublic: return new PublicKey(data, this); case RSAPrivate: return new PrivateKey(data, this); case AES256: return new SymmetricKey(data, this); } throw new EncryptionError("can't unpack key: " + this); } KeyInfo(Algorythm algorythm, byte[] tag, int keyLength);  KeyInfo(Algorythm algorythm, byte[] tag);  KeyInfo(PRF PRF, int rounds, byte[] salt, byte[] tag);  KeyInfo(byte[] packedInfo); byte[] getSalt(); boolean matchType(KeyInfo otherInfo); boolean matchType(AbstractKey otherKey); boolean matchTag(KeyInfo keyInfo); void setTag(byte[] tag); String getBase64Tag(); boolean isPassword(); byte[] getTag(); int getRounds(); Algorythm getAlgorythm(); PRF getPRF(); int getKeyLength(); byte[] pack(); SymmetricKey derivePassword(String password); AbstractKey unpackKey(byte[] data); @Override String toString();  }