nsspki.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 3,162 行 · 第 1/4 页
H
3,162 行
/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the Netscape security libraries. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1994-2000 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. */#ifndef NSSPKI_H#define NSSPKI_H#ifdef DEBUGstatic const char NSSPKI_CVS_ID[] = "@(#) $RCSfile: nsspki.h,v $ $Revision: 1.1 $ $Date: 2000/03/31 19:16:12 $ $Name: NSS_3_1_1_RTM $";#endif /* DEBUG *//* * nsspki.h * * This file prototypes the methods of the top-level PKI objects. */#ifndef NSSPKIT_H#include "nsspkit.h"#endif /* NSSPKIT_H */PR_BEGIN_EXTERN_C/* * A note about interfaces * * Although these APIs are specified in C, a language which does * not have fancy support for abstract interfaces, this library * was designed from an object-oriented perspective. It may be * useful to consider the standard interfaces which went into * the writing of these APIs. * * Basic operations on all objects: * Destroy -- free a pointer to an object * DeleteStoredObject -- delete an object permanently * * Public Key cryptographic operations: * Encrypt * Verify * VerifyRecover * Wrap * Derive * * Private Key cryptographic operations: * IsStillPresent * Decrypt * Sign * SignRecover * Unwrap * Derive * * Symmetric Key cryptographic operations: * IsStillPresent * Encrypt * Decrypt * Sign * SignRecover * Verify * VerifyRecover * Wrap * Unwrap * Derive * *//* * NSSCertificate * * These things can do crypto ops like public keys, except that the trust, * usage, and other constraints are checked. These objects are "high-level," * so trust, usages, etc. are in the form we throw around (client auth, * email signing, etc.). Remember that theoretically another implementation * (think PGP) could be beneath this object. *//* * NSSCertificate_Destroy * * Free a pointer to a certificate object. */NSS_EXTERN PRStatusNSSCertificate_Destroy( NSSCertificate *c);/* * NSSCertificate_DeleteStoredObject * * Permanently remove this certificate from storage. If this is the * only (remaining) certificate corresponding to a private key, * public key, and/or other object; then that object (those objects) * are deleted too. */NSS_EXTERN PRStatusNSSCertificate_DeleteStoredObject( NSSCertificate *c, NSSCallback *uhh);/* * NSSCertificate_Validate * * Verify that this certificate is trusted, for the specified usage(s), * at the specified time, {word word} the specified policies. */NSS_EXTERN PRStatusNSSCertificate_Validate( NSSCertificate *c, NSSTime *timeOpt, /* NULL for "now" */ NSSUsage *usage, NSSPolicies *policiesOpt /* NULL for none */);/* * NSSCertificate_ValidateCompletely * * Verify that this certificate is trusted. The difference between * this and the previous call is that NSSCertificate_Validate merely * returns success or failure with an appropriate error stack. * However, there may be (and often are) multiple problems with a * certificate. This routine returns an array of errors, specifying * every problem. *//* * Return value must be an array of objects, each of which has * an NSSError, and any corresponding certificate (in the chain) * and/or policy. */NSS_EXTERN void ** /* void *[] */NSSCertificate_ValidateCompletely( NSSCertificate *c, NSSTime *timeOpt, /* NULL for "now" */ NSSUsage *usage, NSSPolicies *policiesOpt, /* NULL for none */ void **rvOpt, /* NULL for allocate */ PRUint32 rvLimit, /* zero for no limit */ NSSArena *arenaOpt /* NULL for heap */);/* * NSSCertificate_ValidateAndDiscoverUsagesAndPolicies * * Returns PR_SUCCESS if the certificate is valid for at least something. */NSS_EXTERN PRStatusNSSCertificate_ValidateAndDiscoverUsagesAndPolicies( NSSCertificate *c, NSSTime **notBeforeOutOpt, NSSTime **notAfterOutOpt, void *allowedUsages, void *disallowedUsages, void *allowedPolicies, void *disallowedPolicies, /* more args.. work on this fgmr */ NSSArena *arenaOpt);/* * NSSCertificate_Encode * */NSS_EXTERN NSSDER *NSSCertificate_Encode( NSSCertificate *c, NSSDER *rvOpt, NSSArena *arenaOpt);/* * NSSCertificate_BuildChain * * This routine returns NSSCertificate *'s for each certificate * in the "chain" starting from the specified one up to and * including the root. The zeroth element in the array is the * specified ("leaf") certificate. */NSS_EXTERN NSSCertificate **NSSCertificate_BuildChain( NSSCertificate *c, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCertificate **rvOpt, PRUint32 rvLimit, /* zero for no limit */ NSSArena *arenaOpt);/* * NSSCertificate_GetTrustDomain * */NSS_EXTERN NSSTrustDomain *NSSCertificate_GetTrustDomain( NSSCertificate *c);/* * NSSCertificate_GetToken * * There doesn't have to be one. */NSS_EXTERN NSSToken *NSSCertificate_GetToken( NSSCertificate *c, PRStatus *statusOpt);/* * NSSCertificate_GetSlot * * There doesn't have to be one. */NSS_EXTERN NSSSlot *NSSCertificate_GetSlot( NSSCertificate *c, PRStatus *statusOpt);/* * NSSCertificate_GetModule * * There doesn't have to be one. */NSS_EXTERN NSSModule *NSSCertificate_GetModule( NSSCertificate *c, PRStatus *statusOpt);/* * NSSCertificate_Encrypt * * Encrypt a single chunk of data with the public key corresponding to * this certificate. */NSS_EXTERN NSSItem *NSSCertificate_Encrypt( NSSCertificate *c, NSSAlgorithmAndParameters *apOpt, NSSItem *data, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSCertificate_Verify * */NSS_EXTERN PRStatusNSSCertificate_Verify( NSSCertificate *c, NSSAlgorithmAndParameters *apOpt, NSSItem *data, NSSItem *signature, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh);/* * NSSCertificate_VerifyRecover * */NSS_EXTERN NSSItem *NSSCertificate_VerifyRecover( NSSCertificate *c, NSSAlgorithmAndParameters *apOpt, NSSItem *signature, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSCertificate_WrapSymmetricKey * * This method tries very hard to to succeed, even in situations * involving sensitive keys and multiple modules. * { relyea: want to add verbiage? } */NSS_EXTERN NSSItem *NSSCertificate_WrapSymmetricKey( NSSCertificate *c, NSSAlgorithmAndParameters *apOpt, NSSSymmetricKey *keyToWrap, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSCertificate_CreateCryptoContext * * Create a crypto context, in this certificate's trust domain, with this * as the distinguished certificate. */NSS_EXTERN NSSCryptoContext *NSSCertificate_CreateCryptoContext( NSSCertificate *c, NSSAlgorithmAndParameters *apOpt, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh );/* * NSSCertificate_GetPublicKey * * Returns the public key corresponding to this certificate. */NSS_EXTERN NSSPublicKey *NSSCertificate_GetPublicKey( NSSCertificate *c);/* * NSSCertificate_FindPrivateKey * * Finds and returns the private key corresponding to this certificate, * if it is available. * * { Should this hang off of NSSUserCertificate? } */NSS_EXTERN NSSPrivateKey *NSSCertificate_FindPrivateKey( NSSCertificate *c, NSSCallback *uhh);/* * NSSCertificate_IsPrivateKeyAvailable * * Returns success if the private key corresponding to this certificate * is available to be used. * * { Should *this* hang off of NSSUserCertificate?? } */NSS_EXTERN PRBoolNSSCertificate_IsPrivateKeyAvailable( NSSCertificate *c, NSSCallback *uhh, PRStatus *statusOpt);/* * If we make NSSUserCertificate not a typedef of NSSCertificate, * then we'll need implementations of the following: * * NSSUserCertificate_Destroy * NSSUserCertificate_DeleteStoredObject * NSSUserCertificate_Validate * NSSUserCertificate_ValidateCompletely * NSSUserCertificate_ValidateAndDiscoverUsagesAndPolicies * NSSUserCertificate_Encode * NSSUserCertificate_BuildChain * NSSUserCertificate_GetTrustDomain * NSSUserCertificate_GetToken * NSSUserCertificate_GetSlot * NSSUserCertificate_GetModule * NSSUserCertificate_GetCryptoContext * NSSUserCertificate_GetPublicKey *//* * NSSUserCertificate_IsStillPresent * * Verify that if this certificate lives on a token, that the token * is still present and the certificate still exists. This is a * lightweight call which should be used whenever it should be * verified that the user hasn't perhaps popped out his or her * token and strolled away. */NSS_EXTERN PRBoolNSSUserCertificate_IsStillPresent( NSSUserCertificate *uc, PRStatus *statusOpt);/* * NSSUserCertificate_Decrypt * * Decrypt a single chunk of data with the private key corresponding * to this certificate. */NSS_EXTERN NSSItem *NSSUserCertificate_Decrypt( NSSUserCertificate *uc, NSSAlgorithmAndParameters *apOpt, NSSItem *data, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSUserCertificate_Sign * */NSS_EXTERN NSSItem *NSSUserCertificate_Sign( NSSUserCertificate *uc, NSSAlgorithmAndParameters *apOpt, NSSItem *data, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSUserCertificate_SignRecover * */NSS_EXTERN NSSItem *NSSUserCertificate_SignRecover( NSSUserCertificate *uc, NSSAlgorithmAndParameters *apOpt, NSSItem *data, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSUserCertificate_UnwrapSymmetricKey * */NSS_EXTERN NSSSymmetricKey *NSSUserCertificate_UnwrapSymmetricKey( NSSUserCertificate *uc, NSSAlgorithmAndParameters *apOpt, NSSItem *wrappedKey, NSSTime *timeOpt, NSSUsage *usage, NSSPolicies *policiesOpt, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSUserCertificate_DeriveSymmetricKey * */NSS_EXTERN NSSSymmetricKey *NSSUserCertificate_DeriveSymmetricKey( NSSUserCertificate *uc, /* provides private key */ NSSCertificate *c, /* provides public key */ NSSAlgorithmAndParameters *apOpt, NSSOID *target, PRUint32 keySizeOpt, /* zero for best allowed */ NSSOperations operations, NSSCallback *uhh);/* filter-certs function(s) *//** ** fgmr -- trust objects **//* * NSSPrivateKey * *//* * NSSPrivateKey_Destroy * * Free a pointer to a private key object. */NSS_EXTERN PRStatusNSSPrivateKey_Destroy( NSSPrivateKey *vk);/* * NSSPrivateKey_DeleteStoredObject * * Permanently remove this object, and any related objects (such as the * certificates corresponding to this key). */NSS_EXTERN PRStatusNSSPrivateKey_DeleteStoredObject( NSSPrivateKey *vk, NSSCallback *uhh);/* * NSSPrivateKey_GetSignatureLength * */NSS_EXTERN PRUint32NSSPrivateKey_GetSignatureLength( NSSPrivateKey *vk);/* * NSSPrivateKey_GetPrivateModulusLength * */NSS_EXTERN PRUint32NSSPrivateKey_GetPrivateModulusLength( NSSPrivateKey *vk);/* * NSSPrivateKey_IsStillPresent * */NSS_EXTERN PRBoolNSSPrivateKey_IsStillPresent( NSSPrivateKey *vk, PRStatus *statusOpt);/* * NSSPrivateKey_Encode * */NSS_EXTERN NSSItem *NSSPrivateKey_Encode( NSSPrivateKey *vk, NSSAlgorithmAndParameters *ap, NSSItem *passwordOpt, /* NULL will cause a callback; "" for no password */ NSSCallback *uhhOpt, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSPrivateKey_GetTrustDomain * * There doesn't have to be one. */NSS_EXTERN NSSTrustDomain *NSSPrivateKey_GetTrustDomain( NSSPrivateKey *vk, PRStatus *statusOpt);/* * NSSPrivateKey_GetToken * */NSS_EXTERN NSSToken *NSSPrivateKey_GetToken( NSSPrivateKey *vk);/* * NSSPrivateKey_GetSlot * */NSS_EXTERN NSSSlot *NSSPrivateKey_GetSlot( NSSPrivateKey *vk);/* * NSSPrivateKey_GetModule * */NSS_EXTERN NSSModule *NSSPrivateKey_GetModule( NSSPrivateKey *vk);/* * NSSPrivateKey_Decrypt * */NSS_EXTERN NSSItem *NSSPrivateKey_Decrypt( NSSPrivateKey *vk, NSSAlgorithmAndParameters *apOpt, NSSItem *encryptedData, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSPrivateKey_Sign * */NSS_EXTERN NSSItem *NSSPrivateKey_Sign( NSSPrivateKey *vk, NSSAlgorithmAndParameters *apOpt, NSSItem *data, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSPrivateKey_SignRecover * */NSS_EXTERN NSSItem *NSSPrivateKey_SignRecover( NSSPrivateKey *vk, NSSAlgorithmAndParameters *apOpt, NSSItem *data, NSSCallback *uhh, NSSItem *rvOpt, NSSArena *arenaOpt);/* * NSSPrivateKey_UnwrapSymmetricKey * */NSS_EXTERN NSSSymmetricKey *NSSPrivateKey_UnwrapSymmetricKey( NSSPrivateKey *vk, NSSAlgorithmAndParameters *apOpt, NSSItem *wrappedKey, NSSCallback *uhh);/* * NSSPrivateKey_DeriveSymmetricKey * */NSS_EXTERN NSSSymmetricKey *NSSPrivateKey_DeriveSymmetricKey( NSSPrivateKey *vk, NSSPublicKey *bk, NSSAlgorithmAndParameters *apOpt, NSSOID *target, PRUint32 keySizeOpt, /* zero for best allowed */ NSSOperations operations, NSSCallback *uhh);/* * NSSPrivateKey_FindPublicKey * */NSS_EXTERN NSSPublicKey *NSSPrivateKey_FindPublicKey( NSSPrivateKey *vk /* { don't need the callback here, right? } */);/* * NSSPrivateKey_CreateCryptoContext * * Create a crypto context, in this key's trust domain, * with this as the distinguished private key. */NSS_EXTERN NSSCryptoContext *NSSPrivateKey_CreateCryptoContext( NSSPrivateKey *vk NSSAlgorithmAndParameters *apOpt,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?