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

com.unbound.client.MacMode 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.client;

import com.dyadicsec.cryptoki.CK;
import com.unbound.kmip.KMIP;

import java.security.ProviderException;

public final class MacMode
{
  private final Integer kmipBlockMode;
  private final int pkcsMech;
  private final int pkcs3DesMech;
  private final ObjectType keyType;


  private MacMode(ObjectType keyType, Integer kmipBlockMode, int pkcsMech, int pkcs3DesMech)
  {
    this.keyType = keyType;
    this.kmipBlockMode = kmipBlockMode;
    this.pkcsMech =  pkcsMech;
    this.pkcs3DesMech = pkcs3DesMech;
  }

  public static MacMode HMAC = new MacMode(ObjectType.GenericSecret, null, -1, -1);
  public static MacMode GMAC = new MacMode(ObjectType.AES, KMIP.BlockCipherMode.GMAC, CK.CKM_AES_GMAC, -1);

  public ObjectType getKeyType()
  {
    return keyType;
  }

  public Integer getKmipAlg(HashType hashType)
  {
    if (this==HMAC) return hashType.getKmipHmacAlg();
    throw new ProviderException("Unsupported MAC type");
  }

  public Integer getKmipBlockMode() { return kmipBlockMode; }

  public int getPkcs11(ObjectType objectType, HashType hashType)
  {
    if (this==HMAC) return hashType.getPkcs11HmacMech();
    if (objectType == ObjectType.DES3) return pkcs3DesMech;
    return pkcsMech;
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy