Package gnu.javax.crypto.kwa

Examples of gnu.javax.crypto.kwa.IKeyWrappingAlgorithm.wrap()


        String msg;
        byte[] km = new byte[24];
        msg = "Input length for wrapping MUST be 16 or 24 bytes";
        try
          {
            kwa.wrap(km, 0, 15);
            harness.fail(msg);
          }
        catch (IllegalArgumentException e)
          {
            harness.check(true, msg);
View Full Code Here


        IKeyWrappingAlgorithm kwa = KeyWrappingAlgorithmFactory.getInstance("kw-tripledes");
        Map attributes = new HashMap();
        attributes.put(IKeyWrappingAlgorithm.KEY_ENCRYPTION_KEY_MATERIAL, kek);
        kwa.init(attributes);

        byte[] wrapped = kwa.wrap(km, 0, km.length);
        harness.check(wrapped.length == 40,
                      "Wrapped key material MUST produce 40 bytes");

        byte[] unwrapped = kwa.unwrap(wrapped, 0, wrapped.length);
        harness.check(unwrapped.length == 24,
View Full Code Here

        String msg;
        byte[] km1 = new byte[24];
        msg = "Input length MUST be a multiple of 8 bytes";
        try
          {
            kwa.wrap(km1, 0, 17, km1, 0);
            harness.fail(msg);
          }
        catch (IllegalArgumentException e)
          {
            harness.check(true, msg);
View Full Code Here

          }

        msg = "Output length MUST be at least 8 bytes larger than input length";
        try
          {
            kwa.wrap(km1, 0, 16, km1, 1);
            harness.fail(msg);
          }
        catch (ShortBufferException e)
          {
            harness.check(true, msg);
View Full Code Here

        Map attributes = new HashMap();
        attributes.put(IKeyWrappingAlgorithm.KEY_ENCRYPTION_KEY_MATERIAL, kek);
        kwa.init(attributes);

        byte[] wrapped = new byte[km.length + 8];
        int outputLength = kwa.wrap(km, 0, km.length, wrapped, 0);
        harness.check(outputLength == 16,
                      "Wrapped 64-bit key material MUST produce 16 bytes");

        byte[] unwrapped = new byte[8];
        outputLength = kwa.unwrap(wrapped, 0, wrapped.length, unwrapped, 0);
View Full Code Here

        attributes.put(IKeyWrappingAlgorithm.KEY_ENCRYPTION_KEY_MATERIAL, kek);
        kwa.init(attributes);

        byte[] km = (byte[]) keyMaterial.clone();
        byte[] wrapped = new byte[km.length + 8];
        kwa.wrap(km, 0, km.length, wrapped, 0);
        harness.check(Arrays.equals(wrappedKeyMaterial, wrapped),
                      keyMaterialLength + "-bit key material wrapped w/ "
                      + keyLength + "-bit KEK MUST match expected value");

        byte[] unwrapped = new byte[wrappedKeyMaterial.length - 8];
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.