⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resource.c

📁 安全开发库。含客户端建立ssl连接、签名、证书验证、证书发布和撤销等。编译用到nss
💻 C
📖 第 1 页 / 共 3 页
字号:
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- *//*  * 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. *//*   resource.c -- Resources in PSM, and mappings to                  native C data structures */#include "resource.h"#include "hashtbl.h"#include "collectn.h"#include "connect.h"#include "ctrlconn.h"#include "dataconn.h"#include "sslconn.h"#include "sslskst.h"#include "certres.h"#include "keyres.h"#include "crmfres.h"#include "p7dconn.h"#include "p7cinfo.h"#include "p7econn.h"#include "hashconn.h"#include "kgenctxt.h"#include "servimpl.h"#include "ssmerrs.h"#include "nlsutil.h"#include "advisor.h"#include "p12res.h"#include "signtextres.h"#include <stdarg.h>/* Type registration */struct SSMResourceClass{    /* The type of resource. */    SSMResourceType        m_classType;    SSMResourceType        m_superclass;    /* Name. */    char *                 m_className;    /* Data pertaining to each class. */    SSMClientDestroyAction m_clientDest;        /* Accessor functions. */    SSMResourceCreateFunc  m_create_func;    SSMResourceDestroyFunc m_destroy_func;    SSMResourceShutdownFunc m_shutdown_func;    SSMResourceGetAttrIDsFunc m_getids_func;    SSMResourceGetAttrFunc m_get_func;    SSMResourceSetAttrFunc m_set_func;    SSMResourcePickleFunc m_pickle_func;    SSMResourceUnpickleFunc m_unpickle_func;    SSMResourceHTMLFunc m_html_func;    SSMResourcePrintFunc m_print_func;    SSMSubmitHandlerFunc m_submit_func;};SSMHashTable *ssm_classRegistry = NULL;/* Declarations to keep the compiler happy */SSMStatus SSM_FindResourceClass(SSMResourceType type, SSMResourceClass **cls);SSMStatusSSM_ResourceInit(){    SSMStatus rv = PR_SUCCESS;        if (ssm_classRegistry == NULL)        {        rv = SSM_HashCreate(&ssm_classRegistry);        PR_ASSERT(ssm_classRegistry != NULL);        /* Register well-known types.            Connection classes fall into this category. */        SSM_RegisterResourceType("Resource",                                 SSM_RESTYPE_RESOURCE,                                 SSM_RESTYPE_NULL,                                 SSM_CLIENTDEST_NOTHING,                                 SSMResource_Create,                                 SSMResource_Destroy,                                 SSMResource_Shutdown,                                 SSMResource_GetAttrIDs,                                 SSMResource_GetAttr,                                 SSMResource_SetAttr,                                 SSMResource_Pickle,                                 SSMResource_Unpickle,                                 SSMResource_HTML,                                 SSMResource_Print,                                 SSMResource_FormSubmitHandler);        SSM_RegisterResourceType("Connection",                                 SSM_RESTYPE_CONNECTION,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 SSMConnection_Create,                                 SSMConnection_Destroy,                                 SSMConnection_Shutdown,                                 SSMConnection_GetAttrIDs,                                 SSMConnection_GetAttr,                                 SSMConnection_SetAttr,                                  NULL,                                  NULL,                                 NULL,                                 NULL,                                 NULL);        SSM_RegisterResourceType("Control connection",                                 SSM_RESTYPE_CONTROL_CONNECTION,                                 SSM_RESTYPE_CONNECTION,                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 SSMControlConnection_Create,                                 SSMControlConnection_Destroy,                                 SSMControlConnection_Shutdown,                                 SSMControlConnection_GetAttrIDs,                                 SSMControlConnection_GetAttr,                                 NULL,                                  NULL,                                  NULL,                                 NULL,                                 NULL,                                 SSMControlConnection_FormSubmitHandler);        SSM_RegisterResourceType("Data connection",                                 SSM_RESTYPE_DATA_CONNECTION,                                 SSM_RESTYPE_CONNECTION,                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 SSMDataConnection_Create,                                 SSMDataConnection_Destroy,                                 SSMDataConnection_Shutdown,                                 SSMDataConnection_GetAttrIDs,                                 SSMDataConnection_GetAttr,                                 NULL,                                  NULL,                                  NULL,                                 NULL,                                 NULL,                                 NULL);        SSM_RegisterResourceType("SSL connection",                                 SSM_RESTYPE_SSL_DATA_CONNECTION,                                 SSM_RESTYPE_DATA_CONNECTION,                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 SSMSSLDataConnection_Create,                                 SSMSSLDataConnection_Destroy,                                 SSMSSLDataConnection_Shutdown,                                 SSMSSLDataConnection_GetAttrIDs,                                 SSMSSLDataConnection_GetAttr,                                 NULL,                                 NULL,                                  NULL,                                 NULL,                                 NULL,                                 SSMSSLDataConnection_FormSubmitHandler);        SSM_RegisterResourceType("Hash connection",                                 SSM_RESTYPE_HASH_CONNECTION,                                 SSM_RESTYPE_DATA_CONNECTION,                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 SSMHashConnection_Create,                                 SSMHashConnection_Destroy,                                 SSMHashConnection_Shutdown,                                 SSMHashConnection_GetAttrIDs,                                 SSMHashConnection_GetAttr,                                 NULL,                                 NULL,                                  NULL,                                 NULL,                                 NULL,                                 NULL);        SSM_RegisterResourceType("PKCS7 decode connection",                                 SSM_RESTYPE_PKCS7_DECODE_CONNECTION,                                 SSM_RESTYPE_DATA_CONNECTION,                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 SSMP7DecodeConnection_Create,                                 SSMP7DecodeConnection_Destroy,                                 SSMP7DecodeConnection_Shutdown,                                 SSMP7DecodeConnection_GetAttrIDs,                                 SSMP7DecodeConnection_GetAttr,                                 NULL,                                 NULL,                                  NULL,                                 NULL,                                 NULL,                                 NULL);        SSM_RegisterResourceType("PKCS7 encode connection",                                 SSM_RESTYPE_PKCS7_ENCODE_CONNECTION,                                 SSM_RESTYPE_DATA_CONNECTION,                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 SSMP7EncodeConnection_Create,                                 SSMP7EncodeConnection_Destroy,                                 SSMP7EncodeConnection_Shutdown,                                 NULL,                                 SSMP7EncodeConnection_GetAttr,                                 SSMP7EncodeConnection_SetAttr,                                 NULL,                                  NULL,                                 NULL,                                 NULL,                                 NULL);        SSM_RegisterResourceType("PKCS7 content info",                                 SSM_RESTYPE_PKCS7_CONTENT_INFO,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_FREE, /* client destroy */                                 SSMP7ContentInfo_Create,                                 SSMP7ContentInfo_Destroy,                                 NULL,                                 SSMP7ContentInfo_GetAttrIDs,                                 SSMP7ContentInfo_GetAttr,                                 NULL,                                 NULL,                                  NULL,                                 NULL,                                 NULL,                                 NULL);        SSM_RegisterResourceType("SSL socket status object",                                 SSM_RESTYPE_SSL_SOCKET_STATUS,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_FREE, /* client destroy */                                 SSMSSLSocketStatus_Create,                                 SSMSSLSocketStatus_Destroy,                                 NULL,                                 SSMSSLSocketStatus_GetAttrIDs,                                 SSMSSLSocketStatus_GetAttr,                                 NULL,                                 SSMSSLSocketStatus_Pickle,                                  SSMSSLSocketStatus_Unpickle,                                 SSMSSLSocketStatus_HTML,                                 NULL,                                 NULL);        SSM_RegisterResourceType("Certificate",                                 SSM_RESTYPE_CERTIFICATE,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_FREE, /* client destroy */                                 SSMResourceCert_Create,                                 SSMResourceCert_Destroy,                                 NULL,                                 SSMResourceCert_GetAttrIDs,                                 SSMResourceCert_GetAttr,                                 NULL,                                 SSMResourceCert_Pickle,                                  SSMResourceCert_Unpickle,                                 SSMResourceCert_HTML,                                 NULL,                                 SSMResourceCert_FormSubmitHandler);        SSM_RegisterResourceType("Key pair",                                 SSM_RESTYPE_KEY_PAIR,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_FREE, /* client destroy */                                 SSMKeyPair_Create,                                 SSMKeyPair_Destroy,                                 NULL,                                 NULL,                                 NULL,                                 SSMKeyPair_SetAttr,                                 NULL,                                 NULL,                                 NULL,                                 NULL,                                 NULL);        SSM_RegisterResourceType("CRMF request",                                 SSM_RESTYPE_CRMF_REQUEST,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_FREE, /* client destroy */                                 SSMCRMFRequest_Create,                                 SSMCRMFRequest_Destroy,                                 NULL,                                 NULL,                                 NULL,                                 SSMCRMFRequest_SetAttr,                                 NULL,                                 NULL,                                 NULL,                                 NULL,                                 NULL);        SSM_RegisterResourceType("Key gen context",                                 SSM_RESTYPE_KEYGEN_CONTEXT, /* type */                                 SSM_RESTYPE_RESOURCE, /* superclass */                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 SSMKeyGenContext_Create, /* create */                                 SSMKeyGenContext_Destroy, /* destroy */                                 SSMKeyGenContext_Shutdown, /* shutdown */                                 NULL, /* get attr IDs */                                 SSMKeyGenContext_GetAttr, /* get attr */                                 SSMKeyGenContext_SetAttr,                                 NULL, /* pickle */                                 NULL, /* unpickle */                                 NULL, /* HTML */                                 SSMKeyGenContext_Print, /* Print */                                 SSMKeyGenContext_FormSubmitHandler);        SSM_RegisterResourceType("Security advisor context",                                 SSM_RESTYPE_SECADVISOR_CONTEXT,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_SHUTDOWN, /* client destroy */                                 NULL,                                 SSMSecurityAdvisorContext_Destroy,                                 NULL,                                  SSMSecurityAdvisorContext_GetAttrIDs,                                 SSMSecurityAdvisorContext_GetAttr,                                 SSMSecurityAdvisorContext_SetAttr,                                 NULL,                                  NULL,                                 NULL,                                 SSMSecurityAdvisorContext_Print,                                 SSMSecurityAdvisorContext_FormSubmitHandler);        SSM_RegisterResourceType("PKCS12 Context",                                 SSM_RESTYPE_PKCS12_CONTEXT,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_FREE,                                 SSMPKCS12Context_Create,                                 SSMPKCS12Context_Destroy,                                 NULL,                                 NULL,                                 NULL,                                 NULL,                                 NULL,                                 NULL,                                 NULL,                                 SSMPKCS12Context_Print,                                 SSMPKCS12Context_FormSubmitHandler);        SSM_RegisterResourceType("SignText Context",                                 SSM_RESTYPE_SIGNTEXT,                                 SSM_RESTYPE_RESOURCE,                                 SSM_CLIENTDEST_FREE,                                 SSMSignTextResource_Create,                                 SSMSignTextResource_Destroy,                                 SSMSignTextResource_Shutdown,                                 NULL,                                 SSMSignTextResource_GetAttr,                                 NULL,                                 NULL,                                 NULL,                                 NULL,                                 SSMSignTextResource_Print,                                 SSMSignTextResource_FormSubmitHandler);    }        return rv;}SSMStatusSSMResource_Destroy(SSMResource *res, PRBool doFree){    SSMStatus rv;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -