📄 pgpkeyback.c
字号:
{
PGPKeyDBObj * userid = (PGPKeyDBObj *) useridid;
PGPError err;
if (pgpRPCEnabled())
return pgpCertifyPrimaryUserID_backRPC( context, useridid, passphrase,
passphraseLength, hashedPhrase, cacheTimeOut, cacheGlobal,
newobjs, newobjslength );
pgpAssert( pgpKeyDBObjIsValid( userid ) );
err = pgpCertifyPrimaryUserID_internal( userid, passphrase,
passphraseLength, hashedPhrase,
cacheTimeOut, cacheGlobal );
if( IsPGPError( err ) )
return err;
(void)pgpSetPendingNotify( NULL, NULL, NULL, PGPPeekKeyDBObjKey(userid) );
return pgpCreateKeyArray( context, userid->up, 1, NULL,
newobjs, newobjslength );
}
PGPError
pgpRevokeSig_back (
PGPContextRef context,
PGPUInt32 sigid,
char const * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal,
PGPUInt32 ** newobjs,
PGPSize * newobjslength
)
{
PGPKeyDBObj * sig = (PGPKeyDBObj *) sigid;
PGPError err;
if (pgpRPCEnabled())
return pgpRevokeSig_backRPC( context, sigid, passphrase,
passphraseLength, hashedPhrase, cacheTimeOut, cacheGlobal,
newobjs, newobjslength );
pgpAssert( pgpKeyDBObjIsValid( sig ) );
err = pgpRevokeSig_internal( context, sig, passphrase, passphraseLength,
hashedPhrase, cacheTimeOut, cacheGlobal );
if( IsPGPError( err ) )
return err;
(void)pgpSetPendingNotify( NULL, NULL, NULL, PGPPeekKeyDBObjKey(sig) );
return pgpCreateKeyArray( context, sig->up, 1, NULL,
newobjs, newobjslength );
}
/* This is also called to revoke subkeys */
PGPError
pgpRevokeKey_back (
PGPContextRef context,
PGPUInt32 key_id,
char const * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal,
PGPUInt32 ** newobjs,
PGPSize * newobjslength
)
{
PGPKeyDBObj * keyorsubkey = (PGPKeyDBObj *) key_id;
PGPError err;
if (pgpRPCEnabled())
return pgpRevokeKey_backRPC( context, key_id, passphrase,
passphraseLength, hashedPhrase, cacheTimeOut, cacheGlobal,
newobjs, newobjslength);
pgpAssert( pgpKeyDBObjIsValid( keyorsubkey ) );
err = pgpRevokeKey_internal( keyorsubkey, passphrase, passphraseLength,
hashedPhrase, cacheTimeOut, cacheGlobal );
if( IsPGPError( err ) )
return err;
(void)pgpSetPendingNotify( NULL, NULL, NULL,
PGPPeekKeyDBObjKey(keyorsubkey) );
return pgpCreateKeyArray( context, keyorsubkey, 1, NULL,
newobjs, newobjslength );
}
PGPError
pgpDoChangePassphrase_back (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)
{
PGPKeyDB * keydb = (PGPKeyDB *)keydb_id;
PGPKeyDBObj * key = (PGPKeyDBObj *) key_id;
PGPKeyDBObj * masterkey = (PGPKeyDBObj *) masterkey_id;
if (pgpRPCEnabled())
return pgpDoChangePassphrase_backRPC( context, keydb_id, key_id,
masterkey_id, oldphrase, oldphraseLength, newphrase,
newphraseLength, newPassphraseIsKey, cacheTimeOut,
cacheGlobal );
pgpAssert( pgpKeyDBIsValid( keydb ) );
pgpAssert( pgpKeyDBObjIsValid( key ) );
pgpAssert( IsNull(masterkey) || pgpKeyDBObjIsValid( masterkey ) );
return pgpDoChangePassphrase_internal( keydb, key, masterkey, oldphrase,
oldphraseLength, newphrase,
newphraseLength,
newPassphraseIsKey, cacheTimeOut,
cacheGlobal );
}
PGPError
pgpPassphraseIsValid_back(
PGPContextRef context,
PGPUInt32 key_id,
const char * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal,
PGPBoolean * isValid)
{
PGPKeyDBObj * key = (PGPKeyDBObj *) key_id;
if (pgpRPCEnabled())
return pgpPassphraseIsValid_backRPC( context, key_id, passphrase,
passphraseLength, hashedPhrase, cacheTimeOut, cacheGlobal,
isValid );
pgpAssert( pgpKeyDBObjIsValid( key ) );
return pgpPassphraseIsValid_internal( key, passphrase, passphraseLength,
hashedPhrase, cacheTimeOut,
cacheGlobal, isValid );
}
PGPError
pgpPurgePassphraseCache_back(
PGPContextRef context)
{
if (pgpRPCEnabled())
return pgpPurgePassphraseCache_backRPC( context );
return pgpPurgePassphraseCache_internal( context );
}
PGPError
pgpCountCachedPassphrases_back(
PGPContextRef context,
PGPUInt32 *nLocals,
PGPUInt32 *nGlobals,
PGPUInt32 *nOtherLocals)
{
if (pgpRPCEnabled())
return pgpCountCachedPassphrases_backRPC( context, nLocals, nGlobals,
nOtherLocals );
return pgpCountCachedPassphrases_internal( context, nLocals, nGlobals,
nOtherLocals );
}
PGPError
pgpSetKeyTrust_back(
PGPContextRef context,
PGPUInt32 key_id,
PGPUInt32 trust)
{
PGPKeyDBObj * key = (PGPKeyDBObj *) key_id;
if (pgpRPCEnabled())
return pgpSetKeyTrust_backRPC( context, key_id, trust );
pgpAssert( pgpKeyDBObjIsValid( key ) );
return pgpSetKeyTrust_internal( key, trust );
}
PGPError
pgpGetPasskeyBuffer_back (
PGPContextRef context,
PGPUInt32 key_id,
char const * passphrase,
PGPSize passphraseLength,
PGPByte **passkeyBuffer,
PGPSize *passkeyBufferLength
)
{
PGPKeyDBObj * key = (PGPKeyDBObj *) key_id;
PGPByte * buf;
PGPInt32 bufsize;
PGPError err;
if (pgpRPCEnabled())
return pgpGetPasskeyBuffer_backRPC( context, key_id, passphrase, passphraseLength,
passkeyBuffer, passkeyBufferLength );
pgpAssert( pgpKeyDBObjIsValid( key ) );
*passkeyBuffer = NULL;
*passkeyBufferLength = 0;
if( OBJISSUBKEY( key ))
pgpGetSubKeyNumberInternal( key, kPGPSubKeyProperty_LockingBits,
&bufsize );
else
pgpGetKeyNumberInternal( key, kPGPKeyProperty_LockingBits, &bufsize );
bufsize /= 8;
buf = pgpContextMemAlloc( context, bufsize, 0 );
if( IsNull( buf ) )
return kPGPError_OutOfMemory;
err = pgpGetPasskeyBuffer_internal( key, passphrase, passphraseLength,buf);
if( IsPGPError( err ) )
{
PGPFreeData( buf );
return err;
}
*passkeyBuffer = buf;
*passkeyBufferLength = bufsize;
return kPGPError_NoErr;
}
PGPError
pgpAddKeyOptions_back (PGPContextRef context, PGPUInt32 key_id,
const char * passphrase, PGPSize passphraseLength, PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut, PGPBoolean cacheGlobal,
PGPUInt32 *raklist, PGPSize raklistsize, PGPUInt32 rakclass,
PGPUInt32 **newobjs, PGPSize *newobjslength)
{
PGPKeyDBObj * key = (PGPKeyDBObj *) key_id;
PGPKeyDB * db;
PGPKeySetRef rakset;
PGPError err;
if (pgpRPCEnabled())
return pgpAddKeyOptions_backRPC( context, key_id, passphrase,
passphraseLength, hashedPhrase, cacheTimeOut, cacheGlobal,
raklist, raklistsize, rakclass, newobjs, newobjslength );
pgpAssert( pgpKeyDBObjIsValid( key ) );
db = PGPPeekKeyDBObjKeyDB( key );
err = pgpKeySetUnflattenFree( db, raklist, raklistsize, &rakset );
if( IsPGPError( err ) )
return err;
err = pgpAddKeyOptions_internal( key, passphrase, passphraseLength,
hashedPhrase, cacheTimeOut, cacheGlobal,
rakset, rakclass );
PGPFreeKeySet( rakset );
if( IsPGPError( err ) )
return err;
(void)pgpSetPendingNotify( NULL, NULL, NULL, key );
return pgpCreateKeyArray( context, key, 1, NULL, newobjs, newobjslength );
}
PGPError
pgpUpdateKeyOptions_back (
PGPContextRef context,
PGPUInt32 key_id,
const char * passphrase,
PGPSize passphraseLength,
PGPBoolean hashedPhrase,
PGPUInt32 cacheTimeOut,
PGPBoolean cacheGlobal,
const PGPCipherAlgorithm *prefalg,
PGPSize prefalgLength,
const PGPByte *prefkeyserv,
PGPSize prefkeyservLength,
PGPUInt32 keyflags,
PGPBoolean fkeyflags,
PGPUInt32 keyservprefs,
PGPBoolean fkeyservprefs,
PGPUInt32 ** newobjs,
PGPSize * newobjslength
)
{
PGPKeyDBObj * key = (PGPKeyDBObj *) key_id;
PGPError err;
if (pgpRPCEnabled())
return pgpUpdateKeyOptions_backRPC( context, key_id, passphrase,
passphraseLength, hashedPhrase, cacheTimeOut, cacheGlobal,
prefalg, prefalgLength, prefkeyserv, prefkeyservLength,
keyflags, fkeyflags, keyservprefs, fkeyservprefs,
newobjs, newobjslength );
pgpAssert( pgpKeyDBObjIsValid( key ) );
err = pgpUpdateKeyOptions_internal( key, passphrase, passphraseLength,
hashedPhrase, cacheTimeOut,
cacheGlobal, prefalg, prefalgLength,
prefkeyserv, prefkeyservLength,
keyflags, fkeyflags, keyservprefs,
fkeyservprefs);
if( IsPGPError( err ) )
return err;
(void)pgpSetPendingNotify( NULL, NULL, NULL, key );
return pgpCreateKeyArray( context, key, 1, NULL, newobjs, newobjslength );
}
PGPError
pgpKeyDBAddObject_back( PGPContextRef context, PGPUInt32 kdb_id,
PGPUInt32 obj_id, PGPUInt32 **newobjs, PGPSize *newobjslength,
PGPUInt32 *pnewobj )
{
PGPKeyDB * keydb = (PGPKeyDB *)kdb_id;
PGPKeyDBObj * obj = (PGPKeyDBObj *) obj_id;
PGPKeyDBObj * newobj;
PGPError err;
if (pgpRPCEnabled())
return pgpKeyDBAddObject_backRPC( context, kdb_id, obj_id, newobjs, newobjslength, pnewobj );
pgpAssert( pgpKeyDBIsValid( keydb ) );
pgpAssert( pgpKeyDBObjIsValid( obj ) );
err = pgpKeyDBAddObject_internal( keydb, obj, &newobj );
if( IsPGPError( err ) )
return err;
*pnewobj = (PGPUInt32)newobj;
/* Notification is done in pgpKeyDBArray, called afterwards */
return pgpCreateKeyArray( context, PGPPeekKeyDBObjKey(newobj), 1, NULL,
newobjs, newobjslength );
}
PGPError
pgpKeyDBRemoveObject_back( PGPContextRef context, PGPUInt32 kdb_id,
PGPUInt32 obj_id )
{
PGPKeyDB * keydb = (PGPKeyDB *)kdb_id;
PGPKeyDBObj * obj = (PGPKeyDBObj *) obj_id;
PGPError err = kPGPError_NoErr;
if (pgpRPCEnabled())
return pgpKeyDBRemoveObject_backRPC( context, kdb_id, obj_id );
pgpAssert( pgpKeyDBIsValid( keydb ) );
pgpAssert( pgpKeyDBObjIsValid( obj ) );
if( pgpKeyDBObjIsReal( obj ) )
{
/*
* Record for notification purposes as "new" because that is the
* only pass-back which can handle deleted objects in Update
*/
(void)pgpSetPendingNotify( NULL, NULL, NULL, PGPPeekKeyDBObjKey(obj) );
err = pgpKeyDBRemoveObject_internal( keydb, obj );
}
return err;
}
PGPError
pgpCopyKeys_back( PGPContextRef context, PGPUInt32 srcid, PGPUInt32 dstid,
PGPUInt32 *keylist, PGPSize keylistsize, PGPBoolean neednewkeylist,
PGPUInt32 **newkeylist, PGPSize *newkeylistsize )
{
PGPKeySetRef keyset;
PGPKeySetRef newkeyset;
PGPError err;
PGPKeyDB * srckdb;
PGPKeyDB * dstkdb;
if (pgpRPCEnabled())
return pgpCopyKeys_backRPC( context, srcid, dstid, keylist,
keylistsize, neednewkeylist, newkeylist,
newkeylistsize );
srckdb = (PGPKeyDB *)srcid;
dstkdb = (PGPKeyDB *)dstid;
pgpAssert( pgpKeyDBIsValid( srckdb ) && pgpKeyDBIsValid( dstkdb ) );
err = pgpKeySetUnflattenFree( srckdb, keylist, keylistsize, &keyset );
if( IsPGPError( err ) )
return err;
err = pgpCopyKeys_internal( keyset, dstkdb,
(neednewkeylist?&newkeyset:NULL) );
if( IsPGPError( err ) )
return err;
if( neednewkeylist )
return pgpKeySetFlattenFree( newkeyset, newkeylist, newkeylistsize );
/* Notification is done in pgpKeyDBArray, called afterwards */
return kPGPError_NoErr;
}
PGPError
pgpGlobalRandomPoolAddState_back( PGPBoolean addKeyState, PGPInt32 keyEvent,
PGPBoolean addMouseState, PGPBoolean addSystemState )
{
if (pgpRPCEnabled())
return pgpGlobalRandomPoolAddState_backRPC( addKeyState, keyEvent,
addMouseState, addSystemState );
return pgpGlobalRandomPoolAddState_internal( addKeyState, keyEvent,
addMouseState, addSystemState );
}
PGPError
pgpGlobalRandomPoolGetInfo_back( PGPUInt32 *entropy, PGPUInt32 *size,
PGPUInt32 *minEntropy, PGPBoolean *hasMinEntropy,
PGPBoolean *hasIntelRNG )
{
if (pgpRPCEnabled())
return pgpGlobalRandomPoolGetInfo_backRPC( entropy, size,
minEntropy, hasMinEntropy, hasIntelRNG );
return pgpGlobalRandomPoolGetInfo_internal( entropy, size,
minEntropy, hasMinEntropy, hasIntelRNG );
}
PGPError
pgpRandomGetBytesEntropy_back( PGPContextRef context, PGPUInt32 requestBytes,
PGPUInt32 entropyBits, PGPByte **randbuf, PGPSize *randbuflen )
{
PGPRandomContext *rc;
PGPByte *buf;
if (pgpRPCEnabled())
return pgpRandomGetBytesEntropy_backRPC( context, requestBytes,
entropyBits, randbuf, randbuflen );
*randbuf = NULL;
*randbuflen = 0;
rc = pgpContextGetX9_17RandomContext( context );
buf = pgpContextMemAlloc( context, requestBytes, 0 );
if( IsNull( buf ) )
return kPGPError_OutOfMemory;
pgpRandomGetBytesEntropy( rc, buf, requestBytes, entropyBits );
*randbuf = buf;
*randbuflen = requestBytes;
return kPGPError_NoErr;
}
PGPError
pgpRandomAddBytes_back( PGPContextRef context, PGPByte const *buf,
PGPSize buflen )
{
PGPRandomContext *rc;
if (pgpRPCEnabled())
return pgpRandomAddBytes_backRPC( context, buf, buflen );
rc = pgpContextGetX9_17RandomContext( context );
pgpRandomAddBytes( rc, buf, buflen );
return kPGPError_NoErr;
}
PGPError
pgpRandomStir_back( PGPContextRef context )
{
PGPRandomContext *rc;
if (pgpRPCEnabled())
return pgpRandomStir_backRPC( context );
rc = pgpContextGetX9_17RandomContext( context );
pgpRandomStir( rc );
return kPGPError_NoErr;
}
PGPError
pgpSetRandSeedFile_back( PFLFileSpecRef randFile )
{
if (pgpRPCEnabled())
return pgpSetRandSeedFile_backRPC( randFile );
return pgpSetRandSeedFile_internal( randFile );
}
/*
* Local Variables:
* tab-width: 4
* End:
* vi: ts=4 sw=4
* vim: si
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -