feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.pkcs11.wrapper;
/**
* This class represents the necessary parameters required by
* the CKM_AES_CTR mechanism as defined in CK_AES_CTR_PARAMS structure.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_AES_CTR_PARAMS {
* CK_ULONG ulCounterBits;
* CK_BYTE cb[16];
* } CK_AES_CTR_PARAMS;
* </PRE>
*
* @author Yu-Ching Valerie Peng
* @since 1.7
*/
public class CK_AES_CTR_PARAMS {
private final long ulCounterBits;
private final byte cb[];
public CK_AES_CTR_PARAMS(byte[] cb) {
ulCounterBits = 128;
this.cb = cb.clone();
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("ulCounterBits: ");
buffer.append(ulCounterBits);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("cb: ");
buffer.append(Functions.toHexString(cb));
return buffer.toString();
}
}
@@ -0,0 +1,229 @@
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
import java.math.BigInteger;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
/**
* class CK_ATTRIBUTE includes the type, value and length of an attribute.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_ATTRIBUTE {&nbsp;&nbsp;
* CK_ATTRIBUTE_TYPE type;&nbsp;&nbsp;
* CK_VOID_PTR pValue;&nbsp;&nbsp;
* CK_ULONG ulValueLen;
* } CK_ATTRIBUTE;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_ATTRIBUTE {
// common attributes
// NOTE that CK_ATTRIBUTE is a mutable classes but these attributes
// *MUST NEVER* be modified, e.g. by using them in a
// C_GetAttributeValue() call!
public final static CK_ATTRIBUTE TOKEN_FALSE =
new CK_ATTRIBUTE(CKA_TOKEN, false);
public final static CK_ATTRIBUTE SENSITIVE_FALSE =
new CK_ATTRIBUTE(CKA_SENSITIVE, false);
public final static CK_ATTRIBUTE EXTRACTABLE_TRUE =
new CK_ATTRIBUTE(CKA_EXTRACTABLE, true);
public final static CK_ATTRIBUTE ENCRYPT_TRUE =
new CK_ATTRIBUTE(CKA_ENCRYPT, true);
public final static CK_ATTRIBUTE DECRYPT_TRUE =
new CK_ATTRIBUTE(CKA_DECRYPT, true);
public final static CK_ATTRIBUTE WRAP_TRUE =
new CK_ATTRIBUTE(CKA_WRAP, true);
public final static CK_ATTRIBUTE UNWRAP_TRUE =
new CK_ATTRIBUTE(CKA_UNWRAP, true);
public final static CK_ATTRIBUTE SIGN_TRUE =
new CK_ATTRIBUTE(CKA_SIGN, true);
public final static CK_ATTRIBUTE VERIFY_TRUE =
new CK_ATTRIBUTE(CKA_VERIFY, true);
public final static CK_ATTRIBUTE SIGN_RECOVER_TRUE =
new CK_ATTRIBUTE(CKA_SIGN_RECOVER, true);
public final static CK_ATTRIBUTE VERIFY_RECOVER_TRUE =
new CK_ATTRIBUTE(CKA_VERIFY_RECOVER, true);
public final static CK_ATTRIBUTE DERIVE_TRUE =
new CK_ATTRIBUTE(CKA_DERIVE, true);
public final static CK_ATTRIBUTE ENCRYPT_NULL =
new CK_ATTRIBUTE(CKA_ENCRYPT);
public final static CK_ATTRIBUTE DECRYPT_NULL =
new CK_ATTRIBUTE(CKA_DECRYPT);
public final static CK_ATTRIBUTE WRAP_NULL =
new CK_ATTRIBUTE(CKA_WRAP);
public final static CK_ATTRIBUTE UNWRAP_NULL =
new CK_ATTRIBUTE(CKA_UNWRAP);
public CK_ATTRIBUTE() {
// empty
}
public CK_ATTRIBUTE(long type) {
this.type = type;
}
public CK_ATTRIBUTE(long type, Object pValue) {
this.type = type;
this.pValue = pValue;
}
public CK_ATTRIBUTE(long type, boolean value) {
this.type = type;
this.pValue = Boolean.valueOf(value);
}
public CK_ATTRIBUTE(long type, long value) {
this.type = type;
this.pValue = Long.valueOf(value);
}
public CK_ATTRIBUTE(long type, BigInteger value) {
this.type = type;
this.pValue = sun.security.pkcs11.P11Util.getMagnitude(value);
}
public BigInteger getBigInteger() {
if (pValue instanceof byte[] == false) {
throw new RuntimeException("Not a byte[]");
}
return new BigInteger(1, (byte[])pValue);
}
public boolean getBoolean() {
if (pValue instanceof Boolean == false) {
throw new RuntimeException
("Not a Boolean: " + pValue.getClass().getName());
}
return ((Boolean)pValue).booleanValue();
}
public char[] getCharArray() {
if (pValue instanceof char[] == false) {
throw new RuntimeException("Not a char[]");
}
return (char[])pValue;
}
public byte[] getByteArray() {
if (pValue instanceof byte[] == false) {
throw new RuntimeException("Not a byte[]");
}
return (byte[])pValue;
}
public long getLong() {
if (pValue instanceof Long == false) {
throw new RuntimeException
("Not a Long: " + pValue.getClass().getName());
}
return ((Long)pValue).longValue();
}
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ATTRIBUTE_TYPE type;
* </PRE>
*/
public long type;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VOID_PTR pValue;
* CK_ULONG ulValueLen;
* </PRE>
*/
public Object pValue;
/**
* Returns the string representation of CK_ATTRIBUTE.
*
* @return the string representation of CK_ATTRIBUTE
*/
public String toString() {
String prefix = Functions.getAttributeName(type) + " = ";
if (type == CKA_CLASS) {
return prefix + Functions.getObjectClassName(getLong());
} else if (type == CKA_KEY_TYPE) {
return prefix + Functions.getKeyName(getLong());
} else {
String s;
if (pValue instanceof char[]) {
s = new String((char[])pValue);
} else if (pValue instanceof byte[]) {
s = Functions.toHexString((byte[])pValue);
} else {
s = String.valueOf(pValue);
}
return prefix + s;
}
}
}
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.pkcs11.wrapper;
/**
* This class represents the necessary parameters required by
* the CKM_AES_CCM mechanism as defined in CK_CCM_PARAMS structure.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_CCM_PARAMS {
* CK_ULONG ulDataLen;
* CK_BYTE_PTR pNonce;
* CK_ULONG ulNonceLen;
* CK_BYTE_PTR pAAD;
* CK_ULONG ulAADLen;
* CK_ULONG ulMACLen;
* } CK_CCM_PARAMS;
* </PRE>
*
* @since 13
*/
public class CK_CCM_PARAMS {
private final long dataLen;
private final byte[] nonce;
private final byte[] aad;
private final long macLen;
public CK_CCM_PARAMS(int tagLen, byte[] iv, byte[] aad, int dataLen) {
this.dataLen = dataLen;
this.nonce = iv;
this.aad = aad;
this.macLen = tagLen;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(Constants.INDENT);
sb.append("ulDataLen: ");
sb.append(dataLen);
sb.append(Constants.NEWLINE);
sb.append(Constants.INDENT);
sb.append("iv: ");
sb.append(Functions.toHexString(nonce));
sb.append(Constants.NEWLINE);
sb.append(Constants.INDENT);
sb.append("aad: ");
sb.append(Functions.toHexString(aad));
sb.append(Constants.NEWLINE);
sb.append(Constants.INDENT);
sb.append("tagLen: ");
sb.append(macLen);
return sb.toString();
}
}
@@ -0,0 +1,68 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* interface CK_CREATEMUTEX.
*
* @author Karl Scheibelhofer &lt;Karl.Scheibelhofer@iaik.at&gt;
* @author Martin Schlaeffer &lt;schlaeff@sbox.tugraz.at&gt;
*/
public interface CK_CREATEMUTEX {
/**
* Method CK_CREATEMUTEX
*
* @return The mutex (lock) object.
* @exception PKCS11Exception
*/
public Object CK_CREATEMUTEX() throws PKCS11Exception;
}
@@ -0,0 +1,120 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_C_INITIALIZE_ARGS contains the optional arguments for the
* C_Initialize function.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_C_INITIALIZE_ARGS {&nbsp;&nbsp;
* CK_CREATEMUTEX CreateMutex;&nbsp;&nbsp;
* CK_DESTROYMUTEX DestroyMutex;&nbsp;&nbsp;
* CK_LOCKMUTEX LockMutex;&nbsp;&nbsp;
* CK_UNLOCKMUTEX UnlockMutex;&nbsp;&nbsp;
* CK_FLAGS flags;&nbsp;&nbsp;
* CK_VOID_PTR pReserved;&nbsp;&nbsp;
* } CK_C_INITIALIZE_ARGS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_C_INITIALIZE_ARGS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_CREATEMUTEX CreateMutex;
* </PRE>
*/
public CK_CREATEMUTEX CreateMutex;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_DESTROYMUTEX DestroyMutex;
* </PRE>
*/
public CK_DESTROYMUTEX DestroyMutex;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_LOCKMUTEX LockMutex;
* </PRE>
*/
public CK_LOCKMUTEX LockMutex;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_UNLOCKMUTEX UnlockMutex;
* </PRE>
*/
public CK_UNLOCKMUTEX UnlockMutex;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_FLAGS flags;
* </PRE>
*/
public long flags;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VOID_PTR pReserved;
* </PRE>
*/
public Object pReserved;
}
@@ -0,0 +1,137 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class .<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_DATE {&nbsp;&nbsp;
* CK_CHAR year[4];&nbsp;&nbsp;
* CK_CHAR month[2];&nbsp;&nbsp;
* CK_CHAR day[2];&nbsp;&nbsp;
* } CK_DATE;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_DATE implements Cloneable {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_CHAR year[4]; - the year ("1900" - "9999")
* </PRE>
*/
public char[] year; /* the year ("1900" - "9999") */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_CHAR month[2]; - the month ("01" - "12")
* </PRE>
*/
public char[] month; /* the month ("01" - "12") */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_CHAR day[2]; - the day ("01" - "31")
* </PRE>
*/
public char[] day; /* the day ("01" - "31") */
public CK_DATE(char[] year, char[] month, char[] day) {
this.year = year;
this.month = month;
this.day = day;
}
/**
* Create a (deep) clone of this object.
*
* @return A clone of this object.
*/
public Object clone() {
CK_DATE copy = null;
try {
copy = (CK_DATE) super.clone();
} catch (CloneNotSupportedException cnse) {
// re-throw as RuntimeException
throw (RuntimeException)
(new RuntimeException("Clone error").initCause(cnse));
}
copy.year = this.year.clone();
copy.month = this.month.clone();
copy.day = this.day.clone();
return copy;
}
/**
* Returns the string representation of CK_DATE.
*
* @return the string representation of CK_DATE
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(new String(day));
buffer.append('.');
buffer.append(new String(month));
buffer.append('.');
buffer.append(new String(year));
buffer.append(" (DD.MM.YYYY)");
return buffer.toString();
}
}
@@ -0,0 +1,68 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* interface CK_DESTROYMUTEX.<p>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public interface CK_DESTROYMUTEX {
/**
* Method CK_DESTROYMUTEX
*
* @param pMutex The mutex (lock) object.
* @exception PKCS11Exception
*/
public void CK_DESTROYMUTEX(Object pMutex) throws PKCS11Exception;
}
@@ -0,0 +1,138 @@
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_ECDH1_DERIVE_PARAMS provides the parameters to the
* CKM_ECDH1_DERIVE and CKM_ECDH1_COFACTOR_DERIVE mechanisms.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_ECDH1_DERIVE_PARAMS {
* CK_EC_KDF_TYPE kdf;
* CK_ULONG ulSharedDataLen;
* CK_BYTE_PTR pSharedData;
* CK_ULONG ulPublicDataLen;
* CK_BYTE_PTR pPublicData;
* } CK_ECDH1_DERIVE_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
*/
public class CK_ECDH1_DERIVE_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_EC_KDF_TYPE kdf;
* </PRE>
*/
public long kdf;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulSharedDataLen;
* CK_BYTE_PTR pSharedData;
* </PRE>
*/
public byte[] pSharedData;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulPublicDataLen;
* CK_BYTE_PTR pPublicData;
* </PRE>
*/
public byte[] pPublicData;
public CK_ECDH1_DERIVE_PARAMS(long kdf, byte[] pSharedData, byte[] pPublicData) {
this.kdf = kdf;
this.pSharedData = pSharedData;
this.pPublicData = pPublicData;
}
/**
* Returns the string representation of CK_PKCS5_PBKD2_PARAMS.
*
* @return the string representation of CK_PKCS5_PBKD2_PARAMS
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("kdf: 0x");
buffer.append(Functions.toFullHexString(kdf));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pSharedDataLen: ");
buffer.append(pSharedData.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pSharedData: ");
buffer.append(Functions.toHexString(pSharedData));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicDataLen: ");
buffer.append(pPublicData.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicData: ");
buffer.append(Functions.toHexString(pPublicData));
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,181 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_ECDH2_DERIVE_PARAMS provides the parameters to the
* CKM_ECMQV_DERIVE mechanism.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_ECDH2_DERIVE_PARAMS {
* CK_EC_KDF_TYPE kdf;
* CK_ULONG ulSharedDataLen;
* CK_BYTE_PTR pSharedData;
* CK_ULONG ulPublicDataLen;
* CK_BYTE_PTR pPublicData;
* CK_ULONG ulPrivateDataLen;
* CK_OBJECT_HANDLE hPrivateData;
* CK_ULONG ulPublicDataLen2;
* CK_BYTE_PTR pPublicData2;
* } CK_ECDH2_DERIVE_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
*/
public class CK_ECDH2_DERIVE_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_EC_KDF_TYPE kdf;
* </PRE>
*/
public long kdf;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulSharedDataLen;
* CK_BYTE_PTR pSharedData;
* </PRE>
*/
public byte[] pSharedData;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulPublicDataLen;
* CK_BYTE_PTR pPublicData;
* </PRE>
*/
public byte[] pPublicData;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulPrivateDataLen;
* </PRE>
*/
public long ulPrivateDataLen;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_OBJECT_HANDLE hPrivateData;
* </PRE>
*/
public long hPrivateData;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulPublicDataLen2;
* CK_BYTE_PTR pPublicData2;
* </PRE>
*/
public byte[] pPublicData2;
/**
* Returns the string representation of CK_PKCS5_PBKD2_PARAMS.
*
* @return the string representation of CK_PKCS5_PBKD2_PARAMS
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("kdf: 0x");
buffer.append(Functions.toFullHexString(kdf));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pSharedDataLen: ");
buffer.append(pSharedData.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pSharedData: ");
buffer.append(Functions.toHexString(pSharedData));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicDataLen: ");
buffer.append(pPublicData.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicData: ");
buffer.append(Functions.toHexString(pPublicData));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulPrivateDataLen: ");
buffer.append(ulPrivateDataLen);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("hPrivateData: ");
buffer.append(hPrivateData);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicDataLen2: ");
buffer.append(pPublicData2.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicData2: ");
buffer.append(Functions.toHexString(pPublicData2));
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.pkcs11.wrapper;
/**
* This class represents the necessary parameters required by
* the CKM_AES_GCM mechanism as defined in CK_GCM_PARAMS structure.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_GCM_PARAMS {
* CK_BYTE_PTR pIv;
* CK_ULONG ulIvLen;
* CK_BYTE_PTR pAAD;
* CK_ULONG ulAADLen;
* CK_ULONG ulTagBits;
* } CK_GCM_PARAMS;
* </PRE>
*
* @since 10
*/
public class CK_GCM_PARAMS {
private final byte[] iv;
private final byte[] aad;
private final long tagBits;
public CK_GCM_PARAMS(int tagLenInBits, byte[] iv, byte[] aad) {
this.iv = iv;
this.aad = aad;
this.tagBits = tagLenInBits;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(Constants.INDENT);
sb.append("iv: ");
sb.append(Functions.toHexString(iv));
sb.append(Constants.NEWLINE);
sb.append(Constants.INDENT);
sb.append("aad: ");
sb.append(Functions.toHexString(aad));
sb.append(Constants.NEWLINE);
sb.append(Constants.INDENT);
sb.append("tagLen(in bits): ");
sb.append(tagBits);
return sb.toString();
}
}
@@ -0,0 +1,164 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_INFO provides general information about Cryptoki.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_INFO {&nbsp;&nbsp;
* CK_VERSION cryptokiVersion;&nbsp;&nbsp;
* CK_UTF8CHAR manufacturerID[32];&nbsp;&nbsp;
* CK_FLAGS flags;&nbsp;&nbsp;
* CK_UTF8CHAR libraryDescription[32];&nbsp;&nbsp;
* CK_VERSION libraryVersion;&nbsp;&nbsp;
* } CK_INFO;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_INFO {
/**
* Cryptoki interface version number<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_VERSION cryptokiVersion;
* </PRE>
*/
public CK_VERSION cryptokiVersion;
/**
* ID of the Cryptoki library manufacturer. must be blank
* padded - only the first 32 chars will be used<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_UTF8CHAR manufacturerID[32];
* </PRE>
*/
public char[] manufacturerID;
/**
* bit flags reserved for future versions. must be zero<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_FLAGS flags;
* </PRE>
*/
public long flags;
/* libraryDescription and libraryVersion are new for v2.0 */
/**
* must be blank padded - only the first 32 chars will be used<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_UTF8CHAR libraryDescription[32];
* </PRE>
*/
public char[] libraryDescription;
/**
* Cryptoki library version number<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_VERSION libraryVersion;
* </PRE>
*/
public CK_VERSION libraryVersion;
public CK_INFO(CK_VERSION cryptoVer, char[] vendor, long flags,
char[] libDesc, CK_VERSION libVer) {
this.cryptokiVersion = cryptoVer;
this.manufacturerID = vendor;
this.flags = flags;
this.libraryDescription = libDesc;
this.libraryVersion = libVer;
}
/**
* Returns the string representation of CK_INFO.
*
* @return the string representation of CK_INFO
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("cryptokiVersion: ");
buffer.append(cryptokiVersion.toString());
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("manufacturerID: ");
buffer.append(new String(manufacturerID));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("flags: ");
buffer.append(Functions.toBinaryString(flags));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("libraryDescription: ");
buffer.append(new String(libraryDescription));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("libraryVersion: ");
buffer.append(libraryVersion.toString());
//buffer.append(Constants.NEWLINE);
return buffer.toString() ;
}
}
@@ -0,0 +1,68 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* interface CK_LOCKMUTEX<p>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public interface CK_LOCKMUTEX {
/**
* Method CK_LOCKMUTEX
*
* @param pMutex The mutex (lock) object to lock.
* @exception PKCS11Exception
*/
public void CK_LOCKMUTEX(Object pMutex) throws PKCS11Exception;
}
@@ -0,0 +1,213 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
import java.math.BigInteger;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
/**
* class CK_MECHANISM specifies a particular mechanism and any parameters it
* requires.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_MECHANISM {&nbsp;&nbsp;
* CK_MECHANISM_TYPE mechanism;&nbsp;&nbsp;
* CK_VOID_PTR pParameter;&nbsp;&nbsp;
* CK_ULONG ulParameterLen;&nbsp;&nbsp;
* } CK_MECHANISM;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_MECHANISM {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_MECHANISM_TYPE mechanism;
* </PRE>
*/
public long mechanism;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VOID_PTR pParameter;
* CK_ULONG ulParameterLen;
* </PRE>
*/
public Object pParameter = null;
// pointer to native CK_MECHANISM structure
// For mechanisms which have only mechanism id, the native structure
// can be freed right after init and this field will not be used. However,
// for mechanisms which have both mechanism id and parameters, it can
// only be freed after operation is finished. Thus, the native pointer
// will be stored here and then be explicitly freed by caller.
private long pHandle = 0L;
public CK_MECHANISM(long mechanism) {
this.mechanism = mechanism;
}
// We don't have a (long,Object) constructor to force type checking.
// This makes sure we don't accidentally pass a class that the native
// code cannot handle.
public CK_MECHANISM(long mechanism, byte[] pParameter) {
init(mechanism, pParameter);
}
public CK_MECHANISM(long mechanism, BigInteger b) {
init(mechanism, sun.security.pkcs11.P11Util.getMagnitude(b));
}
public CK_MECHANISM(long mechanism, CK_VERSION version) {
init(mechanism, version);
}
public CK_MECHANISM(long mechanism, CK_SSL3_MASTER_KEY_DERIVE_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_TLS12_MASTER_KEY_DERIVE_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_SSL3_KEY_MAT_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_TLS12_KEY_MAT_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_TLS_PRF_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_TLS_MAC_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_ECDH1_DERIVE_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, Long params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_AES_CTR_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_GCM_PARAMS params) {
init(mechanism, params);
}
public CK_MECHANISM(long mechanism, CK_CCM_PARAMS params) {
init(mechanism, params);
}
// For PSS. the parameter may be set multiple times, use the
// CK_MECHANISM(long) constructor and setParameter(CK_RSA_PKCS_PSS_PARAMS)
// methods instead of creating yet another constructor
public void setParameter(CK_RSA_PKCS_PSS_PARAMS params) {
assert(this.mechanism == CKM_RSA_PKCS_PSS);
assert(params != null);
if (this.pParameter != null && this.pParameter.equals(params)) {
return;
}
freeHandle();
this.pParameter = params;
}
public void freeHandle() {
if (this.pHandle != 0L) {
this.pHandle = PKCS11.freeMechanism(pHandle);
}
}
private void init(long mechanism, Object pParameter) {
this.mechanism = mechanism;
this.pParameter = pParameter;
}
/**
* Returns the string representation of CK_MECHANISM.
*
* @return the string representation of CK_MECHANISM
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("mechanism: ");
buffer.append(mechanism);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pParameter: ");
buffer.append(pParameter.toString());
buffer.append(Constants.NEWLINE);
/*
buffer.append(Constants.INDENT);
buffer.append("ulParameterLen: ??");
buffer.append(Constants.NEWLINE);
*/
if (pHandle != 0L) {
buffer.append(Constants.INDENT);
buffer.append("pHandle: ");
buffer.append(pHandle);
buffer.append(Constants.NEWLINE);
}
return buffer.toString() ;
}
}
@@ -0,0 +1,163 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
import java.security.ProviderException;
/**
* class CK_MECHANISM_INFO provides information about a particular mechanism.
* <p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_MECHANISM_INFO {&nbsp;&nbsp;
* CK_ULONG ulMinKeySize;&nbsp;&nbsp;
* CK_ULONG ulMaxKeySize;&nbsp;&nbsp;
* CK_FLAGS flags;&nbsp;&nbsp;
* } CK_MECHANISM_INFO;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_MECHANISM_INFO {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMinKeySize;
* </PRE>
*/
public long ulMinKeySize;
// the integer version of ulMinKeySize for doing the actual range
// check in SunPKCS11 provider, defaults to 0
public final int iMinKeySize;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMaxKeySize;
* </PRE>
*/
public long ulMaxKeySize;
// the integer version of ulMaxKeySize for doing the actual range
// check in SunPKCS11 provider, defaults to Integer.MAX_VALUE
public final int iMaxKeySize;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_FLAGS flags;
* </PRE>
*/
public long flags;
public CK_MECHANISM_INFO(long minKeySize, long maxKeySize,
long flags) {
this.ulMinKeySize = minKeySize;
this.ulMaxKeySize = maxKeySize;
this.iMinKeySize = ((minKeySize < Integer.MAX_VALUE && minKeySize > 0)?
(int)minKeySize : 0);
this.iMaxKeySize = ((maxKeySize < Integer.MAX_VALUE && maxKeySize > 0)?
(int)maxKeySize : Integer.MAX_VALUE);
this.flags = flags;
}
/**
* Returns the string representation of CK_MECHANISM_INFO.
*
* @return the string representation of CK_MECHANISM_INFO
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("ulMinKeySize: ");
buffer.append(String.valueOf(ulMinKeySize));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulMaxKeySize: ");
buffer.append(String.valueOf(ulMaxKeySize));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("flags: ");
buffer.append(String.valueOf(flags));
buffer.append(" = ");
buffer.append(Functions.mechanismInfoFlagsToString(flags));
//buffer.append(Constants.NEWLINE);
return buffer.toString() ;
}
}
@@ -0,0 +1,70 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* interface CK_NOTIFY.<p>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public interface CK_NOTIFY {
/**
* Method CK_NOTIFY
*
* @param hSession
* @param event
* @param pApplication
* @exception PKCS11Exception
*/
public void CK_NOTIFY(long hSession, long event, Object pApplication) throws PKCS11Exception;
}
@@ -0,0 +1,142 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_PBE_PARAMS provides all of the necessary information required byte
* the CKM_PBE mechanisms and the CKM_PBA_SHA1_WITH_SHA1_HMAC mechanism.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_PBE_PARAMS {
* CK_CHAR_PTR pInitVector;
* CK_CHAR_PTR pPassword;
* CK_ULONG ulPasswordLen;
* CK_CHAR_PTR pSalt;
* CK_ULONG ulSaltLen;
* CK_ULONG ulIteration;
* } CK_PBE_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_PBE_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_CHAR_PTR pInitVector;
* </PRE>
*/
public char[] pInitVector;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_CHAR_PTR pPassword;
* CK_ULONG ulPasswordLen;
* </PRE>
*/
public char[] pPassword;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_CHAR_PTR pSalt
* CK_ULONG ulSaltLen;
* </PRE>
*/
public char[] pSalt;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulIteration;
* </PRE>
*/
public long ulIteration;
/**
* Returns the string representation of CK_PBE_PARAMS.
*
* @return the string representation of CK_PBE_PARAMS
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("pInitVector: ");
buffer.append(pInitVector);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulPasswordLen: ");
buffer.append(pPassword.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulSaltLen: ");
buffer.append(pSalt.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pSalt: ");
buffer.append(pSalt);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulIteration: ");
buffer.append(ulIteration);
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,161 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_PKCS5_PBKD2_PARAMS provides the parameters to the CKM_PKCS5_PBKD2
* mechanism.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_PKCS5_PBKD2_PARAMS {
* CK_PKCS5_PBKD2_SALT_SOURCE_TYPE saltSource;
* CK_VOID_PTR pSaltSourceData;
* CK_ULONG ulSaltSourceDataLen;
* CK_ULONG iterations;
* CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf;
* CK_VOID_PTR pPrfData;
* CK_ULONG ulPrfDataLen;
* } CK_PKCS5_PBKD2_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_PKCS5_PBKD2_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE saltSource;
* </PRE>
*/
public long saltSource;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VOID_PTR pSaltSourceData;
* CK_ULONG ulSaltSourceDataLen;
* </PRE>
*/
public byte[] pSaltSourceData;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG iterations;
* </PRE>
*/
public long iterations;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf;
* </PRE>
*/
public long prf;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VOID_PTR pPrfData;
* CK_ULONG ulPrfDataLen;
* </PRE>
*/
public byte[] pPrfData;
/**
* Returns the string representation of CK_PKCS5_PBKD2_PARAMS.
*
* @return the string representation of CK_PKCS5_PBKD2_PARAMS
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("saltSource: ");
buffer.append(saltSource);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pSaltSourceData: ");
buffer.append(Functions.toHexString(pSaltSourceData));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulSaltSourceDataLen: ");
buffer.append(pSaltSourceData.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("iterations: ");
buffer.append(iterations);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("prf: ");
buffer.append(prf);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPrfData: ");
buffer.append(Functions.toHexString(pPrfData));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulPrfDataLen: ");
buffer.append(pPrfData.length);
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,143 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_RSA_PKCS_OAEP_PARAMS provides the parameters to the
* CKM_RSA_PKCS_OAEP mechanism.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_RSA_PKCS_OAEP_PARAMS {
* CK_MECHANISM_TYPE hashAlg;
* CK_RSA_PKCS_OAEP_MGF_TYPE mgf;
* CK_RSA_PKCS_OAEP_SOURCE_TYPE source;
* CK_VOID_PTR pSourceData;
* CK_ULONG ulSourceDataLen;
* } CK_RSA_PKCS_OAEP_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_RSA_PKCS_OAEP_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_MECHANISM_TYPE hashAlg;
* </PRE>
*/
public long hashAlg;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_RSA_PKCS_OAEP_MGF_TYPE mgf;
* </PRE>
*/
public long mgf;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_RSA_PKCS_OAEP_SOURCE_TYPE source;
* </PRE>
*/
public long source;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VOID_PTR pSourceData;
* CK_ULONG ulSourceDataLen;
* </PRE>
*/
public byte[] pSourceData;
//CK_ULONG ulSourceDataLen;
// ulSourceDataLen == pSourceData.length
/**
* Returns the string representation of CK_RSA_PKCS_OAEP_PARAMS.
*
* @return the string representation of CK_RSA_PKCS_OAEP_PARAMS
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("hashAlg: ");
buffer.append(hashAlg);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("mgf: ");
buffer.append(mgf);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("source: ");
buffer.append(source);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pSourceData: ");
buffer.append(pSourceData.toString());
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pSourceDataLen: ");
buffer.append(Functions.toHexString(pSourceData));
//buffer.append(Constants.NEWLINE);
return buffer.toString() ;
}
}
@@ -0,0 +1,104 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.pkcs11.wrapper;
import java.security.ProviderException;
import java.security.spec.PSSParameterSpec;
import java.security.spec.MGF1ParameterSpec;
/**
* This class represents the necessary parameters required by the
* CKM_RSA_PKCS_PSS mechanism as defined in CK_RSA_PKCS_PSS_PARAMS structure.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_RSA_PKCS_PSS_PARAMS {
* CK_MECHANISM_TYPE hashAlg;
* CK_RSA_PKCS_MGF_TYPE mgf;
* CK_ULONG sLen;
* } CK_RSA_PKCS_PSS_PARAMS;
* </PRE>
*
* @since 13
*/
public class CK_RSA_PKCS_PSS_PARAMS {
private final long hashAlg;
private final long mgf;
private final long sLen;
public CK_RSA_PKCS_PSS_PARAMS(String hashAlg, String mgfAlg,
String mgfHash, int sLen) {
this.hashAlg = Functions.getHashMechId(hashAlg);
if (!mgfAlg.equals("MGF1")) {
throw new ProviderException("Only MGF1 is supported");
}
// no dash in PKCS#11 mechanism names
this.mgf = Functions.getMGFId("CKG_MGF1_" + hashAlg.replaceFirst("-", ""));
this.sLen = sLen;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof CK_RSA_PKCS_PSS_PARAMS)) {
return false;
}
CK_RSA_PKCS_PSS_PARAMS other = (CK_RSA_PKCS_PSS_PARAMS) o;
return ((other.hashAlg == hashAlg) &&
(other.mgf == mgf) &&
(other.sLen == sLen));
}
@Override
public int hashCode() {
return (int)(hashAlg << 2 + mgf << 1 + sLen);
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("hashAlg: ");
buffer.append(Functions.toFullHexString(hashAlg));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("mgf: ");
buffer.append(Functions.toFullHexString(mgf));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("sLen(in bytes): ");
buffer.append(sLen);
return buffer.toString();
}
}
@@ -0,0 +1,142 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_SESSION_INFO provides information about a session.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_SESSION_INFO {&nbsp;&nbsp;
* CK_SLOT_ID slotID;&nbsp;&nbsp;
* CK_STATE state;&nbsp;&nbsp;
* CK_FLAGS flags;&nbsp;&nbsp;
* CK_ULONG ulDeviceError;&nbsp;&nbsp;
* } CK_SESSION_INFO;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_SESSION_INFO {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_SLOT_ID slotID;
* </PRE>
*/
public long slotID;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_STATE state;
* </PRE>
*/
public long state;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_FLAGS flags;
* </PRE>
*/
public long flags; /* see below */
/* ulDeviceError was changed from CK_USHORT to CK_ULONG for
* v2.0 */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulDeviceError;
* </PRE>
*/
public long ulDeviceError; /* device-dependent error code */
public CK_SESSION_INFO(long slotID, long state,
long flags, long ulDeviceError) {
this.slotID = slotID;
this.state = state;
this.flags = flags;
this.ulDeviceError = ulDeviceError;
}
/**
* Returns the string representation of CK_SESSION_INFO.
*
* @return the string representation of CK_SESSION_INFO
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("slotID: ");
buffer.append(String.valueOf(slotID));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("state: ");
buffer.append(Functions.sessionStateToString(state));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("flags: ");
buffer.append(Functions.sessionInfoFlagsToString(flags));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulDeviceError: ");
buffer.append(Functions.toHexString(ulDeviceError));
//buffer.append(Constants.NEWLINE);
return buffer.toString() ;
}
}
@@ -0,0 +1,163 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_SLOT_INFO provides information about a slot.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_SLOT_INFO {&nbsp;&nbsp;
* CK_UTF8CHAR slotDescription[64];&nbsp;&nbsp;
* CK_UTF8CHAR manufacturerID[32];&nbsp;&nbsp;
* CK_FLAGS flags;&nbsp;&nbsp;
* CK_VERSION hardwareVersion;&nbsp;&nbsp;
* CK_VERSION firmwareVersion;&nbsp;&nbsp;
* } CK_SLOT_INFO;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_SLOT_INFO {
/* slotDescription and manufacturerID have been changed from
* CK_CHAR to CK_UTF8CHAR for v2.11. */
/**
* must be blank padded and only the first 64 chars will be used<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_UTF8CHAR slotDescription[64];
* </PRE>
*/
public char[] slotDescription;
/**
* must be blank padded and only the first 32 chars will be used<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_UTF8CHAR manufacturerID[32];
* </PRE>
*/
public char[] manufacturerID;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_FLAGS flags;
* </PRE>
*/
public long flags;
/* hardwareVersion and firmwareVersion are new for v2.0 */
/**
* version of hardware<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_VERSION hardwareVersion;
* </PRE>
*/
public CK_VERSION hardwareVersion;
/**
* version of firmware<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_VERSION firmwareVersion;
* </PRE>
*/
public CK_VERSION firmwareVersion;
public CK_SLOT_INFO(char[] slotDesc, char[] vendor,
long flags, CK_VERSION hwVer, CK_VERSION fwVer) {
this.slotDescription = slotDesc;
this.manufacturerID = vendor;
this.flags = flags;
this.hardwareVersion = hwVer;
this.firmwareVersion = fwVer;
}
/**
* Returns the string representation of CK_SLOT_INFO.
*
* @return the string representation of CK_SLOT_INFO
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("slotDescription: ");
buffer.append(new String(slotDescription));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("manufacturerID: ");
buffer.append(new String(manufacturerID));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("flags: ");
buffer.append(Functions.slotInfoFlagsToString(flags));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("hardwareVersion: ");
buffer.append(hardwareVersion.toString());
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("firmwareVersion: ");
buffer.append(firmwareVersion.toString());
//buffer.append(Constants.NEWLINE);
return buffer.toString() ;
}
}
@@ -0,0 +1,162 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_SSL3_KEY_MAT_OUT contains the resulting key handles and
* initialization vectors after performing a C_DeriveKey function with the
* CKM_SSL3_KEY_AND_MAC_DERIVE mechanism.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_SSL3_KEY_MAT_OUT {
* CK_OBJECT_HANDLE hClientMacSecret;
* CK_OBJECT_HANDLE hServerMacSecret;
* CK_OBJECT_HANDLE hClientKey;
* CK_OBJECT_HANDLE hServerKey;
* CK_BYTE_PTR pIVClient;
* CK_BYTE_PTR pIVServer;
* } CK_SSL3_KEY_MAT_OUT;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_SSL3_KEY_MAT_OUT{
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_OBJECT_HANDLE hClientMacSecret;
* </PRE>
*/
public long hClientMacSecret;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_OBJECT_HANDLE hServerMacSecret;
* </PRE>
*/
public long hServerMacSecret;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_OBJECT_HANDLE hClientKey;
* </PRE>
*/
public long hClientKey;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_OBJECT_HANDLE hServerKey;
* </PRE>
*/
public long hServerKey;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_BYTE_PTR pIVClient;
* </PRE>
*/
public byte[] pIVClient;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_BYTE_PTR pIVServer;
* </PRE>
*/
public byte[] pIVServer;
/**
* Returns the string representation of CK_SSL3_KEY_MAT_OUT.
*
* @return the string representation of CK_SSL3_KEY_MAT_OUT
*/
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(Constants.INDENT);
buffer.append("hClientMacSecret: ");
buffer.append(hClientMacSecret);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("hServerMacSecret: ");
buffer.append(hServerMacSecret);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("hClientKey: ");
buffer.append(hClientKey);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("hServerKey: ");
buffer.append(hServerKey);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pIVClient: ");
buffer.append(Functions.toHexString(pIVClient));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pIVServer: ");
buffer.append(Functions.toHexString(pIVServer));
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,175 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_SSL3_KEY_MAT_PARAMS provides the parameters to the
* CKM_SSL3_KEY_AND_MAC_DERIVE mechanism.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_SSL3_KEY_MAT_PARAMS {
* CK_ULONG ulMacSizeInBits;
* CK_ULONG ulKeySizeInBits;
* CK_ULONG ulIVSizeInBits;
* CK_BBOOL bIsExport;
* CK_SSL3_RANDOM_DATA RandomInfo;
* CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial;
* } CK_SSL3_KEY_MAT_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_SSL3_KEY_MAT_PARAMS{
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMacSizeInBits;
* </PRE>
*/
public long ulMacSizeInBits;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulKeySizeInBits;
* </PRE>
*/
public long ulKeySizeInBits;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulIVSizeInBits;
* </PRE>
*/
public long ulIVSizeInBits;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_BBOOL bIsExport;
* </PRE>
*/
public boolean bIsExport;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_SSL3_RANDOM_DATA RandomInfo;
* </PRE>
*/
public CK_SSL3_RANDOM_DATA RandomInfo;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial;
* </PRE>
*/
public CK_SSL3_KEY_MAT_OUT pReturnedKeyMaterial;
public CK_SSL3_KEY_MAT_PARAMS(int macSize, int keySize, int ivSize, boolean export, CK_SSL3_RANDOM_DATA random) {
ulMacSizeInBits = macSize;
ulKeySizeInBits = keySize;
ulIVSizeInBits = ivSize;
bIsExport = export;
RandomInfo = random;
pReturnedKeyMaterial = new CK_SSL3_KEY_MAT_OUT();
if (ivSize != 0) {
int n = ivSize >> 3;
pReturnedKeyMaterial.pIVClient = new byte[n];
pReturnedKeyMaterial.pIVServer = new byte[n];
}
}
/**
* Returns the string representation of CK_SSL3_KEY_MAT_PARAMS.
*
* @return the string representation of CK_SSL3_KEY_MAT_PARAMS
*/
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(Constants.INDENT);
buffer.append("ulMacSizeInBits: ");
buffer.append(ulMacSizeInBits);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulKeySizeInBits: ");
buffer.append(ulKeySizeInBits);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulIVSizeInBits: ");
buffer.append(ulIVSizeInBits);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("bIsExport: ");
buffer.append(bIsExport);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("RandomInfo: ");
buffer.append(RandomInfo);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pReturnedKeyMaterial: ");
buffer.append(pReturnedKeyMaterial);
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,110 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_SSL3_MASTER_KEY_DERIVE_PARAMS provides the parameters to the
* CKM_SSL3_MASTER_KEY_DERIVE mechanism.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS {
* CK_SSL3_RANDOM_DATA RandomInfo;
* CK_VERSION_PTR pVersion;
* } CK_SSL3_MASTER_KEY_DERIVE_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_SSL3_MASTER_KEY_DERIVE_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_SSL3_RANDOM_DATA RandomInfo;
* </PRE>
*/
public CK_SSL3_RANDOM_DATA RandomInfo;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VERSION_PTR pVersion;
* </PRE>
*/
public CK_VERSION pVersion;
public CK_SSL3_MASTER_KEY_DERIVE_PARAMS(CK_SSL3_RANDOM_DATA random, CK_VERSION version) {
RandomInfo = random;
pVersion = version;
}
/**
* Returns the string representation of CK_SSL3_MASTER_KEY_DERIVE_PARAMS.
*
* @return the string representation of CK_SSL3_MASTER_KEY_DERIVE_PARAMS
*/
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(Constants.INDENT);
buffer.append("RandomInfo: ");
buffer.append(RandomInfo);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pVersion: ");
buffer.append(pVersion);
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,126 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_SSL3_RANDOM_DATA provides information about the random data of a
* client and a server in an SSL context. This class is used by both the
* CKM_SSL3_MASTER_KEY_DERIVE and the CKM_SSL3_KEY_AND_MAC_DERIVE mechanisms.
* <p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_SSL3_RANDOM_DATA {
* CK_BYTE_PTR pClientRandom;
* CK_ULONG ulClientRandomLen;
* CK_BYTE_PTR pServerRandom;
* CK_ULONG ulServerRandomLen;
* } CK_SSL3_RANDOM_DATA;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_SSL3_RANDOM_DATA {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_BYTE_PTR pClientRandom;
* CK_ULONG ulClientRandomLen;
* </PRE>
*/
public byte[] pClientRandom;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_BYTE_PTR pServerRandom;
* CK_ULONG ulServerRandomLen;
* </PRE>
*/
public byte[] pServerRandom;
public CK_SSL3_RANDOM_DATA(byte[] clientRandom, byte[] serverRandom) {
pClientRandom = clientRandom;
pServerRandom = serverRandom;
}
/**
* Returns the string representation of CK_SSL3_RANDOM_DATA.
*
* @return the string representation of CK_SSL3_RANDOM_DATA
*/
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(Constants.INDENT);
buffer.append("pClientRandom: ");
buffer.append(Functions.toHexString(pClientRandom));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulClientRandomLen: ");
buffer.append(pClientRandom.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pServerRandom: ");
buffer.append(Functions.toHexString(pServerRandom));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulServerRandomLen: ");
buffer.append(pServerRandom.length);
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,151 @@
/*
* Copyright (c) 2018, Red Hat, Inc. and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.pkcs11.wrapper;
/**
* CK_TLS12_KEY_MAT_PARAMS from PKCS#11 v2.40.
*/
public class CK_TLS12_KEY_MAT_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMacSizeInBits;
* </PRE>
*/
public long ulMacSizeInBits;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulKeySizeInBits;
* </PRE>
*/
public long ulKeySizeInBits;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulIVSizeInBits;
* </PRE>
*/
public long ulIVSizeInBits;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_BBOOL bIsExport;
* </PRE>
*/
public boolean bIsExport;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_SSL3_RANDOM_DATA RandomInfo;
* </PRE>
*/
public CK_SSL3_RANDOM_DATA RandomInfo;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial;
* </PRE>
*/
public CK_SSL3_KEY_MAT_OUT pReturnedKeyMaterial;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_MECHANISM_TYPE prfHashMechanism;
* </PRE>
*/
public long prfHashMechanism;
public CK_TLS12_KEY_MAT_PARAMS(
int macSize, int keySize, int ivSize, boolean export,
CK_SSL3_RANDOM_DATA random, long prfHashMechanism) {
ulMacSizeInBits = macSize;
ulKeySizeInBits = keySize;
ulIVSizeInBits = ivSize;
bIsExport = export;
RandomInfo = random;
pReturnedKeyMaterial = new CK_SSL3_KEY_MAT_OUT();
if (ivSize != 0) {
int n = ivSize >> 3;
pReturnedKeyMaterial.pIVClient = new byte[n];
pReturnedKeyMaterial.pIVServer = new byte[n];
}
this.prfHashMechanism = prfHashMechanism;
}
/**
* Returns the string representation of CK_TLS12_KEY_MAT_PARAMS.
*
* @return the string representation of CK_TLS12_KEY_MAT_PARAMS
*/
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(Constants.INDENT);
buffer.append("ulMacSizeInBits: ");
buffer.append(ulMacSizeInBits);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulKeySizeInBits: ");
buffer.append(ulKeySizeInBits);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulIVSizeInBits: ");
buffer.append(ulIVSizeInBits);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("bIsExport: ");
buffer.append(bIsExport);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("RandomInfo: ");
buffer.append(RandomInfo);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pReturnedKeyMaterial: ");
buffer.append(pReturnedKeyMaterial);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("prfHashMechanism: ");
buffer.append(prfHashMechanism);
return buffer.toString();
}
}
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2018, Red Hat, Inc. and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.pkcs11.wrapper;
/**
* CK_TLS12_MASTER_KEY_DERIVE_PARAMS from PKCS#11 v2.40.
*/
public class CK_TLS12_MASTER_KEY_DERIVE_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_SSL3_RANDOM_DATA RandomInfo;
* </PRE>
*/
public CK_SSL3_RANDOM_DATA RandomInfo;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VERSION_PTR pVersion;
* </PRE>
*/
public CK_VERSION pVersion;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_MECHANISM_TYPE prfHashMechanism;
* </PRE>
*/
public long prfHashMechanism;
public CK_TLS12_MASTER_KEY_DERIVE_PARAMS(
CK_SSL3_RANDOM_DATA random, CK_VERSION version,
long prfHashMechanism) {
RandomInfo = random;
pVersion = version;
this.prfHashMechanism = prfHashMechanism;
}
}
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2018, Red Hat, Inc. and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.pkcs11.wrapper;
/**
* CK_TLS_MAC_PARAMS from PKCS#11 v2.40.
*/
public class CK_TLS_MAC_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_MECHANISM_TYPE prfMechanism;
* </PRE>
*/
public long prfMechanism;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMacLength;
* </PRE>
*/
public long ulMacLength;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulServerOrClient;
* </PRE>
*/
public long ulServerOrClient;
public CK_TLS_MAC_PARAMS(long prfMechanism,
long ulMacLength, long ulServerOrClient) {
this.prfMechanism = prfMechanism;
this.ulMacLength = ulMacLength;
this.ulServerOrClient = ulServerOrClient;
}
}
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.pkcs11.wrapper;
/**
* CK_TLS_PRF_PARAMS from PKCS#11 v2.20.
*
* @author Andreas Sterbenz
* @since 1.6
*/
public class CK_TLS_PRF_PARAMS {
public byte[] pSeed;
public byte[] pLabel;
public byte[] pOutput;
public CK_TLS_PRF_PARAMS(byte[] pSeed, byte[] pLabel, byte[] pOutput) {
this.pSeed = pSeed;
this.pLabel = pLabel;
this.pOutput = pOutput;
}
}
@@ -0,0 +1,389 @@
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_TOKEN_INFO provides information about a token.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_TOKEN_INFO {&nbsp;&nbsp;
* CK_UTF8CHAR label[32];&nbsp;&nbsp;
* CK_UTF8CHAR manufacturerID[32];&nbsp;&nbsp;
* CK_UTF8CHAR model[16];&nbsp;&nbsp;
* CK_CHAR serialNumber[16];&nbsp;&nbsp;
* CK_FLAGS flags;&nbsp;&nbsp;
* CK_ULONG ulMaxSessionCount;&nbsp;&nbsp;
* CK_ULONG ulSessionCount;&nbsp;&nbsp;
* CK_ULONG ulMaxRwSessionCount;&nbsp;&nbsp;
* CK_ULONG ulRwSessionCount;&nbsp;&nbsp;
* CK_ULONG ulMaxPinLen;&nbsp;&nbsp;
* CK_ULONG ulMinPinLen;&nbsp;&nbsp;
* CK_ULONG ulTotalPublicMemory;&nbsp;&nbsp;
* CK_ULONG ulFreePublicMemory;&nbsp;&nbsp;
* CK_ULONG ulTotalPrivateMemory;&nbsp;&nbsp;
* CK_ULONG ulFreePrivateMemory;&nbsp;&nbsp;
* CK_VERSION hardwareVersion;&nbsp;&nbsp;
* CK_VERSION firmwareVersion;&nbsp;&nbsp;
* CK_CHAR utcTime[16];&nbsp;&nbsp;
* } CK_TOKEN_INFO;
* &nbsp;&nbsp;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_TOKEN_INFO {
/* label, manufacturerID, and model have been changed from
* CK_CHAR to CK_UTF8CHAR for v2.11. */
/**
* must be blank padded and only the first 32 chars will be used<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_UTF8CHAR label[32];
* </PRE>
*/
public char[] label; /* blank padded */
/**
* must be blank padded and only the first 32 chars will be used<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_UTF8CHAR manufacturerID[32];
* </PRE>
*/
public char[] manufacturerID; /* blank padded */
/**
* must be blank padded and only the first 16 chars will be used<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_UTF8CHAR model[16];
* </PRE>
*/
public char[] model; /* blank padded */
/**
* must be blank padded and only the first 16 chars will be used<p>
* <B>PKCS#11:</B>
* <PRE>
* CK_CHAR serialNumber[16];
* </PRE>
*/
public char[] serialNumber; /* blank padded */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_FLAGS flags;
* </PRE>
*/
public long flags; /* see below */
/* ulMaxSessionCount, ulSessionCount, ulMaxRwSessionCount,
* ulRwSessionCount, ulMaxPinLen, and ulMinPinLen have all been
* changed from CK_USHORT to CK_ULONG for v2.0 */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMaxSessionCount;
* </PRE>
*/
public long ulMaxSessionCount; /* max open sessions */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulSessionCount;
* </PRE>
*/
public long ulSessionCount; /* sess. now open */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMaxRwSessionCount;
* </PRE>
*/
public long ulMaxRwSessionCount; /* max R/W sessions */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulRwSessionCount;
* </PRE>
*/
public long ulRwSessionCount; /* R/W sess. now open */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMaxPinLen;
* </PRE>
*/
public long ulMaxPinLen; /* in bytes */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulMinPinLen;
* </PRE>
*/
public long ulMinPinLen; /* in bytes */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulTotalPublicMemory;
* </PRE>
*/
public long ulTotalPublicMemory; /* in bytes */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulFreePublicMemory;
* </PRE>
*/
public long ulFreePublicMemory; /* in bytes */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulTotalPrivateMemory;
* </PRE>
*/
public long ulTotalPrivateMemory; /* in bytes */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulFreePrivateMemory;
* </PRE>
*/
public long ulFreePrivateMemory; /* in bytes */
/* hardwareVersion, firmwareVersion, and time are new for
* v2.0 */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VERSION hardwareVersion;
* </PRE>
*/
public CK_VERSION hardwareVersion; /* version of hardware */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_VERSION firmwareVersion;
* </PRE>
*/
public CK_VERSION firmwareVersion; /* version of firmware */
/**
* only the first 16 chars will be used
* <B>PKCS#11:</B>
* <PRE>
* CK_CHAR utcTime[16];
* </PRE>
*/
public char[] utcTime; /* time */
public CK_TOKEN_INFO(char[] label, char[] vendor, char[] model,
char[] serialNo, long flags,
long sessionMax, long session,
long rwSessionMax, long rwSession,
long pinLenMax, long pinLenMin,
long totalPubMem, long freePubMem,
long totalPrivMem, long freePrivMem,
CK_VERSION hwVer, CK_VERSION fwVer, char[] utcTime) {
this.label = label;
this.manufacturerID = vendor;
this.model = model;
this.serialNumber = serialNo;
this.flags = flags;
this.ulMaxSessionCount = sessionMax;
this.ulSessionCount = session;
this.ulMaxRwSessionCount = rwSessionMax;
this.ulRwSessionCount = rwSession;
this.ulMaxPinLen = pinLenMax;
this.ulMinPinLen = pinLenMin;
this.ulTotalPublicMemory = totalPubMem;
this.ulFreePublicMemory = freePubMem;
this.ulTotalPrivateMemory = totalPrivMem;
this.ulFreePrivateMemory = freePrivMem;
this.hardwareVersion = hwVer;
this.firmwareVersion = fwVer;
this.utcTime = utcTime;
}
/**
* Returns the string representation of CK_TOKEN_INFO.
*
* @return the string representation of CK_TOKEN_INFO
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("label: ");
buffer.append(new String(label));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("manufacturerID: ");
buffer.append(new String(manufacturerID));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("model: ");
buffer.append(new String(model));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("serialNumber: ");
buffer.append(new String(serialNumber));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("flags: ");
buffer.append(Functions.tokenInfoFlagsToString(flags));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulMaxSessionCount: ");
buffer.append((ulMaxSessionCount == PKCS11Constants.CK_EFFECTIVELY_INFINITE)
? "CK_EFFECTIVELY_INFINITE"
: (ulMaxSessionCount == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
? "CK_UNAVAILABLE_INFORMATION"
: String.valueOf(ulMaxSessionCount));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulSessionCount: ");
buffer.append((ulSessionCount == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
? "CK_UNAVAILABLE_INFORMATION"
: String.valueOf(ulSessionCount));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulMaxRwSessionCount: ");
buffer.append((ulMaxRwSessionCount == PKCS11Constants.CK_EFFECTIVELY_INFINITE)
? "CK_EFFECTIVELY_INFINITE"
: (ulMaxRwSessionCount == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
? "CK_UNAVAILABLE_INFORMATION"
: String.valueOf(ulMaxRwSessionCount));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulRwSessionCount: ");
buffer.append((ulRwSessionCount == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
? "CK_UNAVAILABLE_INFORMATION"
: String.valueOf(ulRwSessionCount));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulMaxPinLen: ");
buffer.append(String.valueOf(ulMaxPinLen));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulMinPinLen: ");
buffer.append(String.valueOf(ulMinPinLen));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulTotalPublicMemory: ");
buffer.append((ulTotalPublicMemory == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
? "CK_UNAVAILABLE_INFORMATION"
: String.valueOf(ulTotalPublicMemory));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulFreePublicMemory: ");
buffer.append((ulFreePublicMemory == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
? "CK_UNAVAILABLE_INFORMATION"
: String.valueOf(ulFreePublicMemory));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulTotalPrivateMemory: ");
buffer.append((ulTotalPrivateMemory == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
? "CK_UNAVAILABLE_INFORMATION"
: String.valueOf(ulTotalPrivateMemory));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulFreePrivateMemory: ");
buffer.append((ulFreePrivateMemory == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
? "CK_UNAVAILABLE_INFORMATION"
: String.valueOf(ulFreePrivateMemory));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("hardwareVersion: ");
buffer.append(hardwareVersion.toString());
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("firmwareVersion: ");
buffer.append(firmwareVersion.toString());
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("utcTime: ");
buffer.append(new String(utcTime));
//buffer.append(Constants.NEWLINE);
return buffer.toString() ;
}
}
@@ -0,0 +1,68 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* interface CK_UNLOCKMUTEX<p>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public interface CK_UNLOCKMUTEX {
/**
* Method CK_UNLOCKMUTEX
*
* @param pMutex The mutex (lock) object to unlock.
* @exception PKCS11Exception
*/
public void CK_UNLOCKMUTEX(Object pMutex) throws PKCS11Exception;
}
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_VERSION describes the version of a Cryptoki interface, a Cryptoki
* library, or an SSL implementation, or the hardware or firmware version of a
* slot or token.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_VERSION {&nbsp;&nbsp;
* CK_BYTE major;&nbsp;&nbsp;
* CK_BYTE minor;&nbsp;&nbsp;
* } CK_VERSION;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class CK_VERSION {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_BYTE major;
* </PRE>
*/
public byte major; /* integer portion of version number */
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_BYTE minor;
* </PRE>
*/
public byte minor; /* 1/100ths portion of version number */
public CK_VERSION(int major, int minor) {
this.major = (byte)major;
this.minor = (byte)minor;
}
/**
* Returns the string representation of CK_VERSION.
*
* @return the string representation of CK_VERSION
*/
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(major & 0xff);
buffer.append('.');
int m = minor & 0xff;
if (m < 10) {
buffer.append('0');
}
buffer.append(m);
return buffer.toString();
}
}
@@ -0,0 +1,132 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_X9_42_DH1_DERIVE_PARAMS provides the parameters to the
* CKM_X9_42_DH_DERIVE mechanism.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_X9_42_DH1_DERIVE_PARAMS {
* CK_X9_42_DH_KDF_TYPE kdf;
* CK_ULONG ulOtherInfoLen;
* CK_BYTE_PTR pOtherInfo;
* CK_ULONG ulPublicDataLen;
* CK_BYTE_PTR pPublicData;
* } CK_X9_42_DH1_DERIVE_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
*/
public class CK_X9_42_DH1_DERIVE_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_X9_42_DH_KDF_TYPE kdf;
* </PRE>
*/
public long kdf;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulOtherInfoLen;
* CK_BYTE_PTR pOtherInfo;
* </PRE>
*/
public byte[] pOtherInfo;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulPublicDataLen;
* CK_BYTE_PTR pPublicData;
* </PRE>
*/
public byte[] pPublicData;
/**
* Returns the string representation of CK_PKCS5_PBKD2_PARAMS.
*
* @return the string representation of CK_PKCS5_PBKD2_PARAMS
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("kdf: 0x");
buffer.append(Functions.toFullHexString(kdf));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pOtherInfoLen: ");
buffer.append(pOtherInfo.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pOtherInfo: ");
buffer.append(Functions.toHexString(pOtherInfo));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicDataLen: ");
buffer.append(pPublicData.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicData: ");
buffer.append(Functions.toHexString(pPublicData));
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,181 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* class CK_X9_42_DH2_DERIVE_PARAMS provides the parameters to the
* CKM_X9_42_DH_HYBRID_DERIVE and CKM_X9_42_MQV_DERIVE mechanisms.<p>
* <B>PKCS#11 structure:</B>
* <PRE>
* typedef struct CK_X9_42_DH2_DERIVE_PARAMS {
* CK_X9_42_DH_KDF_TYPE kdf;
* CK_ULONG ulOtherInfoLen;
* CK_BYTE_PTR pOtherInfo;
* CK_ULONG ulPublicDataLen;
* CK_BYTE_PTR pPublicData;
* CK_ULONG ulPrivateDataLen;
* CK_OBJECT_HANDLE hPrivateData;
* CK_ULONG ulPublicDataLen2;
* CK_BYTE_PTR pPublicData2;
* } CK_X9_42_DH2_DERIVE_PARAMS;
* </PRE>
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
*/
public class CK_X9_42_DH2_DERIVE_PARAMS {
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_X9_42_DH_KDF_TYPE kdf;
* </PRE>
*/
public long kdf;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulOtherInfoLen;
* CK_BYTE_PTR pOtherInfo;
* </PRE>
*/
public byte[] pOtherInfo;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulPublicDataLen;
* CK_BYTE_PTR pPublicData;
* </PRE>
*/
public byte[] pPublicData;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulPrivateDataLen;
* </PRE>
*/
public long ulPrivateDataLen;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_OBJECT_HANDLE hPrivateData;
* </PRE>
*/
public long hPrivateData;
/**
* <B>PKCS#11:</B>
* <PRE>
* CK_ULONG ulPublicDataLen2;
* CK_BYTE_PTR pPublicData2;
* </PRE>
*/
public byte[] pPublicData2;
/**
* Returns the string representation of CK_PKCS5_PBKD2_PARAMS.
*
* @return the string representation of CK_PKCS5_PBKD2_PARAMS
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(Constants.INDENT);
buffer.append("kdf: 0x");
buffer.append(Functions.toFullHexString(kdf));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pOtherInfoLen: ");
buffer.append(pOtherInfo.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pOtherInfo: ");
buffer.append(Functions.toHexString(pOtherInfo));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicDataLen: ");
buffer.append(pPublicData.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicData: ");
buffer.append(Functions.toHexString(pPublicData));
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("ulPrivateDataLen: ");
buffer.append(ulPrivateDataLen);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("hPrivateData: ");
buffer.append(hPrivateData);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicDataLen2: ");
buffer.append(pPublicData2.length);
buffer.append(Constants.NEWLINE);
buffer.append(Constants.INDENT);
buffer.append("pPublicData2: ");
buffer.append(Functions.toHexString(pPublicData2));
//buffer.append(Constants.NEWLINE);
return buffer.toString();
}
}
@@ -0,0 +1,65 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* This class holds only final static member variables that are constants
* in this package.
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class Constants {
public static final String NEWLINE = System.getProperty("line.separator");
public static final String INDENT = " ";
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,320 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
import java.util.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
/**
* This is the superclass of all checked exceptions used by this package. An
* exception of this class indicates that a function call to the underlying
* PKCS#11 module returned a value not equal to CKR_OK. The application can get
* the returned value by calling getErrorCode(). A return value not equal to
* CKR_OK is the only reason for such an exception to be thrown.
* PKCS#11 defines the meaning of an error-code, which may depend on the
* context in which the error occurs.
*
* @author <a href="mailto:Karl.Scheibelhofer@iaik.at"> Karl Scheibelhofer </a>
* @invariants
*/
public class PKCS11Exception extends Exception {
private static final long serialVersionUID = 4877072363729195L;
/**
* The code of the error which was the reason for this exception.
*/
protected long errorCode_;
private static final Map<Long,String> errorMap;
static {
long[] errorCodes = new long[] {
CKR_OK,
CKR_CANCEL,
CKR_HOST_MEMORY,
CKR_SLOT_ID_INVALID,
CKR_GENERAL_ERROR,
CKR_FUNCTION_FAILED,
CKR_ARGUMENTS_BAD,
CKR_NO_EVENT,
CKR_NEED_TO_CREATE_THREADS,
CKR_CANT_LOCK,
CKR_ATTRIBUTE_READ_ONLY,
CKR_ATTRIBUTE_SENSITIVE,
CKR_ATTRIBUTE_TYPE_INVALID,
CKR_ATTRIBUTE_VALUE_INVALID,
CKR_ACTION_PROHIBITED,
CKR_DATA_INVALID,
CKR_DATA_LEN_RANGE,
CKR_DEVICE_ERROR,
CKR_DEVICE_MEMORY,
CKR_DEVICE_REMOVED,
CKR_ENCRYPTED_DATA_INVALID,
CKR_ENCRYPTED_DATA_LEN_RANGE,
CKR_AEAD_DECRYPT_FAILED,
CKR_FUNCTION_CANCELED,
CKR_FUNCTION_NOT_PARALLEL,
CKR_FUNCTION_NOT_SUPPORTED,
CKR_KEY_HANDLE_INVALID,
CKR_KEY_SIZE_RANGE,
CKR_KEY_TYPE_INCONSISTENT,
CKR_KEY_NOT_NEEDED,
CKR_KEY_CHANGED,
CKR_KEY_NEEDED,
CKR_KEY_INDIGESTIBLE,
CKR_KEY_FUNCTION_NOT_PERMITTED,
CKR_KEY_NOT_WRAPPABLE,
CKR_KEY_UNEXTRACTABLE,
CKR_MECHANISM_INVALID,
CKR_MECHANISM_PARAM_INVALID,
CKR_OBJECT_HANDLE_INVALID,
CKR_OPERATION_ACTIVE,
CKR_OPERATION_NOT_INITIALIZED,
CKR_PIN_INCORRECT,
CKR_PIN_INVALID,
CKR_PIN_LEN_RANGE,
CKR_PIN_EXPIRED,
CKR_PIN_LOCKED,
CKR_SESSION_CLOSED,
CKR_SESSION_COUNT,
CKR_SESSION_HANDLE_INVALID,
CKR_SESSION_PARALLEL_NOT_SUPPORTED,
CKR_SESSION_READ_ONLY,
CKR_SESSION_EXISTS,
CKR_SESSION_READ_ONLY_EXISTS,
CKR_SESSION_READ_WRITE_SO_EXISTS,
CKR_SIGNATURE_INVALID,
CKR_SIGNATURE_LEN_RANGE,
CKR_TEMPLATE_INCOMPLETE,
CKR_TEMPLATE_INCONSISTENT,
CKR_TOKEN_NOT_PRESENT,
CKR_TOKEN_NOT_RECOGNIZED,
CKR_TOKEN_WRITE_PROTECTED,
CKR_UNWRAPPING_KEY_HANDLE_INVALID,
CKR_UNWRAPPING_KEY_SIZE_RANGE,
CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT,
CKR_USER_ALREADY_LOGGED_IN,
CKR_USER_NOT_LOGGED_IN,
CKR_USER_PIN_NOT_INITIALIZED,
CKR_USER_TYPE_INVALID,
CKR_USER_ANOTHER_ALREADY_LOGGED_IN,
CKR_USER_TOO_MANY_TYPES,
CKR_WRAPPED_KEY_INVALID,
CKR_WRAPPED_KEY_LEN_RANGE,
CKR_WRAPPING_KEY_HANDLE_INVALID,
CKR_WRAPPING_KEY_SIZE_RANGE,
CKR_WRAPPING_KEY_TYPE_INCONSISTENT,
CKR_RANDOM_SEED_NOT_SUPPORTED,
CKR_RANDOM_NO_RNG,
CKR_DOMAIN_PARAMS_INVALID,
CKR_CURVE_NOT_SUPPORTED,
CKR_BUFFER_TOO_SMALL,
CKR_SAVED_STATE_INVALID,
CKR_INFORMATION_SENSITIVE,
CKR_STATE_UNSAVEABLE,
CKR_CRYPTOKI_NOT_INITIALIZED,
CKR_CRYPTOKI_ALREADY_INITIALIZED,
CKR_MUTEX_BAD,
CKR_MUTEX_NOT_LOCKED,
CKR_NEW_PIN_MODE,
CKR_NEXT_OTP,
CKR_EXCEEDED_MAX_ITERATIONS,
CKR_FIPS_SELF_TEST_FAILED,
CKR_LIBRARY_LOAD_FAILED,
CKR_PIN_TOO_WEAK,
CKR_PUBLIC_KEY_INVALID,
CKR_FUNCTION_REJECTED,
CKR_TOKEN_RESOURCE_EXCEEDED,
CKR_OPERATION_CANCEL_FAILED,
CKR_VENDOR_DEFINED,
};
String[] errorMessages = new String[] {
"CKR_OK",
"CKR_CANCEL",
"CKR_HOST_MEMORY",
"CKR_SLOT_ID_INVALID",
"CKR_GENERAL_ERROR",
"CKR_FUNCTION_FAILED",
"CKR_ARGUMENTS_BAD",
"CKR_NO_EVENT",
"CKR_NEED_TO_CREATE_THREADS",
"CKR_CANT_LOCK",
"CKR_ATTRIBUTE_READ_ONLY",
"CKR_ATTRIBUTE_SENSITIVE",
"CKR_ATTRIBUTE_TYPE_INVALID",
"CKR_ATTRIBUTE_VALUE_INVALID",
"CKR_ACTION_PROHIBITED",
"CKR_DATA_INVALID",
"CKR_DATA_LEN_RANGE",
"CKR_DEVICE_ERROR",
"CKR_DEVICE_MEMORY",
"CKR_DEVICE_REMOVED",
"CKR_ENCRYPTED_DATA_INVALID",
"CKR_ENCRYPTED_DATA_LEN_RANGE",
"CKR_AEAD_DECRYPT_FAILED",
"CKR_FUNCTION_CANCELED",
"CKR_FUNCTION_NOT_PARALLEL",
"CKR_FUNCTION_NOT_SUPPORTED",
"CKR_KEY_HANDLE_INVALID",
"CKR_KEY_SIZE_RANGE",
"CKR_KEY_TYPE_INCONSISTENT",
"CKR_KEY_NOT_NEEDED",
"CKR_KEY_CHANGED",
"CKR_KEY_NEEDED",
"CKR_KEY_INDIGESTIBLE",
"CKR_KEY_FUNCTION_NOT_PERMITTED",
"CKR_KEY_NOT_WRAPPABLE",
"CKR_KEY_UNEXTRACTABLE",
"CKR_MECHANISM_INVALID",
"CKR_MECHANISM_PARAM_INVALID",
"CKR_OBJECT_HANDLE_INVALID",
"CKR_OPERATION_ACTIVE",
"CKR_OPERATION_NOT_INITIALIZED",
"CKR_PIN_INCORRECT",
"CKR_PIN_INVALID",
"CKR_PIN_LEN_RANGE",
"CKR_PIN_EXPIRED",
"CKR_PIN_LOCKED",
"CKR_SESSION_CLOSED",
"CKR_SESSION_COUNT",
"CKR_SESSION_HANDLE_INVALID",
"CKR_SESSION_PARALLEL_NOT_SUPPORTED",
"CKR_SESSION_READ_ONLY",
"CKR_SESSION_EXISTS",
"CKR_SESSION_READ_ONLY_EXISTS",
"CKR_SESSION_READ_WRITE_SO_EXISTS",
"CKR_SIGNATURE_INVALID",
"CKR_SIGNATURE_LEN_RANGE",
"CKR_TEMPLATE_INCOMPLETE",
"CKR_TEMPLATE_INCONSISTENT",
"CKR_TOKEN_NOT_PRESENT",
"CKR_TOKEN_NOT_RECOGNIZED",
"CKR_TOKEN_WRITE_PROTECTED",
"CKR_UNWRAPPING_KEY_HANDLE_INVALID",
"CKR_UNWRAPPING_KEY_SIZE_RANGE",
"CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT",
"CKR_USER_ALREADY_LOGGED_IN",
"CKR_USER_NOT_LOGGED_IN",
"CKR_USER_PIN_NOT_INITIALIZED",
"CKR_USER_TYPE_INVALID",
"CKR_USER_ANOTHER_ALREADY_LOGGED_IN",
"CKR_USER_TOO_MANY_TYPES",
"CKR_WRAPPED_KEY_INVALID",
"CKR_WRAPPED_KEY_LEN_RANGE",
"CKR_WRAPPING_KEY_HANDLE_INVALID",
"CKR_WRAPPING_KEY_SIZE_RANGE",
"CKR_WRAPPING_KEY_TYPE_INCONSISTENT",
"CKR_RANDOM_SEED_NOT_SUPPORTED",
"CKR_RANDOM_NO_RNG",
"CKR_DOMAIN_PARAMS_INVALID",
"CKR_CURVE_NOT_SUPPORTED",
"CKR_BUFFER_TOO_SMALL",
"CKR_SAVED_STATE_INVALID",
"CKR_INFORMATION_SENSITIVE",
"CKR_STATE_UNSAVEABLE",
"CKR_CRYPTOKI_NOT_INITIALIZED",
"CKR_CRYPTOKI_ALREADY_INITIALIZED",
"CKR_MUTEX_BAD",
"CKR_MUTEX_NOT_LOCKED",
"CKR_NEW_PIN_MODE",
"CKR_NEXT_OTP",
"CKR_EXCEEDED_MAX_ITERATIONS",
"CKR_FIPS_SELF_TEST_FAILED",
"CKR_LIBRARY_LOAD_FAILED",
"CKR_PIN_TOO_WEAK",
"CKR_PUBLIC_KEY_INVALID",
"CKR_FUNCTION_REJECTED",
"CKR_TOKEN_RESOURCE_EXCEEDED",
"CKR_OPERATION_CANCEL_FAILED",
"CKR_VENDOR_DEFINED",
};
errorMap = new HashMap<Long,String>();
for (int i = 0; i < errorCodes.length; i++) {
errorMap.put(Long.valueOf(errorCodes[i]), errorMessages[i]);
}
}
/**
* Constructor taking the error code as defined for the CKR_* constants
* in PKCS#11.
*/
public PKCS11Exception(long errorCode) {
errorCode_ = errorCode;
}
/**
* This method gets the corresponding text error message from
* a property file. If this file is not available, it returns the error
* code as a hex-string.
*
* @return The message or the error code; e.g. "CKR_DEVICE_ERROR" or
* "0x00000030".
* @preconditions
* @postconditions (result <> null)
*/
public String getMessage() {
String message = errorMap.get(Long.valueOf(errorCode_));
if (message == null) {
message = "0x" + Functions.toFullHexString((int)errorCode_);
}
return message;
}
/**
* Returns the PKCS#11 error code.
*
* @return The error code; e.g. 0x00000030.
* @preconditions
* @postconditions
*/
public long getErrorCode() {
return errorCode_ ;
}
}
@@ -0,0 +1,109 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
/**
* This is the superclass of all runtime exception used by this library.
* For instance, Runtime exceptions occur, if an internal error in the native
* part of the wrapper occurs.
*
* @author <a href="mailto:Karl.Scheibelhofer@iaik.at"> Karl Scheibelhofer </a>
* @invariants
*/
public class PKCS11RuntimeException extends RuntimeException {
private static final long serialVersionUID = 7889842162743590564L;
/**
* Empty constructor.
*
* @preconditions
* @postconditions
*/
public PKCS11RuntimeException() {
super();
}
/**
* Constructor taking a string that describes the reason of the exception
* in more detail.
*
* @param message A descrption of the reason for this exception.
* @preconditions
* @postconditions
*/
public PKCS11RuntimeException(String message) {
super(message);
}
/**
* Constructor taking an other exception to wrap.
*
* @param encapsulatedException The other exception the wrap into this.
* @preconditions
* @postconditions
*/
public PKCS11RuntimeException(Exception encapsulatedException) {
super(encapsulatedException);
}
/**
* Constructor taking a message for this exception and an other exception to
* wrap.
*
* @param message The message giving details about the exception to ease
* debugging.
* @param encapsulatedException The other exception the wrap into this.
* @preconditions
* @postconditions
*/
public PKCS11RuntimeException(String message, Exception encapsulatedException) {
super(message, encapsulatedException);
}
}