Example usage for org.bouncycastle.util Arrays fill

List of usage examples for org.bouncycastle.util Arrays fill

Introduction

In this page you can find the example usage for org.bouncycastle.util Arrays fill.

Prototype

public static void fill(short[] a, short val) 

Source Link

Usage

From source file:org.ccnx.ccn.io.content.CCNNetworkObjectTestRepo.java

License:Open Source License

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    Log.info(Log.FAC_TEST, "Setting up CCNNetworkObjectTestRepo, prefix {0}", testHelper.getClassNamespace());

    CCNHandle myhandle = CCNHandle.open();
    try {//from w w w .  ja va 2s. c o  m
        ns = new ContentName[NUM_LINKS];
        for (int i = 0; i < NUM_LINKS; ++i) {
            ns[i] = new ContentName(testHelper.getClassNamespace(), "Links", prefix + Integer.toString(i));
        }
        Arrays.fill(publisherid1, (byte) 6);
        Arrays.fill(publisherid2, (byte) 3);

        pubID1 = new PublisherID(publisherid1, PublisherType.KEY);
        pubID2 = new PublisherID(publisherid2, PublisherType.ISSUER_KEY);

        las[0] = new LinkAuthenticator(pubID1);
        las[1] = null;
        las[2] = new LinkAuthenticator(pubID2, null, null, SignedInfo.ContentType.DATA, contenthash1);
        las[3] = new LinkAuthenticator(pubID1, null, CCNTime.now(), null, contenthash1);

        for (int j = 4; j < NUM_LINKS; ++j) {
            las[j] = new LinkAuthenticator(pubID2, null, CCNTime.now(), null, null);
        }

        lrs = new Link[NUM_LINKS];
        for (int i = 0; i < lrs.length; ++i) {
            lrs[i] = new Link(ns[i], las[i]);
        }

        empty = new Collection();
        small1 = new Collection();
        small2 = new Collection();
        for (int i = 0; i < 5; ++i) {
            small1.add(lrs[i]);
            small2.add(lrs[i + 5]);
        }
        big = new Collection();
        for (int i = 0; i < NUM_LINKS; ++i) {
            big.add(lrs[i]);
        }
        Log.info(Log.FAC_TEST, "Finihed setting up CCNNetworkObjectTestRepo, prefix {0}",
                testHelper.getClassNamespace());
    } finally {
        myhandle.close();
        KeyManager.closeDefaultKeyManager();
    }
}

From source file:org.ccnx.ccn.io.content.EncodableObjectTest.java

License:Open Source License

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ns = new ContentName[NUM_LINKS];
    for (int i = 0; i < NUM_LINKS; ++i) {
        ns[i] = new ContentName(baseName, subName, document1, prefix + Integer.toString(i));
    }//  www. j  a  v a 2  s . c  o m
    Arrays.fill(publisherid1, (byte) 6);
    Arrays.fill(publisherid2, (byte) 3);

    pubID1 = new PublisherID(publisherid1, PublisherType.KEY);
    pubID2 = new PublisherID(publisherid2, PublisherType.ISSUER_KEY);

    las[0] = new LinkAuthenticator(pubID1);
    las[1] = null;
    las[2] = new LinkAuthenticator(pubID2, null, null, SignedInfo.ContentType.DATA, contenthash1);
    las[3] = new LinkAuthenticator(pubID1, null, CCNTime.now(), null, contenthash1);

    for (int j = 4; j < NUM_LINKS; ++j) {
        las[j] = new LinkAuthenticator(pubID2, null, CCNTime.now(), null, null);
    }

    lrs = new Link[NUM_LINKS];
    for (int i = 0; i < lrs.length; ++i) {
        lrs[i] = new Link(ns[i], las[i]);
    }

    empty = new Collection();
    small1 = new Collection();
    small2 = new Collection();
    for (int i = 0; i < 5; ++i) {
        small1.add(lrs[i]);
        small2.add(lrs[i + 5]);
    }
    big = new Collection();
    for (int i = 0; i < NUM_LINKS; ++i) {
        big.add(lrs[i]);
    }
}

From source file:org.ejbca.core.ejb.DatabaseSchemaTest.java

License:Open Source License

private byte[] getLob(int size) {
    byte[] ret = new byte[size];
    Arrays.fill(ret, (byte) '0');
    return ret;//from  w w w .  j  a  v  a 2s.c om
}

From source file:org.ethereum.vm.DataWord.java

License:Open Source License

