Examples of NtruEncryptKey


Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

        throws NtruException
    {
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);
            NtruEncryptKey keys = new NtruEncryptKey(tests[t].oid);
            FullPolynomial R = new FullPolynomial(tests[t].R);
            byte out[] = keys.calcPolyMod4Packed(R);
            assertArrayEquals(out, tests[t].R4);
        }
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

        throws NtruException
    {
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);
            NtruEncryptKey keys = new NtruEncryptKey(tests[t].oid);
            FullPolynomial out =
              keys.calcEncryptionMask(new FullPolynomial(tests[t].R));
            assertArrayEquals(out.p, tests[t].mask);
        }
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    // Verify that the the dm0 check is correct for all 3 failure cases.
    // and for the positive case
    @Test public void test_check_dm0()
        throws NtruException
    {
        NtruEncryptKey keys = new NtruEncryptKey(OID.ees401ep1);

        // Check the ability to count 1's.
        // Verify the boundary case and one case on each side of the dm0 limit
        short threeOnesArray[] = {-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1};
        FullPolynomial threeOnes = new FullPolynomial(threeOnesArray);
        assertFalse(keys.check_dm0(threeOnes, 4));
        assertTrue(keys.check_dm0(threeOnes, 3));
        assertTrue(keys.check_dm0(threeOnes, 2));

        // Check the ability to count 0's.
        // Verify the boundary case and one case on each side of the dm0 limit
        short threeZerosArray[] = {-1, -1, -1, -1, -1, 0, 0, 0, 1, 1, 1, 1, 1};
        FullPolynomial threeZeros = new FullPolynomial(threeZerosArray);
        assertFalse(keys.check_dm0(threeZeros, 4));
        assertTrue(keys.check_dm0(threeZeros, 3));
        assertTrue(keys.check_dm0(threeZeros, 2));

        // Check the ability to count -1's.
        // Verify the boundary case and one case on each side of the dm0 limit
        short threeNegOnesArray[] = {-1, -1, -1, -1, -10,0,0,0,01,1,1};
        FullPolynomial threeNegOnes = new FullPolynomial(threeNegOnesArray);
        assertFalse(keys.check_dm0(threeNegOnes, 4));
        assertTrue(keys.check_dm0(threeNegOnes, 3));
        assertTrue(keys.check_dm0(threeNegOnes, 2));
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

        throws NtruException
    {
        for (OID oid : OID.values())
        {
            NtruEncryptTestVector test  = findTest(oid);
            NtruEncryptKey k = new NtruEncryptKey(getPubKeyBlob(test));
            defaultPrng.seed(test.encryptSeed);
            assertArrayEquals(test.packedE, k.encrypt(test.m, defaultPrng));
        }
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    // Implements test case NDC-7.
    @Test(expected=ObjectClosedException.class)
    public void test_decrypt_closed()
        throws NtruException
    {
        NtruEncryptKey k = null;
        byte           ct[] = null;
        try
        {
            NtruEncryptTestVector test    = findTest(OID.ees401ep1);
            k = new NtruEncryptKey(getPrivKeyBlob(test));
            k.close();
            ct = test.m;
        }
        catch (Throwable t)
        {
            fail("Unexpected exception " + t);
        }
        k.decrypt(ct);
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    // Implements test case NDC-2.
    @Test(expected=NullPointerException.class)
    public void test_decrypt_nullCipherText()
        throws NtruException
    {
        NtruEncryptKey k = null;
        try
        {
            NtruEncryptTestVector test    = findTest(OID.ees401ep1);
            k = new NtruEncryptKey(getPrivKeyBlob(test));
        }
        catch (Throwable t)
        {
            fail("Unexpected exception " + t);
        }
        k.decrypt(null);
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    @Test(expected=CiphertextBadLengthException.class)
    public void test_decrypt_ciphertext_short()
        throws NtruException
    {
        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);
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    @Test(expected=CiphertextBadLengthException.class)
    public void test_decrypt_ciphertext_long()
        throws NtruException
    {
        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);
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    @Test(expected=DecryptionFailureException.class)
    public void test_decrypt_bad_ciphertext()
        throws NtruException
    {
        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);
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

        NtruEncryptTestVector test = tests[0];
        // 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);
    }
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.