Package com.securityinnovation.jNeo.ntruencrypt

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


            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


        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

    {
        NtruEncryptKey keys = NtruEncryptKey.genKey(oid, defaultPrng);

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

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

        // Compare
View Full Code Here

        }
        catch (Throwable t)
        {
            fail("Unexpected exception " + t);
        }
        k.encrypt(defaultSeed, defaultPrng);
    }
   
    // Implements test case NEP-2.
    @Test(expected=NullPointerException.class)
    public void test_encrypt_nullPlaintext()
View Full Code Here

        }
        catch (Throwable t)
        {
            fail("Unexpected exception " + t);
        }
        k.encrypt(null, defaultPrng);
    }
   
    // Implements test case NEP-5.
    @Test(expected=NullPointerException.class)
    public void test_encrypt_nullPrng()
View Full Code Here

        }
        catch (Throwable t)
        {
            fail("Unexpected exception " + t);
        }
        k.encrypt(defaultSeed, (Random)null);
    }
   
    // Implements test case NEP-3.
    @Test(expected=PlaintextBadLengthException.class)
    public void test_encrypt_messageTooLong()
View Full Code Here

        catch (Throwable t)
        {
            fail("Unexpected exception " + t);
        }
        byte b[] = new byte[2*1024];
        k.encrypt(b, defaultPrng);
    }
   
    // Implements test case NEP-1.
    public void test_encrypt_known_value()
        throws NtruException
View Full Code Here

            NtruEncryptKey key = NtruEncryptKey.genKey(oid, r);

            seed = makeSeed(oid, "encrypt");
            TVDump.dumpHex("encryptSeed", seed);
            r.seed(seed);
            byte ct[] = key.encrypt(m, r);
            key.decrypt(ct);

            System.out.println("\n\n");
        }
    }
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.