public void assignDataRange(byte[] data, int ofs, int len) {
    if (data == null) {
        this.data = ByteUtil.EMPTY_BYTE_ARRAY;
    } else if (len <= 32) {
        //if there is not enough data
        // trailing zeros are assumed (this is required  for PUSH opcode semantic
        Arrays.fill(this.data, (byte) 0); // first clear
        int dlen = Integer.min(len, data.length - ofs);
        System.arraycopy(data, ofs, this.data, 32 - len, dlen);

    } else {/*www .  j  a va2 s . co  m*/
        throw new RuntimeException("Data word can't exceed 32 bytes: " + data);
    }
}

From source file:org.ethereum.vm.DataWord.java

License:Open Source License

public DataWord zero() {
    Arrays.fill(this.data, (byte) 0);
    return this;
}

From source file:org.fdroid.enigtext.crypto.MasterSecret.java

License:Open Source License

private MasterSecret(Parcel in) {
    byte[] encryptionKeyBytes = new byte[in.readInt()];
    in.readByteArray(encryptionKeyBytes);

    byte[] macKeyBytes = new byte[in.readInt()];
    in.readByteArray(macKeyBytes);/*from  w  w w .j  a v a  2 s  .  c  o m*/

    this.encryptionKey = new SecretKeySpec(encryptionKeyBytes, "AES");
    this.macKey = new SecretKeySpec(macKeyBytes, "HmacSHA1");

    // SecretKeySpec does an internal copy in its constructor.
    Arrays.fill(encryptionKeyBytes, (byte) 0x00);
    Arrays.fill(macKeyBytes, (byte) 0x00);
}

From source file:org.martus.common.test.TestUniversalId.java

License:Open Source License

public void testLocalId() {
    UniversalId uid = UniversalIdForTesting.createDummyUniversalId();

    assertNotNull("no local id?", uid.getLocalId());
    assertTrue("local id too short?", uid.getLocalId().length() > 20);
    assertTrue("local id too long?", uid.getLocalId().length() < 40);
    assertEquals("contructor didn't strip colons?", -1, uid.getLocalId().indexOf(":"));

    UniversalId uid2 = UniversalIdForTesting.createDummyUniversalId();
    assertNotEquals("dupe?", uid.getLocalId(), uid2.getLocalId());

    uid.setLocalId(sampleLocalId);/* w  w w. j  a  v  a2 s.  c o m*/
    assertEquals("didn't set local?", sampleLocalId, uid.getLocalId());

    uid.setLocalId("This:That");
    assertEquals("setter didn't strip colons?", "This-That", uid.getLocalId());

    String prefix = "B-";
    String suffix = "_R";
    byte[] bytes = new byte[UniversalId.LOCALID_RANDOM_BYTE_COUNT];
    Arrays.fill(bytes, (byte) 0x65);
    String localId = UniversalId.createLocalIdFromByteArray(prefix, bytes, suffix);
    assertTrue(localId.startsWith(prefix));
    assertTrue(localId.endsWith(suffix));
}

From source file:org.ndnx.ndn.io.content.EncodableObjectTest.java

License:Open Source License

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ns = new ContentName[NUM_LINKS];
    for (int i = 0; i < NUM_LINKS; ++i) {
        ns[i] = new ContentName(baseName, subName, document1, prefix + Integer.toString(i));
    }/*from  ww w  .j  a v  a2 s . co m*/
    Arrays.fill(publisherid1, (byte) 6);
    Arrays.fill(publisherid2, (byte) 3);

    pubID1 = new PublisherID(publisherid1, PublisherType.KEY);
    pubID2 = new PublisherID(publisherid2, PublisherType.ISSUER_KEY);

    las[0] = new LinkAuthenticator(pubID1);
    las[1] = null;
    las[2] = new LinkAuthenticator(pubID2, null, null, SignedInfo.ContentType.DATA, contenthash1);
    las[3] = new LinkAuthenticator(pubID1, null, NDNTime.now(), null, contenthash1);

    for (int j = 4; j < NUM_LINKS; ++j) {
        las[j] = new LinkAuthenticator(pubID2, null, NDNTime.now(), null, null);
    }

    lrs = new Link[NUM_LINKS];
    for (int i = 0; i < lrs.length; ++i) {
        lrs[i] = new Link(ns[i], las[i]);
    }

    empty = new Collection();
    small1 = new Collection();
    small2 = new Collection();
    for (int i = 0; i < 5; ++i) {
        small1.add(lrs[i]);
        small2.add(lrs[i + 5]);
    }
    big = new Collection();
    for (int i = 0; i < NUM_LINKS; ++i) {
        big.add(lrs[i]);
    }
}

