📄 hwcryptohook.h
字号:
* entry *len_io is the length of the buffer. It should be updated * by the callback. The returned passphrase should not be * null-terminated by the callback. */ int (*getphystoken)(const char *prompt_info, const char *wrong_info, HWCryptoHook_PassphraseContext *ppctx, HWCryptoHook_CallerContext *cactx); /* Requests that the human user physically insert a different * smartcard, DataKey, etc. The plugin should check whether the * currently inserted token(s) are appropriate, and if they are it * should not make this call. * * prompt_info is as before. wrong_info is a description of the * currently inserted token(s) so that the user is told what * something is. wrong_info, like prompt_info, may be null, but * should not be an empty string. Its contents should be * syntactically similar to that of prompt_info. */ /* Note that a single LoadKey operation might cause several calls to * getpassphrase and/or requestphystoken. If requestphystoken is * not provided (ie, a null pointer is passed) then the plugin may * not support loading keys for which authorisation by several cards * is required. If getpassphrase is not provided then cards with * passphrases may not be supported. * * getpassphrase and getphystoken do not need to check that the * passphrase has been entered correctly or the correct token * inserted; the crypto plugin will do that. If this is not the * case then the crypto plugin is responsible for calling these * routines again as appropriate until the correct token(s) and * passphrase(s) are supplied as required, or until any retry limits * implemented by the crypto plugin are reached. * * In either case, the application must allow the user to say `no' * or `cancel' to indicate that they do not know the passphrase or * have the appropriate token; this should cause the callback to * return nonzero indicating error. */ void (*logmessage)(void *logstream, const char *message); /* A log message will be generated at least every time something goes * wrong and an ErrMsgBuf is filled in (or would be if one was * provided). Other diagnostic information may be written there too, * including more detailed reasons for errors which are reported in an * ErrMsgBuf. * * When a log message is generated, this callback is called. It * should write a message to the relevant logging arrangements. * * The message string passed will be null-terminated and may be of arbitrary * length. It will not be prefixed by the time and date, nor by the * name of the library that is generating it - if this is required, * the logmessage callback must do it. The message will not have a * trailing newline (though it may contain internal newlines). * * If a null pointer is passed for logmessage a default function is * used. The default function treats logstream as a FILE* which has * been converted to a void*. If logstream is 0 it does nothing. * Otherwise it prepends the date and time and library name and * writes the message to logstream. Each line will be prefixed by a * descriptive string containing the date, time and identity of the * crypto plugin. Errors on the logstream are not reported * anywhere, and the default function doesn't flush the stream, so * the application must set the buffering how it wants it. * * The crypto plugin may also provide a facility to have copies of * log messages sent elsewhere, and or for adjusting the verbosity * of the log messages; any such facilities will be configured by * external means. */} HWCryptoHook_InitInfo;typedefHWCryptoHook_ContextHandle HWCryptoHook_Init_t(const HWCryptoHook_InitInfo *initinfo, size_t initinfosize, const HWCryptoHook_ErrMsgBuf *errors, HWCryptoHook_CallerContext *cactx);extern HWCryptoHook_Init_t HWCryptoHook_Init;/* Caller should set initinfosize to the size of the HWCryptoHook struct, * so it can be extended later. * * On success, a message for display or logging by the server, * including the name and version number of the plugin, will be filled * in into *errors; on failure *errors is used for error handling, as * usual. *//* All these functions return 0 on success, HWCRYPTOHOOK_ERROR_FAILED * on most failures. HWCRYPTOHOOK_ERROR_MPISIZE means at least one of * the output MPI buffer(s) was too small; the sizes of all have been * set to the desired size (and for those where the buffer was large * enough, the value may have been copied in), and no error message * has been recorded. * * You may pass 0 for the errors struct. In any case, unless you set * _NoStderr at init time then messages may be reported to stderr. *//* The RSAImmed* functions (and key managed RSA) only work with * modules which have an RSA patent licence - currently that means KM * units; the ModExp* ones work with all modules, so you need a patent * licence in the software in the US. They are otherwise identical. */typedefvoid HWCryptoHook_Finish_t(HWCryptoHook_ContextHandle hwctx);extern HWCryptoHook_Finish_t HWCryptoHook_Finish;/* You must not have any calls going or keys loaded when you call this. */typedefint HWCryptoHook_RandomBytes_t(HWCryptoHook_ContextHandle hwctx, unsigned char *buf, size_t len, const HWCryptoHook_ErrMsgBuf *errors);extern HWCryptoHook_RandomBytes_t HWCryptoHook_RandomBytes;typedefint HWCryptoHook_ModExp_t(HWCryptoHook_ContextHandle hwctx, HWCryptoHook_MPI a, HWCryptoHook_MPI p, HWCryptoHook_MPI n, HWCryptoHook_MPI *r, const HWCryptoHook_ErrMsgBuf *errors);extern HWCryptoHook_ModExp_t HWCryptoHook_ModExp;typedefint HWCryptoHook_RSAImmedPub_t(HWCryptoHook_ContextHandle hwctx, HWCryptoHook_MPI m, HWCryptoHook_MPI e, HWCryptoHook_MPI n, HWCryptoHook_MPI *r, const HWCryptoHook_ErrMsgBuf *errors);extern HWCryptoHook_RSAImmedPub_t HWCryptoHook_RSAImmedPub;typedefint HWCryptoHook_ModExpCRT_t(HWCryptoHook_ContextHandle hwctx, HWCryptoHook_MPI a, HWCryptoHook_MPI p, HWCryptoHook_MPI q, HWCryptoHook_MPI dmp1, HWCryptoHook_MPI dmq1, HWCryptoHook_MPI iqmp, HWCryptoHook_MPI *r, const HWCryptoHook_ErrMsgBuf *errors);extern HWCryptoHook_ModExpCRT_t HWCryptoHook_ModExpCRT;typedefint HWCryptoHook_RSAImmedPriv_t(HWCryptoHook_ContextHandle hwctx, HWCryptoHook_MPI m, HWCryptoHook_MPI p, HWCryptoHook_MPI q, HWCryptoHook_MPI dmp1, HWCryptoHook_MPI dmq1, HWCryptoHook_MPI iqmp, HWCryptoHook_MPI *r, const HWCryptoHook_ErrMsgBuf *errors);extern HWCryptoHook_RSAImmedPriv_t HWCryptoHook_RSAImmedPriv;/* The RSAImmed* and ModExp* functions may return E_FAILED or * E_FALLBACK for failure. * * E_FAILED means the failure is permanent and definite and there * should be no attempt to fall back to software. (Eg, for some * applications, which support only the acceleration-only * functions, the `key material' may actually be an encoded key * identifier, and doing the operation in software would give wrong * answers.) * * E_FALLBACK means that doing the computation in software would seem * reasonable. If an application pays attention to this and is * able to fall back, it should also set the Fallback init flags. */typedefint HWCryptoHook_RSALoadKey_t(HWCryptoHook_ContextHandle hwctx, const char *key_ident, HWCryptoHook_RSAKeyHandle *keyhandle_r, const HWCryptoHook_ErrMsgBuf *errors, HWCryptoHook_PassphraseContext *ppctx);extern HWCryptoHook_RSALoadKey_t HWCryptoHook_RSALoadKey;/* The key_ident is a null-terminated string configured by the * user via the application's usual configuration mechanisms. * It is provided to the user by the crypto provider's key management * system. The user must be able to enter at least any string of between * 1 and 1023 characters inclusive, consisting of printable 7-bit * ASCII characters. The provider should avoid using * any characters except alphanumerics and the punctuation * characters _ - + . / @ ~ (the user is expected to be able * to enter these without quoting). The string may be case-sensitive. * The application may allow the user to enter other NULL-terminated strings, * and the provider must cope (returning an error if the string is not * valid). * * If the key does not exist, no error is recorded and 0 is returned; * keyhandle_r will be set to 0 instead of to a key handle. */typedefint HWCryptoHook_RSAGetPublicKey_t(HWCryptoHook_RSAKeyHandle k, HWCryptoHook_MPI *n, HWCryptoHook_MPI *e, const HWCryptoHook_ErrMsgBuf *errors);extern HWCryptoHook_RSAGetPublicKey_t HWCryptoHook_RSAGetPublicKey;/* The crypto plugin will not store certificates. * * Although this function for acquiring the public key value is * provided, it is not the purpose of this API to deal fully with the * handling of the public key. * * It is expected that the crypto supplier's key generation program * will provide general facilities for producing X.509 * self-certificates and certificate requests in PEM format. These * will be given to the user so that they can configure them in the * application, send them to CAs, or whatever. * * In case this kind of certificate handling is not appropriate, the * crypto supplier's key generation program should be able to be * configured not to generate such a self-certificate or certificate * request. Then the application will need to do all of this, and * will need to store and handle the public key and certificates * itself. */typedefint HWCryptoHook_RSAUnloadKey_t(HWCryptoHook_RSAKeyHandle k, const HWCryptoHook_ErrMsgBuf *errors);extern HWCryptoHook_RSAUnloadKey_t HWCryptoHook_RSAUnloadKey;/* Might fail due to locking problems, or other serious internal problems. */typedefint HWCryptoHook_RSA_t(HWCryptoHook_MPI m, HWCryptoHook_RSAKeyHandle k, HWCryptoHook_MPI *r, const HWCryptoHook_ErrMsgBuf *errors);extern HWCryptoHook_RSA_t HWCryptoHook_RSA;/* RSA private key operation (sign or decrypt) - raw, unpadded. */#endif /*HWCRYPTOHOOK_H*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -