Patent ID: 8995663
Filing Date: 2015-03-31
Classification: H04L

Abstract:
1. A method for implementing an encrypting engine by a smart key device, in which an upper layer application is implemented by invoking an engine binding interface, an initializing interface, a first interface, or an engine releasing interface, in which the first interface comprises a data encrypting and decrypting interface; or the first interface comprises an encrypting and decrypting interface, a signature interface, a signature verification interface, and a SSL client side authentication interface in a second data structure; or the first interface comprises a first digest interface and a second digest interface; wherein said method comprises creating an engine object; setting an id and a name for the created engine object; setting function of crtl_f( ) to control and invoke customizing command comprising setting PKCS#11 database name, setting certificate needed, selecting a slot, selecting a device by key device sequence number, setting PIN code of the selected Slot, login, logout and obtaining total number of hardware key devices; invoking the engine binding interface by the upper layer application; building a connection to the smart key device by the engine; controlling the smart key device to perform an encryption/decryption operation or a digest calculation on data transferred to the smart key device according to the currently set encryption and decryption algorithm and the algorithm key or information digest algorithm; outputting an operation result; wherein if the first interface comprises the data encrypting and decrypting interface, the initializing interface is a key initializing interface, and the method comprises that when the engine binding interface is invoked by the upper layer application, the engine builds a connection to the smart key device, gets an algorithm list of the smart key device, and fills a first data structure; when the key initializing interface is invoked by the upper layer application, the engine sets up an encrypting and decrypting algorithm currently to be used by the smart key device according to the first data structure transferred in, and searches for a corresponding algorithm key, and controls the smart key device to create the corresponding algorithm key if the corresponding algorithm key fails to be searched out; when the data encrypting and decrypting interface is invoked by the upper layer application, the engine controls the smart key device to perform an encryption/decryption operation on data transferred to the smart key device according to the currently set encryption and decryption algorithm and the algorithm key, and output an operation result; and when the engine releasing interface is invoked by the upper layer application, the engine ends the connection to the smart key device, or wherein if the first interface comprises an encryption and decryption interface, a signature interface, a signature verification interface, and a SSL client side authentication interface in a second data structure, the initializing interface is an engine initializing interface, and the method comprises that when the engine binding interface is invoked by the upper layer application, the engine builds a connection to the smart key device; when the engine binding interface is invoked by the upper layer application, the engine is bonded, an algorithm key and a certificate are loaded, and the second data structure is set up; the algorithm key comprises a public key and a private key; when the encrypting and decrypting interface in the second data structure is invoked by the upper layer application, the engine controls the smart key device to perform an encrypting/decrypting operation on data transferred to the smart key device according to the loaded algorithm key, and output an operation result; when the signature interface in the second data structure is invoked by the upper layer application, the engine controls the smart key device to perform a signature operation on a digest value transferred in according to the loaded algorithm key, and return a signature result; when the signature verification interface in the second data structure is invoked by the upper layer application, the engine controls the smart key device to perform a decryption operation on a signature value transferred in according to the loaded algorithm key, and verify whether the signature decryption result got by the decryption operation is correct, if yes, the signature verification is successful, while if no, the signature verification is failed; when the SSL client side authentication interface in the second data structure is invoked by the upper layer application, the engine controls the smart key device to perform SSL client side authentication according to the loaded certificate, and return an authentication result; and when the engine releasing interface is invoked by the upper layer application, the engine ends the connection to the smart key device, or wherein if the first interface comprises the first digest interface and the second digest interface, the method comprises that when the engine binding interface is invoked by the upper layer application, the engine builds a connection to the smart key device, gets an algorithm list of the smart key device, fills a third data structure, and registers the third data structure to the upper layer application; when the initializing interface is invoked by the upper layer application, the engine sets up an information digest algorithm used currently by the smart key device according to the third data structure transferred in, allocates storage space for a context transferred in, and initializes the context; when the first digest interface is invoked by the upper layer application, the engine controls the smart key device to perform a digest calculation on information digest data transferred in according to the currently set information digest algorithm; when the second digest interface is invoked by the upper layer application, the engine controls the smart key device to end digest calculation and output operation result; and when the engine releasing interface is invoked by the upper layer application, the engine ends the connection with the smart key device.