From source file:org.ndnx.ndn.io.content.NDNNetworkObjectTest.java

License:Open Source License

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    Log.info(Log.FAC_TEST, "Setting up NDNNetworkObjectTest, prefix {0}", testHelper.getClassNamespace());

    handle = NDNHandle.open();/*from w ww.j  a v  a 2s .c  om*/

    ns = new ContentName[NUM_LINKS];
    for (int i = 0; i < NUM_LINKS; ++i) {
        ns[i] = new ContentName(testHelper.getClassNamespace(), "Links", prefix + Integer.toString(i));
    }
    Arrays.fill(publisherid1, (byte) 6);
    Arrays.fill(publisherid2, (byte) 3);

    pubID1 = new PublisherID(publisherid1, PublisherType.KEY);
    pubID2 = new PublisherID(publisherid2, PublisherType.ISSUER_KEY);

    las[0] = new LinkAuthenticator(pubID1);
    las[1] = null;
    las[2] = new LinkAuthenticator(pubID2, null, null, SignedInfo.ContentType.DATA, contenthash1);
    las[3] = new LinkAuthenticator(pubID1, null, NDNTime.now(), null, contenthash1);

    for (int j = 4; j < NUM_LINKS; ++j) {
        las[j] = new LinkAuthenticator(pubID2, null, NDNTime.now(), null, null);
    }

    lrs = new Link[NUM_LINKS];
    for (int i = 0; i < lrs.length; ++i) {
        lrs[i] = new Link(ns[i], las[i]);
    }

    empty = new Collection();
    small1 = new Collection();
    small2 = new Collection();
    for (int i = 0; i < 5; ++i) {
        small1.add(lrs[i]);
        small2.add(lrs[i + 5]);
    }
    big = new Collection();
    for (int i = 0; i < NUM_LINKS; ++i) {
        big.add(lrs[i]);
    }

    flosser = new Flosser();
    Log.info(Log.FAC_TEST, "Finished setting up NDNNetworkObjectTest, prefix is: {0}.",
            testHelper.getClassNamespace());
}

From source file:org.ndnx.ndn.io.content.NDNNetworkObjectTestRepo.java

License:Open Source License

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    Log.info(Log.FAC_TEST, "Setting up NDNNetworkObjectTestRepo, prefix {0}", testHelper.getClassNamespace());

    NDNHandle myhandle = NDNHandle.open();
    try {//  ww w.  j av  a 2 s.  c  o m
        ns = new ContentName[NUM_LINKS];
        for (int i = 0; i < NUM_LINKS; ++i) {
            ns[i] = new ContentName(testHelper.getClassNamespace(), "Links", prefix + Integer.toString(i));
        }
        Arrays.fill(publisherid1, (byte) 6);
        Arrays.fill(publisherid2, (byte) 3);

        pubID1 = new PublisherID(publisherid1, PublisherType.KEY);
        pubID2 = new PublisherID(publisherid2, PublisherType.ISSUER_KEY);

        las[0] = new LinkAuthenticator(pubID1);
        las[1] = null;
        las[2] = new LinkAuthenticator(pubID2, null, null, SignedInfo.ContentType.DATA, contenthash1);
        las[3] = new LinkAuthenticator(pubID1, null, NDNTime.now(), null, contenthash1);

        for (int j = 4; j < NUM_LINKS; ++j) {
            las[j] = new LinkAuthenticator(pubID2, null, NDNTime.now(), null, null);
        }

        lrs = new Link[NUM_LINKS];
        for (int i = 0; i < lrs.length; ++i) {
            lrs[i] = new Link(ns[i], las[i]);
        }

        empty = new Collection();
        small1 = new Collection();
        small2 = new Collection();
        for (int i = 0; i < 5; ++i) {
            small1.add(lrs[i]);
            small2.add(lrs[i + 5]);
        }
        big = new Collection();
        for (int i = 0; i < NUM_LINKS; ++i) {
            big.add(lrs[i]);
        }
        Log.info(Log.FAC_TEST, "Finihed setting up NDNNetworkObjectTestRepo, prefix {0}",
                testHelper.getClassNamespace());
    } finally {
        myhandle.close();
        KeyManager.closeDefaultKeyManager();
    }
}