@Test public void packKdf() throws Exception { KeyInfo h1 = new KeyInfo(KeyInfo.PRF.HMAC_SHA256, 4096, null, null); KeyInfo h2 = new KeyInfo(h1.pack()); assertEquals(h1.getAlgorythm(), h2.getAlgorythm()); assertEquals(h1.getPRF(), h2.getPRF()); assertEquals(h1.getRounds(), h2.getRounds()); assertEquals(h1.getKeyLength(), h2.getKeyLength()); assertEquals(KeyInfo.PRF.HMAC_SHA256, h2.getPRF()); assertEquals(KeyInfo.Algorythm.AES256, h2.getAlgorythm()); assertArrayEquals(h1.getTag(), h2.getTag()); }
@Test public void symmetricKeyMustHaveRightInfo() { SymmetricKey k = new SymmetricKey(); KeyInfo h = k.info(); assertEquals(KeyInfo.Algorythm.AES256, h.getAlgorythm()); assertEquals(32, h.getKeyLength()); assertEquals(KeyInfo.PRF.None, h.getPRF()); }
@Test public void publicKeyMustHaveInfo() throws Exception { AbstractKey k = TestKeys.privateKey(3).getPublicKey(); KeyInfo h = k.info(); assertEquals(KeyInfo.Algorythm.RSAPublic, h.getAlgorythm()); assertEquals(KeyInfo.PRF.None, h.getPRF()); assertEquals(5, h.getTag().length); // Bytes.dump(h.pack()); }
KeyInfo h2 = new KeyInfo(h1.pack()); assertEquals(h1.getAlgorythm(), h2.getAlgorythm()); assertEquals(h1.getPRF(), h2.getPRF()); assertEquals(h1.getRounds(), h2.getRounds()); assertEquals(h1.getKeyLength(), h2.getKeyLength()); assertEquals(KeyInfo.PRF.None, h2.getPRF()); assertEquals(KeyInfo.Algorythm.RSAPublic, h2.getAlgorythm()); h2 = new KeyInfo(h1.pack()); assertEquals(h1.getAlgorythm(), h2.getAlgorythm()); assertEquals(h1.getPRF(), h2.getPRF()); assertEquals(h1.getRounds(), h2.getRounds()); assertEquals(h1.getKeyLength(), h2.getKeyLength()); assertEquals(KeyInfo.PRF.None, h2.getPRF()); assertEquals(KeyInfo.Algorythm.RSAPrivate, h2.getAlgorythm()); h2 = new KeyInfo(h1.pack()); assertEquals(h1.getAlgorythm(), h2.getAlgorythm()); assertEquals(h1.getPRF(), h2.getPRF()); assertEquals(h1.getRounds(), h2.getRounds()); assertEquals(h1.getKeyLength(), h2.getKeyLength()); assertEquals(KeyInfo.PRF.None, h2.getPRF()); assertEquals(KeyInfo.Algorythm.AES256, h2.getAlgorythm());
@Test public void privateKeyMustHaveInfo() throws Exception { AbstractKey prk = TestKeys.privateKey(3); AbstractKey puk = prk.getPublicKey(); KeyInfo h = prk.info(); assertEquals(KeyInfo.Algorythm.RSAPrivate, h.getAlgorythm()); assertEquals(KeyInfo.PRF.None, h.getPRF()); assertEquals(5, h.getTag().length); assertArrayEquals(puk.info().getTag(), h.getTag()); // Bytes.dump(h.pack()); }