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);

            byte M[] = new byte[keyParams.db/8-1];
            java.util.Arrays.fill(M, (byte) 0);           
            assertEquals(0, keys.parseMsgLengthFromM(M));
        }
    }
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);

            byte M[] = new byte[keyParams.N];
            java.util.Arrays.fill(M, (byte) 0);
            for (int i=1; i<12; i++)
            {
                M[keyParams.db/8] = (byte) i;
                assertEquals(i, keys.parseMsgLengthFromM(M));
            }
        }
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    // a short input buffer.
    @Test public void test_verifyMFormat_shortInputBuffer()
        throws NtruException
    {
        KeyParams keyParams = KeyParams.getKeyParams(OID.ees401ep1);
        NtruEncryptKey keys = new NtruEncryptKey(OID.ees401ep1);

        byte M[] = new byte[keyParams.N-2];
        java.util.Arrays.fill(M, (byte) 0);
        M[keyParams.db/8] = 1;
        assertEquals(-1, keys.verifyMFormat(M));
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    // embedded mLen is invalid.
    @Test public void test_verifyMFormat_invalidMLen()
        throws NtruException
    {
        KeyParams keyParams = KeyParams.getKeyParams(OID.ees401ep1);
        NtruEncryptKey keys = new NtruEncryptKey(OID.ees401ep1);

        byte M[] = new byte[keyParams.N];
        java.util.Arrays.fill(M, (byte) 0);
        M[keyParams.db/8] = (byte) 401;
        assertEquals(-1, keys.verifyMFormat(M));
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

    // Verify verifyMFormat generates an appropriate error when p0 is incorrect
    @Test public void test_verifyMFormat_invalidp0()
        throws NtruException
    {
        KeyParams keyParams = KeyParams.getKeyParams(OID.ees401ep1);
        NtruEncryptKey keys = new NtruEncryptKey(OID.ees401ep1);

        byte M[] = new byte[keyParams.N];
        java.util.Arrays.fill(M, (byte) 0);
        M[keyParams.db/8] = 1;
        M[keyParams.db/8+keyParams.lLen+1+1] = 2;
        assertEquals(-1, keys.verifyMFormat(M));
    }
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);

            byte M[] = new byte[keyParams.db/8 + keyParams.lLen +
                                keyParams.maxMsgLenBytes + 1];
            java.util.Arrays.fill(M, (byte) 0);
            M[keyParams.db/8] = (byte) 1;
            java.util.Arrays.fill(M, keyParams.db/8+keyParams.lLen,
                                  keyParams.db/8+keyParams.lLen+1, (byte) 22);
            assertEquals(1, keys.verifyMFormat(M));
        }
    }
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);

            // Set f, h.
            keys.h = new FullPolynomial(tests[t].h);
            keys.f = new FullPolynomial(tests[t].f);

            // 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

Examples of com.securityinnovation.jNeo.ntruencrypt.NtruEncryptKey

        throws NtruException
    {
        for (int t=0; t<tests.length; t++)
        {
            ByteArrayInputStream rng = new ByteArrayInputStream(tests[t].b);
            NtruEncryptKey keys = new NtruEncryptKey(tests[t].oid);
            byte M[] = keys.generateM(tests[t].m, rng);
            assertArrayEquals(tests[t].Mbin, M);
        }
    }
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);
            keys.h = new FullPolynomial(tests[t].h);
            byte sData[] = keys.form_sData(
                tests[t].m, 0, tests[t].m.length, tests[t].b, 0);
            assertArrayEquals(tests[t].sData, sData);
        }
    }
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);
            keys.h = new FullPolynomial(tests[t].h);

            byte data[] = new byte[tests[t].m.length + tests[t].b.length + 92];
            java.util.Arrays.fill(data, (byte) 23);
            int mOffset = 33;
            int bOffset = 72;
            System.arraycopy(tests[t].m, 0, data, mOffset, tests[t].m.length);
            System.arraycopy(tests[t].b, 0, data, bOffset, tests[t].b.length);
            byte sData[] = keys.form_sData(
                data, mOffset, tests[t].m.length, data, bOffset);
            assertArrayEquals(tests[t].sData, sData);
        }
    }
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.