📄 pkcs11.java
字号:
/* 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 iaik.pkcs.pkcs11.wrapper;/** * If the underlaying PKCS#11 function retuns CK_OK, the method * returns normally. If the return value of the underlying function is not CK_OK, * it throws PKCS11Exception with the return value as error code. * * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at> * @invariants */public interface PKCS11 {/* ***************************************************************************** * General-purpose ******************************************************************************/ /** * C_Initialize initializes the Cryptoki library. * (General-purpose) * * @param pInitArgs if pInitArgs is not NULL it gets casted to * CK_C_INITIALIZE_ARGS_PTR and dereferenced * (PKCS#11 param: CK_VOID_PTR pInitArgs) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions (pInitArgs == null) * or (pInitArgs instanceof CK_C_INITIALIZE_ARGS_PTR) * @postconditions */ public void C_Initialize(Object pInitArgs) throws PKCS11Exception; /** * C_Finalize indicates that an application is done with the * Cryptoki library * (General-purpose) * * @param pReserved is reserved. Should be NULL_PTR * (PKCS#11 param: CK_VOID_PTR pReserved) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions (pReserved == null) * @postconditions */ public void C_Finalize(Object pReserved) throws PKCS11Exception; /** * C_GetInfo returns general information about Cryptoki. * (General-purpose) * * @return the information. * (PKCS#11 param: CK_INFO_PTR pInfo) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions (result <> null) */ public CK_INFO C_GetInfo() throws PKCS11Exception;/* ***************************************************************************** * Slot and token management ******************************************************************************/ /** * C_GetSlotList obtains a list of slots in the system. * (Slot and token management) * * @param tokenPresent if true only Slot IDs with a token are returned * (PKCS#11 param: CK_BBOOL tokenPresent) * @return a long array of slot IDs and number of Slot IDs * (PKCS#11 param: CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions (result <> null) */ public long[] C_GetSlotList(boolean tokenPresent) throws PKCS11Exception; /** * C_GetSlotInfo obtains information about a particular slot in * the system. * (Slot and token management) * * @param slotID the ID of the slot * (PKCS#11 param: CK_SLOT_ID slotID) * @return the slot information * (PKCS#11 param: CK_SLOT_INFO_PTR pInfo) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions (result <> null) */ public CK_SLOT_INFO C_GetSlotInfo(long slotID) throws PKCS11Exception; /** * C_GetTokenInfo obtains information about a particular token * in the system. * (Slot and token management) * * @param slotID ID of the token's slot * (PKCS#11 param: CK_SLOT_ID slotID) * @return the token information * (PKCS#11 param: CK_TOKEN_INFO_PTR pInfo) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions (result <> null) */ public CK_TOKEN_INFO C_GetTokenInfo(long slotID) throws PKCS11Exception; /** * C_GetMechanismList obtains a list of mechanism types * supported by a token. * (Slot and token management) * * @param slotID ID of the token's slot * (PKCS#11 param: CK_SLOT_ID slotID) * @return a long array of mechanism types and number of mechanism types * (PKCS#11 param: CK_MECHANISM_TYPE_PTR pMechanismList, * CK_ULONG_PTR pulCount) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions (result <> null) */ public long[] C_GetMechanismList(long slotID) throws PKCS11Exception; /** * C_GetMechanismInfo obtains information about a particular * mechanism possibly supported by a token. * (Slot and token management) * * @param slotID ID of the token's slot * (PKCS#11 param: CK_SLOT_ID slotID) * @param type type of mechanism * (PKCS#11 param: CK_MECHANISM_TYPE type) * @return the mechanism info * (PKCS#11 param: CK_MECHANISM_INFO_PTR pInfo) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions (result <> null) */ public CK_MECHANISM_INFO C_GetMechanismInfo(long slotID, long type) throws PKCS11Exception; /** * C_InitToken initializes a token. * (Slot and token management) * * @param slotID ID of the token's slot * (PKCS#11 param: CK_SLOT_ID slotID) * @param pPin the SO's initial PIN and the length in bytes of the PIN * (PKCS#11 param: CK_CHAR_PTR pPin, CK_ULONG ulPinLen) * @param pLabel 32-byte token label (blank padded) * (PKCS#11 param: CK_UTF8CHAR_PTR pLabel) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions */ public void C_InitToken(long slotID, char[] pPin, char[] pLabel) throws PKCS11Exception; /** * C_InitPIN initializes the normal user's PIN. * (Slot and token management) * * @param hSession the session's handle * (PKCS#11 param: CK_SESSION_HANDLE hSession) * @param pPin the normal user's PIN and the length in bytes of the PIN * (PKCS#11 param: CK_CHAR_PTR pPin, CK_ULONG ulPinLen) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions */ public void C_InitPIN(long hSession, char[] pPin) throws PKCS11Exception; /** * C_SetPIN modifies the PIN of the user who is logged in. * (Slot and token management) * * @param hSession the session's handle * (PKCS#11 param: CK_SESSION_HANDLE hSession) * @param pOldPin the old PIN and the length of the old PIN * (PKCS#11 param: CK_CHAR_PTR pOldPin, CK_ULONG ulOldLen) * @param pNewPin the new PIN and the length of the new PIN * (PKCS#11 param: CK_CHAR_PTR pNewPin, CK_ULONG ulNewLen) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions */ public void C_SetPIN(long hSession, char[] pOldPin, char[] pNewPin) throws PKCS11Exception;/* ***************************************************************************** * Session management ******************************************************************************/ /** * C_OpenSession opens a session between an application and a * token. * (Session management) * * @param slotID the slot's ID * (PKCS#11 param: CK_SLOT_ID slotID) * @param flags of CK_SESSION_INFO * (PKCS#11 param: CK_FLAGS flags) * @param pApplication passed to callback * (PKCS#11 param: CK_VOID_PTR pApplication) * @param Notify the callback function * (PKCS#11 param: CK_NOTIFY Notify) * @return the session handle * (PKCS#11 param: CK_SESSION_HANDLE_PTR phSession) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions */ public long C_OpenSession(long slotID, long flags, Object pApplication, CK_NOTIFY Notify) throws PKCS11Exception; /** * C_CloseSession closes a session between an application and a * token. * (Session management) * * @param hSession the session's handle * (PKCS#11 param: CK_SESSION_HANDLE hSession) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions */ public void C_CloseSession(long hSession) throws PKCS11Exception; /** * C_CloseAllSessions closes all sessions with a token. * (Session management) * * @param slotID the ID of the token's slot * (PKCS#11 param: CK_SLOT_ID slotID) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions */ public void C_CloseAllSessions(long slotID) throws PKCS11Exception; /** * C_GetSessionInfo obtains information about the session. * (Session management) * * @param hSession the session's handle * (PKCS#11 param: CK_SESSION_HANDLE hSession) * @return the session info * (PKCS#11 param: CK_SESSION_INFO_PTR pInfo) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions (result <> null) */ public CK_SESSION_INFO C_GetSessionInfo(long hSession) throws PKCS11Exception; /** * C_GetOperationState obtains the state of the cryptographic operation * in a session. * (Session management) * * @param hSession session's handle * (PKCS#11 param: CK_SESSION_HANDLE hSession) * @return the state and the state length * (PKCS#11 param: CK_BYTE_PTR pOperationState, * CK_ULONG_PTR pulOperationStateLen) * @exception PKCS11Exception If function returns other value than CKR_OK. * @preconditions * @postconditions (result <> null) */ public byte[] C_GetOperationState(long hSession) throws PKCS11Exception; /** * C_SetOperationState restores the state of the cryptographic * operation in a session. * (Session management) * * @param hSession session's handle * (PKCS#11 param: CK_SESSION_HANDLE hSession) * @param pOperationState the state and the state length
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -