com.unbound.client.MacMode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unbound-java-provider Show documentation
Show all versions of unbound-java-provider Show documentation
This is a collection of JAVA libraries that implement Unbound cryptographic classes for JAVA provider, PKCS11 wrapper, cryptoki, and advapi
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;
}
}