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

com.unbound.provider.KeyParameters 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;


public class KeyParameters
{
  public static final int EXPORT_NONE = 3;
  public static final int EXPORT_WRAP_WITH_TRUSTED = 2;
  public static final int EXPORT_WRAP = 1;
  public static final int EXPORT_PLAIN = 0;

  private int exportLevelMode = -1;
  private int signMode = -1;
  private int verifyMode = -1;
  private int encryptMode = -1;
  private int decryptMode = -1;
  private int wrapMode = -1;
  private int unwrapMode = -1;
  private int deriveMode = -1;
  private int trustedMode = -1;
  private int hwMode = -1;
  private String name = null;

  public boolean isSetSign()             { return signMode >=0; }
  public boolean isSetVerify()           { return verifyMode >=0; }
  public boolean isSetEncrypt()          { return encryptMode >=0; }
  public boolean isSetDecrypt()          { return decryptMode >=0; }
  public boolean isSetWrap()             { return wrapMode >=0; }
  public boolean isSetUnwrap()           { return unwrapMode >=0; }
  public boolean isSetDerive()           { return deriveMode >=0; }
  public boolean isSetTrusted()          { return trustedMode >=0; }
  public boolean isSetToken()            { return hwMode >=0; }
  public boolean isSetExportProtection() { return exportLevelMode >=0; }
  public boolean isSetName()             { return name != null; }

  public void setName(String name)       { this.name   = name; }
  public void setToken(boolean v)        { hwMode      = v ? 1 : 0; }
  public void setAllowEncrypt(boolean v) { encryptMode = v ? 1 : 0; }
  public void setAllowDecrypt(boolean v) { decryptMode = v ? 1 : 0; }
  public void setAllowSign(boolean v)    { signMode    = v ? 1 : 0; }
  public void setAllowVerify(boolean v)  { verifyMode  = v ? 1 : 0; }
  public void setAllowDerive(boolean v)  { deriveMode  = v ? 1 : 0; }
  public void setTrusted(boolean v)      { trustedMode = v ? 1 : 0; }
  public void setWrap(boolean v)         { wrapMode    = v ? 1 : 0; }
  public void setUnwrap(boolean v)       { unwrapMode  = v ? 1 : 0; }

  public void setExportProtection(int exportLevel)
  {
    if (exportLevelEXPORT_NONE) throw new IllegalArgumentException("Invalid export level");
    this.exportLevelMode = exportLevel;
  }

  public void setExtractable(boolean v)
  {
    if (v) exportLevelMode = EXPORT_WRAP_WITH_TRUSTED;
    else exportLevelMode = EXPORT_NONE;
  }

  public void setSensitive(boolean v)
  {
    if (!v) exportLevelMode = EXPORT_PLAIN;
  }

  public int getExportProtection()
  {
    return exportLevelMode<0 ? EXPORT_NONE : exportLevelMode;
  }
  public boolean isAllowEncrypt() { return encryptMode!=0; }
  public boolean isAllowDecrypt() { return decryptMode!=0; }
  public boolean isAllowSign() { return signMode!=0; }
  public boolean isAllowVerify() { return verifyMode!=0; }
  public boolean isAllowDerive()
  {
    return deriveMode!=0;
  }
  public boolean isTrusted()  {  return trustedMode>0; }
  public boolean isExtractable() { return exportLevelMode==EXPORT_WRAP || exportLevelMode==EXPORT_WRAP_WITH_TRUSTED; }
  public boolean isSensitive() { return exportLevelMode!=EXPORT_PLAIN; }
  public boolean isAllowWrap()
  {
    return wrapMode!=0;
  }
  public boolean isAllowUnwrap()
  {
    return unwrapMode!=0;
  }
  public boolean isToken()  {  return hwMode!=0; }
  public boolean isWrapWithTrusted()  {  return exportLevelMode==EXPORT_WRAP_WITH_TRUSTED; }
  public String getName() { return name; }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy