All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.unbound.provider.kmip.attribute.KeyWrappingData Maven / Gradle / Ivy

Go to download

This is a collection of JAVA libraries that implement Unbound cryptographic classes for JAVA provider, PKCS11 wrapper, cryptoki, and advapi

There is a newer version: 42761
Show newest version
package com.unbound.provider.kmip.attribute;

import com.unbound.common.Log;
import com.unbound.provider.kmip.KMIP;
import com.unbound.provider.kmip.KMIPConvertException;
import com.unbound.provider.kmip.KMIPConverter;

/**
 * Created by valery.osheter on 14-Nov-16.
 */
public class KeyWrappingData extends Attribute
{
  public int wrappingMethod = 0;
  public KeyWrappingInfo encKey = null;
  public KeyWrappingInfo macKey = null;
  public byte[] mac = null;
  public byte[] iv = null;
  public Integer encodingOption = null;

  public KeyWrappingData()
  {
    super(KMIP.Tag.KeyWrappingData);
  }

  public void convert(KMIPConverter converter) throws KMIPConvertException
  {
    int begin = converter.convertBegin(KMIP.Tag.KeyWrappingData);
    wrappingMethod = converter.convert(KMIP.Tag.WrappingMethod, wrappingMethod);

    if (!converter.isWrite() && converter.getNextTag() == KMIP.Tag.EncryptionKeyInformation)
      encKey = new KeyWrappingInfo();
    if (encKey != null)
    {
      int b = converter.convertBegin(KMIP.Tag.EncryptionKeyInformation);
      encKey.convert(converter);
      converter.convertEnd(b);
    }

    if (!converter.isWrite() && converter.getNextTag() == KMIP.Tag.MacSignatureKeyInformation)
      macKey = new KeyWrappingInfo();
    if (macKey != null)
    {
      int b = converter.convertBegin(KMIP.Tag.MacSignatureKeyInformation);
      macKey.convert(converter);
      converter.convertEnd(b);
    }

    mac = converter.convertOptional(KMIP.Tag.MacSignature, mac);
    iv = converter.convertOptional(KMIP.Tag.IVCounterNonce, iv);
    encodingOption = converter.convertOptional(KMIP.Tag.EncodingOption, encodingOption);

    converter.convertEnd(begin);
  }

  public void log()
  {
    Log log = Log.func("KeyWrappingData").
      log("wrappingMethod", wrappingMethod).
      log("encodingOption", encodingOption).
      logLen("macLen", mac).
      logLen("ivLen", mac).
    end();
    if (encKey!=null) encKey.log();
    if (macKey!=null) macKey.log();
    log.leave();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy