📄 pgprpckeyback.c
字号:
memset( info, 0, sizeof(*info) );
pack_init_secure(&pkt, kPGP_GetTokenInfo_MSG, connect_ref);
pack_uint32(&pkt, tokNumber);
pack_uint32(&pkt, client_size);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
PGPByte *p;
PGPSize p_size;
/* Get data from SDK.
Begin of base structure PGPTokenInfo */
/* sizeof(PGPTokenInfo) for SDK */
info->size = unpack_uint32(&rplypkt);
info->bRsa = unpack_bool(&rplypkt);
pgpAssert( info->bRsa == 1 || info->bRsa == 0 );
info->minRsaKeySize = unpack_uint32(&rplypkt);
info->maxRsaKeySize = unpack_uint32(&rplypkt);
pgpAssert( info->maxRsaKeySize >= info->minRsaKeySize );
info->minPinLen = unpack_uint32(&rplypkt);
info->maxPinLen = unpack_uint32(&rplypkt);
pgpAssert( info->maxPinLen >= info->minPinLen );
p_size = 0;
unpack_opaque_alloc(&rplypkt, (void **)&p, &p_size);
if( p_size )
strncpy( info->manufacturerID, p, p_size );
PGPFreeData( p );
p_size = 0;
unpack_opaque_alloc(&rplypkt, (void **)&p, &p_size);
if( p_size )
strncpy( info->model, p, p_size );
PGPFreeData( p );
p_size = 0;
unpack_opaque_alloc(&rplypkt, (void **)&p, &p_size);
if( p_size )
strncpy( info->serialNumber, p, p_size );
PGPFreeData( p );
info->numPubKeys = unpack_uint32(&rplypkt);
info->numPrivKeys = unpack_uint32(&rplypkt);
/* End of base structure PGPTokenInfo, therefore: */
pgpAssert( info->size==0 || info->size/*SDK size*/ == client_size );
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpDeleteKeyOnToken_backRPC( PGPContextRef context,
PGPUInt32 keydbID,
const PGPKeyID *keyID,
PGPUInt32 tokenNumber,
PGPByte const *pin, PGPSize pinLen )
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_DeleteKeyOnToken_MSG, connect_ref);
pack_uint32(&pkt, keydbID);
pack_opaque(&pkt, keyID, sizeof(PGPKeyID));
pack_uint32(&pkt, tokenNumber);
pack_opaque(&pkt, (void *)pin, pinLen);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status))
PGPFreeData(rplypkt.base);
return status;
}
PGPError
pgpWipeToken_backRPC (
PGPContextRef context,
PGPUInt32 tokNumber,
PGPByte const * passphrase,
PGPSize passphraseLength
)
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_WipeToken_MSG, connect_ref);
pack_uint32(&pkt, tokNumber);
pack_opaque(&pkt, (void *)passphrase, passphraseLength);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpFormatToken_backRPC (
PGPContextRef context,
PGPUInt32 tokNumber,
PGPByte const * adminPin, PGPSize adminPinLen,
PGPByte const * newUserPin, PGPSize newUserPinLen )
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_FormatToken_MSG, connect_ref);
pack_uint32(&pkt, tokNumber);
pack_opaque(&pkt, (void *)adminPin, adminPinLen);
pack_opaque(&pkt, (void *)newUserPin, newUserPinLen);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpTokenPassphraseIsValid_backRPC (
PGPContextRef context,
PGPUInt32 tokNumber,
PGPByte const * passphrase,
PGPSize passphraseLength
)
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_TokenPassphraseIsValid_MSG, connect_ref);
pack_uint32(&pkt, tokNumber);
pack_opaque(&pkt, (void *)passphrase, passphraseLength);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpCopyKeyToToken_backRPC (
PGPContextRef context,
PGPUInt32 objid,
PGPUInt32 tokNumber,
PGPBoolean isMaster,
char const * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
char const * PIN,
PGPSize PINlength,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal)
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_CopyKeyToToken_MSG, connect_ref);
pack_uint32(&pkt, objid);
pack_uint32(&pkt, tokNumber);
pack_bool(&pkt, isMaster);
pack_opaque(&pkt, (void *)passphrase, passphraseLength);
pack_bool(&pkt, hashedPhrase);
pack_opaque(&pkt, (void *)PIN, PINlength);
pack_uint32(&pkt, cacheTimeOut);
pack_bool(&pkt, cacheGlobal);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpTokenImportX509_backRPC (
PGPContextRef context,
const PGPByte *keyID,
const PGPByte *userID, PGPSize userID_len,
const PGPByte *x509, PGPSize x509_len,
const PGPByte *password, PGPSize passwordLength )
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void) context;
pack_init_secure(&pkt, kPGP_TokenImportX509_MSG, connect_ref);
pack_uint32(&pkt, *(PGPUInt32*)keyID);
pack_uint32(&pkt, ((PGPUInt32*)keyID)[1]);
pack_opaque(&pkt, userID, userID_len);
pack_opaque(&pkt, password, passwordLength);
pack_opaque(&pkt, (void *)x509, x509_len);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpTokenPutKeyContainer_backRPC(
PGPContextRef context, const PGPByte *keyID,
const PGPByte *password, PGPSize passwordSize,
const PGPByte *cont, PGPSize contSize )
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void) context;
pack_init_secure(&pkt, kPGP_TokenPutKeyContainer_MSG, connect_ref);
pack_uint32(&pkt, *(PGPUInt32*)keyID);
pack_uint32(&pkt, ((PGPUInt32*)keyID)[1]);
pack_opaque(&pkt, cont, contSize);
pack_opaque(&pkt, password, passwordSize);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status) ) {
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpTokenGetKeyContainer_backRPC(
PGPContextRef context, const PGPByte *keyID,
const PGPByte *password, PGPSize passwordSize,
PGPByte **contOut, PGPSize *contOutSize )
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void) context;
pack_init_secure(&pkt, kPGP_TokenGetKeyContainer_MSG, connect_ref);
pack_uint32(&pkt, *(PGPUInt32*)keyID);
pack_uint32(&pkt, ((PGPUInt32*)keyID)[1]);
pack_opaque(&pkt, password, passwordSize);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status) && contOut ) {
unpack_opaque_alloc( &rplypkt, (void **)contOut, contOutSize );
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpSetPKCS11DrvFile_backRPC( PGPByte const *module )
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
pack_init_secure(&pkt, kPGP_SetPKCS11DrvFile_MSG, connect_ref);
pack_opaque(&pkt, (void *)module, strlen(module)+1);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpAddUserID_backRPC (
PGPContextRef context,
PGPUInt32 objid,
PGPBoolean isAttribute,
PGPAttributeType attributeType,
char const * userIDData,
PGPSize userIDLength,
char const * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal,
PGPUInt32 ** newobjs,
PGPSize * newobjslength)
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_AddUserID_MSG, connect_ref);
pack_uint32(&pkt, objid);
pack_bool(&pkt, isAttribute);
pack_int32(&pkt, attributeType);
pack_opaque(&pkt, (void *)userIDData, userIDLength);
pack_opaque(&pkt, (void *)passphrase, passphraseLength);
pack_bool(&pkt, hashedPhrase);
pack_uint32(&pkt, cacheTimeOut);
pack_bool(&pkt, cacheGlobal);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
unpack_opaque_alloc(&rplypkt, (void **)newobjs, newobjslength);
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpCertifyUserID_backRPC(
PGPContextRef context,
PGPUInt32 useridid,
PGPUInt32 certifying_keyid,
char const * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal,
PGPBoolean exportable,
PGPTime creationDate,
PGPUInt32 expiration,
PGPByte trustDepth,
PGPByte trustValue,
char const * sRegExp,
PGPSize sRegExpLength,
PGPUInt32 ** newobjs,
PGPSize * newobjslength
)
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_CertifyUserID_MSG, connect_ref);
pack_uint32(&pkt, useridid);
pack_uint32(&pkt, certifying_keyid);
pack_opaque(&pkt, (void *)passphrase, passphraseLength);
pack_bool(&pkt, hashedPhrase);
pack_uint32(&pkt, cacheTimeOut);
pack_bool(&pkt, cacheGlobal);
pack_bool(&pkt, exportable);
pack_uint32(&pkt, creationDate);
pack_uint32(&pkt, expiration);
pack_byte(&pkt, trustDepth);
pack_byte(&pkt, trustValue);
pack_opaque(&pkt, (void *)sRegExp, sRegExpLength);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
unpack_opaque_alloc(&rplypkt, (void **)newobjs, newobjslength);
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpRevokeSig_backRPC (
PGPContextRef context,
PGPUInt32 sigid,
char const * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal,
PGPUInt32 ** newobjs,
PGPSize * newobjslength
)
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_RevokeSig_MSG, connect_ref);
pack_uint32(&pkt, sigid);
pack_opaque(&pkt, (void *)passphrase, passphraseLength);
pack_bool(&pkt, hashedPhrase);
pack_uint32(&pkt, cacheTimeOut);
pack_bool(&pkt, cacheGlobal);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
unpack_opaque_alloc(&rplypkt, (void **)newobjs, newobjslength);
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpRevokeKey_backRPC (
PGPContextRef context,
PGPUInt32 key_id,
char const * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal,
PGPUInt32 ** newobjs,
PGPSize * newobjslength
)
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_RevokeKey_MSG, connect_ref);
pack_uint32(&pkt, key_id);
pack_opaque(&pkt, (void *)passphrase, passphraseLength);
pack_bool(&pkt, hashedPhrase);
pack_uint32(&pkt, cacheTimeOut);
pack_bool(&pkt, cacheGlobal);
status = pgpRPCSendPacket(&pkt, &rplypkt, TRUE);
if (IsntPGPError(status)) {
unpack_opaque_alloc(&rplypkt, (void **)newobjs, newobjslength);
PGPFreeData(rplypkt.base);
}
return status;
}
PGPError
pgpDoChangePassphrase_backRPC (PGPContextRef context, PGPUInt32 keydb_id,
PGPUInt32 key_id, PGPUInt32 masterkey_id,
const char *oldphrase, PGPSize oldphraseLength,
const char *newphrase, PGPSize newphraseLength,
PGPBoolean newPassphraseIsKey,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal)
{
PGPInt32 status;
PGPPackMsg pkt, rplypkt;
(void)context;
pack_init_secure(&pkt, kPGP_DoChangePassphrase_MSG, connect_ref);
pack_uint32(&pkt, keydb_id);
pack_uint32(&pkt, key_id);
pack_uint32(&pkt, masterkey_id);
pack_opaque(&pkt, (void *)oldphrase, oldphraseLength);
pack_opaque(&pkt, (void *)newphrase, newphraseLength);
pack_bool(&pkt, newPassphraseIsKey);
pack_uint32(&pkt, cacheTimeOut);
pack_bool(&pkt, cacheGlobal);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -