Package com.securityinnovation.jNeo.ntruencrypt

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey.decrypt()


            // Do encryption
            ByteArrayInputStream prng = new ByteArrayInputStream(tests[t].b);
            byte ciphertext[] = keys.encrypt(tests[t].m, prng);

            byte m[] = keys.decrypt(ciphertext);
            assertArrayEquals(tests[t].m, m);
        }
    }
}
View Full Code Here


        }
        catch (Throwable t)
        {
            fail("Unexpected exception " + t);
        }
        k.decrypt(ct);
    }
   
    // Implements test case NDC-2.
    @Test(expected=NullPointerException.class)
    public void test_decrypt_nullCipherText()
View Full Code Here

        }
        catch (Throwable t)
        {
            fail("Unexpected exception " + t);
        }
        k.decrypt(null);
    }
   
    // Implements test case NDC-3.
    @Test(expected=CiphertextBadLengthException.class)
    public void test_decrypt_ciphertext_short()
View Full Code Here

    {
        NtruEncryptTestVector test = tests[0];
        NtruEncryptKey k = new NtruEncryptKey(getPrivKeyBlob(test));
        byte ct[] = new byte[test.packedE.length-1];
        System.arraycopy(test.packedE, 0, ct, 0, ct.length);
        k.decrypt(ct);
    }
    @Test(expected=CiphertextBadLengthException.class)
    public void test_decrypt_ciphertext_long()
        throws NtruException
    {
View Full Code Here

        NtruEncryptTestVector test = tests[0];
        NtruEncryptKey k = new NtruEncryptKey(getPrivKeyBlob(test));
        byte ct[] = new byte[test.packedE.length+1];
        System.arraycopy(test.packedE, 0, ct, 0, test.packedE.length);
        ct[ct.length-1] = 0;
        k.decrypt(ct);
    }
   
    // Implements test case NDC-5.
    @Test(expected=DecryptionFailureException.class)
    public void test_decrypt_bad_ciphertext()
View Full Code Here

        NtruEncryptTestVector test = tests[0];
        NtruEncryptKey k = new NtruEncryptKey(getPrivKeyBlob(test));
        byte ct[] = new byte[test.packedE.length];
        System.arraycopy(test.packedE, 0, ct, 0, ct.length);
        ct[2]++;
        k.decrypt(ct);
    }
   
    // Implements test case NDC-6.
    @Test(expected=DecryptionFailureException.class)
    public void test_decrypt_bad_key()
View Full Code Here

        // Generate a new key. The test vector key was generated with
        // test.keygenSeed, so for this new key we will seed the PRNG
        // with test.encryptSeed, which should != keygenSeed.
        Random r = new Random(test.encryptSeed);
        NtruEncryptKey k = NtruEncryptKey.genKey(test.oid, r);
        k.decrypt(test.packedE);
    }
   
    // Implements test case NDC-4.
    @Test(expected=NoPrivateKeyException.class)
    public void test_decrypt_noPrivateKey()
View Full Code Here

    public void test_decrypt_noPrivateKey()
        throws NtruException
    {
        NtruEncryptTestVector test = tests[0];
        NtruEncryptKey k = new NtruEncryptKey(getPubKeyBlob(test));
        k.decrypt(test.packedE);
    }
   
    // Implements test case NDC-1.
    @Test public void test_decrypt_known_value()
        throws NtruException
View Full Code Here

    {
        for (OID oid : OID.values())
        {
            NtruEncryptTestVector test  = findTest(oid);
            NtruEncryptKey k = new NtruEncryptKey(getPrivKeyBlob(test));
            assertArrayEquals(test.m, k.decrypt(test.packedE));
        }
    }


View Full Code Here

        // Do encryption.
        byte m[] = new byte[10];
        byte ciphertext[] = keys.encrypt(m, defaultPrng);

        // Do decryption.
        byte m2[] = keys.decrypt(ciphertext);

        // Compare
        return Arrays.equals(m, m2);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.