/** * The constructor that takes a reference to the module and the slot ID. * * @param slot * The reference to the slot. * @preconditions (module <> null) * @postconditions */ protected Token(Slot slot) { this.slot = Util.requireNonNull("slot", slot); this.useUtf8Encoding = slot.isUseUtf8Encoding(); }
/** * Set if this mechanism can be used for digesting. * * @param digest * True, if this mechanism can be used for digesting. * @preconditions * @postconditions */ public void setDigest(boolean digest) { setFlagBit(PKCS11Constants.CKF_DIGEST, digest); }
/** * Create a new VersionParameters object with the given version. * * @param version * The version. * @preconditions * @postconditions */ public VersionParams(Version version) { this.version = Util.requireNonNull("version", version); }
private byte[] digestKey0(Session session, int digestLen, Mechanism mechanism, SecretKey key) throws TokenException { session.digestInit(mechanism); session.digestKey(key); byte[] digest = new byte[digestLen]; session.digestFinal(digest, 0, digestLen); return digest; }
/** * The overriding of this method should ensure that the objects of this * class work correctly in a hashtable. * * @return The hash code of this object. * @preconditions * @postconditions */ @Override public int hashCode() { return Util.hashCode(cb); }
/** * Get the date value of this attribute. Null, is also possible. * * @return The date value of this attribute or null. * @preconditions * @postconditions */ public Date getDateValue() { return Util.convertToDate((CK_DATE) ckAttribute.pValue); }
/** * Returns the string representation of this object. * * @return the string representation of object */ @Override public String toString() { return Util.concatObjects("Cryptoki Version: ", cryptokiVersion, "\nManufacturerID: ", manufacturerID, "\nLibrary Description: ", libraryDescription, "\nLibrary Version: ", libraryVersion); }
/** * Set if this mechanism can be used for signing. * * @param sign * True, if this mechanism can be used for signing. * @preconditions * @postconditions */ public void setSign(boolean sign) { setFlagBit(PKCS11Constants.CKF_SIGN, sign); }
/** * Set the key for the second EC private key value. * * @param privateData * The key for the second EC private key value. * @preconditions (privateData <> null) * @postconditions */ public void setPrivateData(PKCS11Object privateData) { this.privateData = Util.requireNonNull("privateData", privateData); }
/** * The overriding of this method should ensure that the objects of this * class work correctly in a hashtable. * * @return The hash code of this object. * @preconditions * @postconditions */ @Override public int hashCode() { return Util.hashCode(publicValue); }
/** * Set if this mechanism can be used for signing with data recovery. * * @param signRecover * True, if this mechanism can be used for signing with data * recovery. * @preconditions * @postconditions */ public void setSignRecover(boolean signRecover) { setFlagBit(PKCS11Constants.CKF_SIGN_RECOVER, signRecover); }
/** * Set the key for the second X9.42 private key value. * * @param privateData * The key for the second X9.42 private key value. * @preconditions (privateData <> null) * @postconditions */ public void setPrivateData(PKCS11Object privateData) { this.privateData = Util.requireNonNull("privateData", privateData); }
/** * Set if this mechanism can be used for verification with data recovery. * * @param verifyRecover * True, if this mechanism can be used for verification with data * recovery. * @preconditions * @postconditions */ public void setVerifyRecover(boolean verifyRecover) { setFlagBit(PKCS11Constants.CKF_VERIFY_RECOVER, verifyRecover); }
/** * Set the salt to be used in the PBE key generation. * * @param salt * The salt to be used in the PBE key generation. * @preconditions (salt <> null) * @postconditions */ public void setSalt(char[] salt) { this.salt = Util.requireNonNull("salt", salt);; }
/** * Set if this mechanism can be used for key wrapping. * * @param wrap * True, if this mechanism can be used for key wrapping. * @preconditions * @postconditions */ public void setWrap(boolean wrap) { setFlagBit(PKCS11Constants.CKF_WRAP, wrap); }
/** * Create a new InitializationVectorParameters object with the given * initialization vector. * * @param iv * The initialization vector. * @preconditions (initializationVector <> null) * @postconditions */ public IVParams(byte[] iv) { this.iv = Util.requireNonNull("iv", iv); }
/** * Set if this mechanism can be used for decryption. * * @param decrypt * True, if this mechanism can be used for decryption. * @preconditions * @postconditions */ public void setDecrypt(boolean decrypt) { setFlagBit(PKCS11Constants.CKF_DECRYPT, decrypt); }
/** * Set the server's random data. * * @param serverRandom * The server's random data. * @preconditions (serverRandom <> null) * @postconditions */ public void setServerRandom(byte[] serverRandom) { this.serverRandom = Util.requireNonNull("serverRandom", serverRandom); }
/** * Set if this mechanism can be used with EC domain parameters over Fp. * * @param ecFp * True, if this mechanism can be used with EC domain parameters * over Fp. * @preconditions * @postconditions */ public void setEcFp(boolean ecFp) { setFlagBit(PKCS11Constants.CKF_EC_F_P, ecFp); }