Examples of NtruEncryptTestVector


Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

    // Implements test case NDC-5.
    @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.testvectors.NtruEncryptTestVector

    // Implements test case NDC-6.
    @Test(expected=DecryptionFailureException.class)
    public void test_decrypt_bad_key()
        throws NtruException
    {
        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);
View Full Code Here

Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

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

Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

    @Test public void test_decrypt_known_value()
        throws NtruException
    {
        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

Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

    // Verify the byte->trit and trit->byte operations really
    // are inverses for a variety of trinomials.
    @Test public void test_invertibility()
    {
        NtruEncryptTestVector tests[] = NtruEncryptTestVector.getTestVectors();
        for (int t=0; t<tests.length; t++)
        {
            FullPolynomial p = new FullPolynomial(tests[t].F);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            MGF_TP_1.encodeTrinomial(p, out);
View Full Code Here

Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

    // test vector
    // r = BGPM3(MGF1(dr, seed=sData));
    @Test public void test_genr()
        throws ParamSetNotSupportedException
    {
        NtruEncryptTestVector tests[] = NtruEncryptTestVector.getTestVectors();
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);
            FullPolynomial expected = new FullPolynomial(tests[t].r);
            IGF2 igf = new IGF2(
View Full Code Here

Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

    // Use samples from the NtruEncrypt test vector paper:
    //  R = r * h (mod q)
    @Test public void test_convolution()
        throws ParamSetNotSupportedException
    {
        NtruEncryptTestVector tests[] = NtruEncryptTestVector.getTestVectors();
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);
            FullPolynomial r = new FullPolynomial(tests[t].r);
            FullPolynomial h = new FullPolynomial(tests[t].h);
View Full Code Here

Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

    // Use samples from the NtruEncrypt test vector paper:
    //  e = R + m' (mod q)
    @Test public void test_add()
        throws ParamSetNotSupportedException
    {
        NtruEncryptTestVector tests[] = NtruEncryptTestVector.getTestVectors();
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);
            FullPolynomial R  = new FullPolynomial(tests[t].R);
            FullPolynomial mP = new FullPolynomial(tests[t].mPrime);
View Full Code Here

Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

    // Use samples from the NtruEncrypt test vector paper:
    //   m' = M + mask (mod p) centered on 0.
    @Test public void test_addAndRecenter()
        throws ParamSetNotSupportedException
    {
        NtruEncryptTestVector tests[] = NtruEncryptTestVector.getTestVectors();
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);

            // m' = mask + Mtrin (mod p)
View Full Code Here

Examples of com.securityinnovation.testvectors.NtruEncryptTestVector

    // Use samples from the NtruEncrypt test vector paper:
    //  R = e - m' (mod q)
    @Test public void test_subtract()
        throws ParamSetNotSupportedException
    {
        NtruEncryptTestVector tests[] = NtruEncryptTestVector.getTestVectors();
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);
            FullPolynomial R  = new FullPolynomial(tests[t].R);
            FullPolynomial mP = new FullPolynomial(tests[t].mPrime);
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.