Compare commits

..

9 Commits

Author SHA1 Message Date
pavlov%netscape.com
bacf018470 merge from head
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@53628 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 05:00:21 +00:00
pavlov%netscape.com
661845527f update makefile
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@53626 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 04:52:09 +00:00
pavlov%netscape.com
2695f743d2 add to branch
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@53625 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 04:50:38 +00:00
pavlov%netscape.com
383ba86d8b add other file
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@53621 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 04:47:14 +00:00
pavlov%netscape.com
8c455b008e merge from head
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@53620 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 04:47:02 +00:00
(no author)
e09c15621a This commit was manufactured by cvs2svn to create branch 'WIDGET_IDL'.
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@53591 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 01:51:40 +00:00
pavlov%netscape.com
6b3eface10 merge from head and new nsBaseWidget stuff
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@53567 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-15 23:26:57 +00:00
pavlov%netscape.com
e815a771b0 initial checkin to branch
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@49611 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-01 22:52:03 +00:00
(no author)
0605f9fbfb This commit was manufactured by cvs2svn to create branch 'WIDGET_IDL'.
git-svn-id: svn://10.0.0.236/branches/WIDGET_IDL@49566 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-01 11:17:28 +00:00
775 changed files with 142490 additions and 17679 deletions

View File

@@ -1,74 +0,0 @@
#! gmake
#
# 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.
#
#######################################################################
# (1) Include initial platform-independent assignments (MANDATORY). #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "global" configuration information. (OPTIONAL) #
#######################################################################
include $(CORE_DEPTH)/coreconf/config.mk
#######################################################################
# (3) Include "component" configuration information. (OPTIONAL) #
#######################################################################
#######################################################################
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
#######################################################################
include $(CORE_DEPTH)/coreconf/rules.mk
#######################################################################
# (6) Execute "component" rules. (OPTIONAL) #
#######################################################################
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -1,3 +0,0 @@
cmtclist.h
cmtcmn.h
cmtjs.h

View File

@@ -1,74 +0,0 @@
#! gmake
#
# 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.
#
#######################################################################
# (1) Include initial platform-independent assignments (MANDATORY). #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "global" configuration information. (OPTIONAL) #
#######################################################################
include $(CORE_DEPTH)/coreconf/config.mk
#######################################################################
# (3) Include "component" configuration information. (OPTIONAL) #
#######################################################################
#######################################################################
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
include config.mk
#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
#######################################################################
include $(CORE_DEPTH)/coreconf/rules.mk
#######################################################################
# (6) Execute "component" rules. (OPTIONAL) #
#######################################################################
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -1,70 +0,0 @@
#! gmake
#
# 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.
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = cmt
EXPORTS = \
cmtcmn.h \
cmtjs.h \
cmtclist.h \
$(NULL)
MODULE = security
CSRCS = cmtinit.c \
cmtssl.c \
cmtutils.c \
cmtcert.c \
cmthash.c \
cmtpkcs7.c \
cmtres.c \
cmtjs.c \
cmtevent.c \
cmtpasswd.c \
cmtadvisor.c \
cmtrng.c \
cmtsdr.c \
$(NULL)
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lprotocol
include $(topsrcdir)/config/rules.mk

View File

@@ -1,99 +0,0 @@
/*
* 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.
*/
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
#ifdef XP_MAC
#include "cmtmac.h"
#endif
CMTStatus CMT_SecurityAdvisor(PCMT_CONTROL control, CMTSecurityAdvisorData* data, CMUint32 *resID)
{
CMTItem message = {0, NULL, 0};
SecurityAdvisorRequest request;
SingleNumMessage reply;
if (!control) {
return CMTFailure;
}
if (!data) {
return CMTFailure;
}
request.infoContext = data->infoContext;
request.resID = data->resID;
request.hostname = data->hostname;
request.senderAddr = data->senderAddr;
request.encryptedP7CInfo = data->encryptedP7CInfo;
request.signedP7CInfo = data->signedP7CInfo;
request.decodeError = data->decodeError;
request.verifyError = data->verifyError;
request.encryptthis = data->encryptthis;
request.signthis = data->signthis;
request.numRecipients = data->numRecipients;
request.recipients = data->recipients;
message.type = SSM_REQUEST_MESSAGE | SSM_SECURITY_ADVISOR;
if (CMT_EncodeMessage(SecurityAdvisorRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Send the message and get the response */
if (CMT_SendMessage(control, &message) != CMTSuccess) {
goto loser;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_SECURITY_ADVISOR)) {
goto loser;
}
/* Decode the message */
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*resID = reply.value;
return CMTSuccess;
loser:
if (message.data) {
free(message.data);
}
return CMTFailure;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,111 +0,0 @@
/*
* 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 cmtclist_h___
#define cmtclist_h___
typedef struct CMTCListStr CMTCList;
/*
** Circular linked list
*/
struct CMTCListStr {
CMTCList *next;
CMTCList *prev;
};
/*
** Insert element "_e" into the list, before "_l".
*/
#define CMT_INSERT_BEFORE(_e,_l) \
(_e)->next = (_l); \
(_e)->prev = (_l)->prev; \
(_l)->prev->next = (_e); \
(_l)->prev = (_e); \
/*
** Insert element "_e" into the list, after "_l".
*/
#define CMT_INSERT_AFTER(_e,_l) \
(_e)->next = (_l)->next; \
(_e)->prev = (_l); \
(_l)->next->prev = (_e); \
(_l)->next = (_e); \
/*
** Append an element "_e" to the end of the list "_l"
*/
#define CMT_APPEND_LINK(_e,_l) CMT_INSERT_BEFORE(_e,_l)
/*
** Insert an element "_e" at the head of the list "_l"
*/
#define CMT_INSERT_LINK(_e,_l) CMT_INSERT_AFTER(_e,_l)
/* Return the head/tail of the list */
#define CMT_LIST_HEAD(_l) (_l)->next
#define CMT_LIST_TAIL(_l) (_l)->prev
/*
** Remove the element "_e" from it's circular list.
*/
#define CMT_REMOVE_LINK(_e) \
(_e)->prev->next = (_e)->next; \
(_e)->next->prev = (_e)->prev; \
/*
** Remove the element "_e" from it's circular list. Also initializes the
** linkage.
*/
#define CMT_REMOVE_AND_INIT_LINK(_e) \
(_e)->prev->next = (_e)->next; \
(_e)->next->prev = (_e)->prev; \
(_e)->next = (_e); \
(_e)->prev = (_e); \
/*
** Return non-zero if the given circular list "_l" is empty, zero if the
** circular list is not empty
*/
#define CMT_CLIST_IS_EMPTY(_l) \
((_l)->next == (_l))
/*
** Initialize a circular list
*/
#define CMT_INIT_CLIST(_l) \
(_l)->next = (_l); \
(_l)->prev = (_l); \
#define CMT_INIT_STATIC_CLIST(_l) \
{(_l), (_l)}
#endif /* cmtclist_h___ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,480 +0,0 @@
/* -*- 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.
*/
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
#include <string.h>
#ifdef XP_UNIX
#include <sys/time.h>
#endif
/* Typedefs */
typedef void (*taskcompleted_handler_fn)(CMUint32 resourceID, CMUint32 numReqProcessed, CMUint32 resultCode, void* data);
CMTStatus CMT_SetUIHandlerCallback(PCMT_CONTROL control,
uiHandlerCallback_fn f, void *data)
{
return CMT_RegisterEventHandler(control, SSM_UI_EVENT, 0,
(void_fun)f, data);
}
void CMT_SetFilePathPromptCallback(PCMT_CONTROL control,
filePathPromptCallback_fn f, void* arg)
{
control->userFuncs.promptFilePath = f;
control->userFuncs.filePromptArg = arg;
}
void CMT_SetPromptCallback(PCMT_CONTROL control,
promptCallback_fn f, void *arg)
{
control->userFuncs.promptCallback = f;
control->userFuncs.promptArg = arg;
}
void CMT_SetSavePrefsCallback(PCMT_CONTROL control, savePrefsCallback_fn f)
{
control->userFuncs.savePrefs = f;
}
CMTStatus CMT_RegisterEventHandler(PCMT_CONTROL control, CMUint32 type,
CMUint32 resourceID, void_fun handler,
void* data)
{
PCMT_EVENT ptr;
/* This is the first connection */
if (control->cmtEventHandlers == NULL) {
control->cmtEventHandlers = ptr =
(PCMT_EVENT)calloc(sizeof(CMT_EVENT), 1);
if (!ptr) {
goto loser;
}
} else {
/* Look for another event handler of the same type. Make sure the
event handler with a rsrcid of 0 is farther down the list so
that it doesn't get chosen when there's an event handler for
a specific rsrcid.
*/
for (ptr=control->cmtEventHandlers; ptr != NULL; ptr = ptr->next) {
if (ptr->type == type && resourceID != 0) {
/* So we've got an event handler that wants to over-ride
an existing event handler. We'll put it before the one
that's already here.
*/
if (ptr->previous == NULL) {
/* We're going to insert at the front of the list*/
control->cmtEventHandlers = ptr->previous =
(PCMT_EVENT)calloc(sizeof(CMT_EVENT), 1);
if (ptr->previous == NULL) {
goto loser;
}
ptr->previous->next = ptr;
ptr = control->cmtEventHandlers;
} else {
/* We want to insert in the middle of the list */
PCMT_EVENT tmpEvent;
tmpEvent = (PCMT_EVENT)calloc(sizeof(CMT_EVENT), 1);
if (tmpEvent == NULL) {
goto loser;
}
tmpEvent->previous = ptr->previous;
ptr->previous->next = tmpEvent;
tmpEvent->next = ptr;
ptr->previous = tmpEvent;
ptr = tmpEvent;
}
break;
}
if (ptr->next == NULL) break;
}
if (ptr == NULL) {
goto loser;
}
if (ptr->next == NULL) {
/* We're adding the event handler at the end of the list. */
ptr->next = (PCMT_EVENT)calloc(sizeof(CMT_EVENT), 1);
if (!ptr->next) {
goto loser;
}
/* Fix up the pointers */
ptr->next->previous = ptr;
ptr = ptr->next;
}
}
/* Fill in the data */
ptr->type = type;
ptr->resourceID = resourceID;
ptr->handler = handler;
ptr->data = data;
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_UnregisterEventHandler(PCMT_CONTROL control, CMUint32 type,
CMUint32 resourceID)
{
PCMT_EVENT ptr, pptr = NULL;
for (ptr = control->cmtEventHandlers; ptr != NULL;
pptr = ptr, ptr = ptr->next) {
if ((ptr->type == type) && (ptr->resourceID == resourceID)) {
if (pptr == NULL) {
/* node is at head */
control->cmtEventHandlers = ptr->next;
if (control->cmtEventHandlers != NULL) {
control->cmtEventHandlers->previous = NULL;
}
free(ptr);
return CMTSuccess;
}
/* node is elsewhere */
pptr->next = ptr->next;
if (ptr->next != NULL) {
ptr->next->previous = pptr;
}
free(ptr);
return CMTSuccess;
}
}
return CMTFailure;
}
PCMT_EVENT CMT_GetEventHandler(PCMT_CONTROL control, CMUint32 type,
CMUint32 resourceID)
{
PCMT_EVENT ptr;
for (ptr = control->cmtEventHandlers; ptr != NULL; ptr = ptr->next) {
if ((ptr->type == type) && ((ptr->resourceID == resourceID) ||
!ptr->resourceID)) {
return ptr;
}
}
return NULL;
}
PCMT_EVENT CMT_GetFirstEventHandler(PCMT_CONTROL control, CMUint32 type,
CMUint32 resourceID)
{
PCMT_EVENT ptr;
for (ptr = control->cmtEventHandlers; ptr != NULL; ptr = ptr->next) {
if ((ptr->type == type) && ((ptr->resourceID == resourceID) ||
!ptr->resourceID)) {
return ptr;
}
}
return NULL;
}
PCMT_EVENT CMT_GetNextEventHandler(PCMT_CONTROL control, PCMT_EVENT e)
{
PCMT_EVENT ptr;
for (ptr = control->cmtEventHandlers; ptr != NULL || ptr == e;
ptr = ptr->next) {
}
for (; ptr != NULL; ptr = ptr->next) {
if ((ptr->type == e->type) && ((ptr->resourceID == e->resourceID) ||
!ptr->resourceID)) {
return ptr;
}
}
return NULL;
}
void CMT_ProcessEvent(PCMT_CONTROL cm_control)
{
CMTSocket sock;
CMTItem eventData={ 0, NULL, 0 };
/* Get the control socket */
sock = cm_control->sock;
/* Acquire a lock on the control connection */
CMT_LOCK(cm_control->mutex);
/* Do another select here to be sure
that the socket is readable */
if (cm_control->sockFuncs.select(&sock, 1, 1) != sock) {
/* There's no event. */
goto done;
}
/* Read the event */
if (CMT_ReceiveMessage(cm_control, &eventData) == CMTFailure) {
goto done;
}
CMT_UNLOCK(cm_control->mutex);
/* Dispatch the event */
CMT_DispatchEvent(cm_control, &eventData);
return;
done:
/* Release the lock on the control connection */
CMT_UNLOCK(cm_control->mutex);
}
void CMT_EventLoop(PCMT_CONTROL cm_control)
{
CMTSocket sock;
/* Get the control socket */
sock = cm_control->sock;
CMT_ReferenceControlConnection(cm_control);
/* Select on the control socket to see if it's readable */
while(cm_control->sockFuncs.select(&sock, 1, 0)) {
CMT_ProcessEvent(cm_control);
}
CMT_CloseControlConnection(cm_control);
return;
}
void
CMT_PromptUser(PCMT_CONTROL cm_control, CMTItem *eventData)
{
char *promptReply = NULL;
CMTItem response={ 0, NULL, 0 };
PromptRequest request;
PromptReply reply;
void * clientContext;
/* Decode the message */
if (CMT_DecodeMessage(PromptRequestTemplate, &request, eventData) != CMTSuccess) {
goto loser;
}
/* Copy the client context to a pointer */
clientContext = CMT_CopyItemToPtr(request.clientContext);
if (cm_control->userFuncs.promptCallback == NULL) {
goto loser;
}
promptReply =
cm_control->userFuncs.promptCallback(cm_control->userFuncs.promptArg,
request.prompt, clientContext, 1);
response.type = SSM_EVENT_MESSAGE | SSM_PROMPT_EVENT;
if (!promptReply) {
/* the user canceled the prompt or other errors occurred */
reply.cancel = CM_TRUE;
}
else {
/* note that this includes an empty string (zero length) password */
reply.cancel = CM_FALSE;
}
reply.resID = request.resID;
reply.promptReply = promptReply;
/* Encode the message */
if (CMT_EncodeMessage(PromptReplyTemplate, &response, &reply) != CMTSuccess) {
goto loser;
}
CMT_TransmitMessage(cm_control, &response);
loser:
if (promptReply != NULL) {
cm_control->userFuncs.userFree(promptReply);
}
return;
}
void CMT_GetFilePath(PCMT_CONTROL cm_control, CMTItem * eventData)
{
char *fileName=NULL;
CMTItem response = { 0, NULL, 0 };
FilePathRequest request;
FilePathReply reply;
/* Decode the request */
if (CMT_DecodeMessage(FilePathRequestTemplate, &request, eventData) != CMTSuccess) {
goto loser;
}
if (cm_control->userFuncs.promptFilePath == NULL) {
goto loser;
}
fileName =
cm_control->userFuncs.promptFilePath(cm_control->userFuncs.filePromptArg,
request.prompt, request.fileRegEx,
request.getExistingFile);
response.type = SSM_EVENT_MESSAGE | SSM_FILE_PATH_EVENT;
reply.resID = request.resID;
reply.filePath = fileName;
/* Encode the reply */
if (CMT_EncodeMessage(FilePathReplyTemplate, &response, &reply) != CMTSuccess) {
goto loser;
}
CMT_TransmitMessage(cm_control, &response);
cm_control->userFuncs.userFree(fileName);
loser:
return;
}
void CMT_SavePrefs(PCMT_CONTROL cm_control, CMTItem* eventData)
{
SetPrefListMessage request;
int i;
/* decode the request */
if (CMT_DecodeMessage(SetPrefListMessageTemplate, &request, eventData) !=
CMTSuccess) {
return;
}
if (cm_control->userFuncs.savePrefs == NULL) {
/* callback was not registered: bail */
return;
}
cm_control->userFuncs.savePrefs(request.length,
(CMTSetPrefElement*)request.list);
for (i = 0; i < request.length; i++) {
if (request.list[i].key != NULL) {
free(request.list[i].key);
}
if (request.list[i].value != NULL) {
free(request.list[i].value);
}
}
return;
}
void CMT_DispatchEvent(PCMT_CONTROL cm_control, CMTItem * eventData)
{
CMUint32 eventType;
CMTItem msgCopy;
/* Init the msgCopy */
msgCopy.data = 0;
/* Get the event type */
if ((eventData->type & SSM_CATEGORY_MASK) != SSM_EVENT_MESSAGE) {
/* Somehow there was a message on the socket that was not
* an event message. Dropping it on the floor.
*/
goto loser;
}
eventType = (eventData->type & SSM_TYPE_MASK);
/* We must now dispatch the event based on it's type */
switch (eventType) {
case SSM_UI_EVENT:
{
PCMT_EVENT p;
UIEvent event;
void * clientContext = NULL;
/* Copy the message to allow a second try with the old format */
msgCopy.len = eventData->len;
msgCopy.data = calloc(msgCopy.len, 1);
if (msgCopy.data) {
memcpy(msgCopy.data, eventData->data, eventData->len);
}
/* Get the event data first */
if (CMT_DecodeMessage(UIEventTemplate, &event, eventData) != CMTSuccess) {
/* Attempt to decode using the old format. Modal is True */
if (!msgCopy.data ||
CMT_DecodeMessage(OldUIEventTemplate, &event, &msgCopy) != CMTSuccess) {
goto loser;
}
/* Set default modal value */
event.isModal = CM_TRUE;
}
/* Convert the client context to a pointer */
clientContext = CMT_CopyItemToPtr(event.clientContext);
/* Call any handlers for this event */
p = CMT_GetEventHandler(cm_control, eventType, event.resourceID);
if (!p) {
goto loser;
}
(*(uiHandlerCallback_fn)(p->handler))(event.resourceID,
clientContext, event.width,
event.height, event.isModal, event.url,
p->data);
break;
}
case SSM_TASK_COMPLETED_EVENT:
{
PCMT_EVENT p;
TaskCompletedEvent event;
/* Get the event data */
if (CMT_DecodeMessage(TaskCompletedEventTemplate, &event, eventData) != CMTSuccess) {
goto loser;
}
/* Call handler for this event */
p = CMT_GetEventHandler(cm_control, eventType, event.resourceID);
if (!p) {
goto loser;
}
(*(taskcompleted_handler_fn)(p->handler))(event.resourceID,
event.numTasks,
event.result, p->data);
break;
}
case SSM_AUTH_EVENT:
CMT_ServicePasswordRequest(cm_control, eventData);
break;
case SSM_FILE_PATH_EVENT:
CMT_GetFilePath(cm_control, eventData);
break;
case SSM_PROMPT_EVENT:
CMT_PromptUser(cm_control, eventData);
break;
case SSM_SAVE_PREF_EVENT:
CMT_SavePrefs(cm_control, eventData);
break;
default:
break;
}
loser:
free(eventData->data);
free(msgCopy.data);
return;
}

View File

@@ -1,216 +0,0 @@
/* -*- 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.
*/
#ifdef XP_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#else
#ifdef XP_MAC
#include "macsocket.h"
#include "string.h"
#else
#include <windows.h>
#include <winsock.h>
#endif
#endif
#include <errno.h>
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
#include "rsrcids.h"
CMTStatus CMT_HashCreate(PCMT_CONTROL control, CMUint32 algID,
CMUint32 * connID)
{
CMTItem message;
SingleNumMessage request;
DataConnectionReply reply;
/* Check passed in parameters */
if (!control) {
goto loser;
}
/* Set up the request */
request.value = algID;
/* Encode the request */
if (CMT_EncodeMessage(SingleNumMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_DATA_CONNECTION | SSM_HASH_STREAM;
/* Send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the response */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_DATA_CONNECTION | SSM_HASH_STREAM)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(DataConnectionReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
CMTSocket sock;
sock = control->sockFuncs.socket(0);
if(sock == NULL) {
goto loser;
}
if (control->sockFuncs.connect(sock, reply.port, NULL) != CMTSuccess) {
goto loser;
}
/* Send the hello message */
control->sockFuncs.send(sock, control->nonce.data, control->nonce.len);
/* Save connection info */
if (CMT_AddDataConnection(control, sock, reply.connID)
!= CMTSuccess) {
goto loser;
}
/* Set the connection ID */
*connID = reply.connID;
return CMTSuccess;
}
loser:
*connID = 0;
return CMTFailure;
}
CMTStatus CMT_HASH_Destroy(PCMT_CONTROL control, CMUint32 connectionID)
{
if (!control) {
goto loser;
}
/* Get the cotext implementation data */
if (CMT_CloseDataConnection(control, connectionID) == CMTFailure) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_HASH_Begin(PCMT_CONTROL control, CMUint32 connectionID)
{
return CMTSuccess;
}
CMTStatus CMT_HASH_Update(PCMT_CONTROL control, CMUint32 connectionID, const unsigned char * buf, CMUint32 len)
{
CMTSocket sock;
CMUint32 sent;
/* Do some parameter checking */
if (!control || !buf) {
goto loser;
}
/* Get the data socket */
if (CMT_GetDataSocket(control, connectionID, &sock) == CMTFailure) {
goto loser;
}
/* Write the data to the socket */
sent = CMT_WriteThisMany(control, sock, (void*)buf, len);
if (sent != len) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_HASH_End(PCMT_CONTROL control, CMUint32 connectionID,
unsigned char * result, CMUint32 * resultlen,
CMUint32 maxLen)
{
CMTItem hash = { 0, NULL, 0 };
/* Do some parameter checking */
if (!control || !result || !resultlen) {
goto loser;
}
/* Close the connection */
if (CMT_CloseDataConnection(control, connectionID) == CMTFailure) {
goto loser;
}
/* Get the context info */
if (CMT_GetStringAttribute(control, connectionID, SSM_FID_HASHCONN_RESULT,
&hash) == CMTFailure) {
goto loser;
}
if (!hash.data) {
goto loser;
}
*resultlen = hash.len;
if (hash.len > maxLen) {
memcpy(result, hash.data, maxLen);
} else {
memcpy(result, hash.data, hash.len);
}
if (hash.data) {
free(hash.data);
}
return CMTSuccess;
loser:
if (hash.data) {
free(hash.data);
}
return CMTFailure;
}

View File

@@ -1,56 +0,0 @@
/*
* 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 __CMTIMPL_H_
#define __CMTIMPL_H_
typedef unsigned long CMT_HANDLE;
struct _CMTControl {
CMT_HANDLE channelID;
int socketID;
CMTStatus (* cmtEventCallback)(struct _CMTControl * control,
CMTItem * event, void * arg);
void * cmtEventCallbackArg;
struct _CMTData * cmtDataConnection;
} _CMTControl;
struct _CMTData {
CMT_HANDLE channelID;
int socketID;
struct _CMTData * next;
struct _CMTData * previous;
};
#endif /*__CMTIMPL_H_*/

View File

@@ -1,484 +0,0 @@
/* -*- 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.
*/
#ifdef XP_UNIX
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/stat.h>
#include <netinet/tcp.h>
#else
#ifdef XP_MAC
#include <Events.h> // for WaitNextEvent
#else /* Windows */
#include <windows.h>
#include <winsock.h>
#include <direct.h>
#include <sys/stat.h>
#endif
#endif
#include "messages.h"
#include "cmtcmn.h"
#include "cmtutils.h"
#include <string.h>
#ifdef XP_UNIX
#define DIRECTORY_SEPARATOR '/'
#elif defined WIN32
#define DIRECTORY_SEPARATOR '\\'
#elif defined XP_MAC
#define DIRECTORY_SEPARATOR ':'
#endif
/* Local defines */
#define CARTMAN_PORT 11111
#define MAX_PATH_LEN 256
/* write to the cmnav.log */
#if 0
#define LOG(x); do { FILE *f; f=fopen("cmnav.log","a+"); if (f) { \
fprintf(f, x); fclose(f); } } while(0);
#define LOG_S(x); do { FILE *f; f=fopen("cmnav.log","a+"); if (f) { \
fprintf(f, "%s", x); fclose(f); } } while(0);
#define ASSERT(x); if (!(x)) { LOG("ASSERT:"); LOG(#x); LOG("\n"); exit(-1); }
#else
#define LOG(x); ;
#define LOG_S(x); ;
#define ASSERT(x); ;
#endif
static char*
getCurrWorkDir(char *buf, int maxLen)
{
#if defined WIN32
return _getcwd(buf, maxLen);
#elif defined XP_UNIX
return getcwd(buf, maxLen);
#else
return NULL;
#endif
}
static void
setWorkingDir(char *path)
{
#if defined WIN32
_chdir(path);
#elif defined XP_UNIX
chdir(path);
#else
return;
#endif
}
static CMTStatus
launch_psm(char *executable)
{
char command[MAX_PATH_LEN];
#ifdef WIN32
STARTUPINFO sui;
PROCESS_INFORMATION pi;
UNALIGNED long *posfhnd;
int i;
char *posfile;
sprintf(command,"%s > psmlog", executable);
ZeroMemory( &sui, sizeof(sui) );
sui.cb = sizeof(sui);
sui.cbReserved2 = (WORD)(sizeof( int ) + (3 * (sizeof( char ) +
sizeof( long ))));
sui.lpReserved2 = calloc( sui.cbReserved2, 1 );
*((UNALIGNED int *)(sui.lpReserved2)) = 3;
posfile = (char *)(sui.lpReserved2 + sizeof( int ));
posfhnd = (UNALIGNED long *)(sui.lpReserved2 + sizeof( int ) +
(3 * sizeof( char )));
for ( i = 0, posfile = (char *)(sui.lpReserved2 + sizeof( int )),
posfhnd = (UNALIGNED long *)(sui.lpReserved2 + sizeof( int ) + (3 * sizeof( char ))) ;
i < 3 ; i++, posfile++, posfhnd++ ) {
*posfile = 0;
*posfhnd = (long)INVALID_HANDLE_VALUE;
}
/* Now, fire up PSM */
if (!CreateProcess(NULL, command, NULL, NULL, TRUE, DETACHED_PROCESS,
NULL, NULL, &sui, &pi)) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
#elif defined XP_UNIX
sprintf(command,"./%s &", executable);
if (system(command) == -1) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
#else
return CMTFailure;
#endif
}
PCMT_CONTROL CMT_EstablishControlConnection(char *inPath,
CMT_SocketFuncs *sockFuncs,
CMT_MUTEX *mutex)
{
PCMT_CONTROL control;
char *executable;
char *newWorkingDir;
char oldWorkingDir[MAX_PATH_LEN];
int i;
char *path = NULL;
size_t stringLen;
/* On the Mac, we do special magic in the Seamonkey PSM component, so
if PSM isn't launched by the time we reach this point, we're not doing well. */
#ifndef XP_MAC
struct stat stbuf;
/*
* Create our own copy of path.
* I'd like to do a straight strdup here, but that caused problems
* for https.
*/
stringLen = strlen(inPath);
path = (char*) malloc(stringLen+1);
memcpy(path, inPath, stringLen);
path[stringLen] = '\0';
control = CMT_ControlConnect(mutex, sockFuncs);
if (control != NULL) {
return control;
}
/*
* We have to try to launch it now, so it better be a valid
* path.
*/
if (stat(path, &stbuf) == -1) {
goto loser;
}
/*
* Now we have to parse the path and launch the psm server.
*/
executable = strrchr(path, DIRECTORY_SEPARATOR);
if (executable != NULL) {
*executable = '\0';
executable ++;
newWorkingDir = path;
} else {
executable = path;
newWorkingDir = NULL;
}
if (getCurrWorkDir(oldWorkingDir, MAX_PATH_LEN) == NULL) {
goto loser;
}
setWorkingDir(newWorkingDir);
if (launch_psm(executable) != CMTSuccess) {
goto loser;
}
setWorkingDir(oldWorkingDir);
#endif
/*
* Now try to connect to the psm server. We will try to connect
* a maximum of 30 times and then give up.
*/
#ifdef WIN32
for (i=0; i<30; i++) {
Sleep(1000);
control = CMT_ControlConnect(mutex, sockFuncs);
if (control != NULL) {
break;
}
}
#elif defined XP_UNIX
i = 0;
while (i<1000) {
i += sleep(10);
control = CMT_ControlConnect(mutex, sockFuncs);
if (control != NULL) {
break;
}
}
#elif defined(XP_MAC)
for (i=0; i<30; i++)
{
EventRecord theEvent;
WaitNextEvent(0, &theEvent, 30, NULL);
control = CMT_ControlConnect(mutex, sockFuncs);
if (control != NULL)
break;
}
#else
/*
* Figure out how to sleep for a while first
*/
for (i=0; i<30; i++) {
control = CMT_ControlConnect(mutex, sockFuncs);
if (control!= NULL) {
break;
}
}
#endif
if (control == NULL) {
goto loser;
}
if (path) {
free (path);
}
return control;
loser:
if (control != NULL) {
CMT_CloseControlConnection(control);
}
if (path) {
free(path);
}
return NULL;
}
PCMT_CONTROL CMT_ControlConnect(CMT_MUTEX *mutex, CMT_SocketFuncs *sockFuncs)
{
PCMT_CONTROL control = NULL;
CMTSocket sock=NULL;
#ifdef XP_UNIX
int unixSock = 1;
char path[20];
#else
int unixSock = 0;
char *path=NULL;
#endif
if (sockFuncs == NULL) {
return NULL;
}
#ifdef XP_UNIX
sprintf(path, "/tmp/.nsmc-%d", (int)geteuid());
#endif
sock = sockFuncs->socket(unixSock);
if (sock == NULL) {
LOG("Could not create a socket to connect to Control Connection.\n");
goto loser;
}
/* Connect to the psm process */
if (sockFuncs->connect(sock, CARTMAN_PORT, path)) {
LOG("Could not connect to Cartman\n");
goto loser;
}
#ifdef XP_UNIX
if (sockFuncs->verify(sock) != CMTSuccess) {
goto loser;
}
#endif
LOG("Connected to Cartman\n");
/* fill in the CMTControl struct */
control = (PCMT_CONTROL)calloc(sizeof(CMT_CONTROL), 1);
if (control == NULL ) {
goto loser;
}
control->sock = sock;
if (mutex != NULL) {
control->mutex = (CMT_MUTEX*)calloc(sizeof(CMT_MUTEX),1);
if (control->mutex == NULL) {
goto loser;
}
*control->mutex = *mutex;
}
memcpy(&control->sockFuncs, sockFuncs, sizeof(CMT_SocketFuncs));
control->refCount = 1;
goto done;
loser:
if (control != NULL) {
free(control);
}
if (sock != NULL) {
sockFuncs->close(sock);
}
control = NULL;
done:
return control;
}
CMTStatus CMT_CloseControlConnection(PCMT_CONTROL control)
{
/* XXX Don't know what to do here yet */
if (control != NULL) {
CMInt32 refCount;
CMT_LOCK(control->mutex);
control->refCount--;
refCount = control->refCount;
CMT_UNLOCK(control->mutex);
if (refCount <= 0) {
if (control->mutex != NULL) {
free (control->mutex);
}
control->sockFuncs.close(control->sock);
free(control);
}
}
return CMTSuccess;
}
CMTStatus CMT_Hello(PCMT_CONTROL control, CMUint32 version, char* profile,
char* profileDir)
{
CMTItem message;
PCMT_EVENT eventHandler;
CMBool doesUI;
HelloRequest request;
HelloReply reply;
/* Check the passed parameters */
if (!control) {
return CMTFailure;
}
if (!profile) {
return CMTFailure;
}
if (!profileDir) {
return CMTFailure;
}
/* Create the hello message */
eventHandler = CMT_GetEventHandler(control, SSM_UI_EVENT, 0);
doesUI = (eventHandler == NULL) ? CM_FALSE : CM_TRUE;
/* Setup the request struct */
request.version = version;
request.policy = 0; /* no more policy */
request.doesUI = doesUI;
request.profile = profile;
request.profileDir = profileDir;
message.type = SSM_REQUEST_MESSAGE | SSM_HELLO_MESSAGE;
if (CMT_EncodeMessage(HelloRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Send the message and get the response */
if (CMT_SendMessage(control, &message) != CMTSuccess) {
goto loser;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_HELLO_MESSAGE)) {
goto loser;
}
/* Decode the message */
if (CMT_DecodeMessage(HelloReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Successful response */
if (reply.result == 0) {
/* Save the nonce value */
control->sessionID = reply.sessionID;
control->protocolVersion = reply.version;
control->port = reply.httpPort;
control->nonce = reply.nonce;
control->policy = reply.policy;
control->serverStringVersion = reply.stringVersion;
/* XXX Free the messages */
return CMTSuccess;
}
loser:
/* XXX Free the messages */
return CMTFailure;
}
CMTStatus CMT_PassAllPrefs(PCMT_CONTROL control, int num,
CMTSetPrefElement* list)
{
SetPrefListMessage request;
SingleNumMessage reply;
CMTItem message;
if ((control == NULL) || (list == NULL)) {
return CMTFailure;
}
/* pack the request */
request.length = num;
request.list = (SetPrefElement*)list;
if (CMT_EncodeMessage(SetPrefListMessageTemplate, &message, &request) !=
CMTSuccess) {
goto loser;
}
message.type = SSM_REQUEST_MESSAGE | SSM_PREF_ACTION;
/* send the message */
if (CMT_SendMessage(control, &message) != CMTSuccess) {
goto loser;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_PREF_ACTION)) {
goto loser;
}
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) !=
CMTSuccess) {
goto loser;
}
/* don't really need to check the return value */
return CMTSuccess;
loser:
return CMTFailure;
}
char* CMT_GetServerStringVersion(PCMT_CONTROL control)
{
if (control == NULL) {
return NULL;
}
return control->serverStringVersion;
}

View File

@@ -1,556 +0,0 @@
/*
* 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.
*/
#include "cmtutils.h"
#include "cmtjs.h"
#include "messages.h"
CMTStatus
CMT_GenerateKeyPair(PCMT_CONTROL control, CMUint32 keyGenContext,
CMUint32 mechType, CMTItem *param, CMUint32 keySize,
CMUint32 *keyPairId)
{
CMTItem message;
CMTStatus rv;
KeyPairGenRequest request = {0, 0, 0, {0, NULL, 0}};
SingleNumMessage reply;
if (!control) {
return CMTFailure;
}
request.keyGenCtxtID = keyGenContext;
request.genMechanism = mechType;
if (param) {
request.params = *param;
}
request.keySize = keySize;
/* Encode the message */
if (CMT_EncodeMessage(KeyPairGenRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
message.type = SSM_REQUEST_MESSAGE | SSM_PKCS11_ACTION | SSM_CREATE_KEY_PAIR;
/* Send the message and get the response */
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_PKCS11_ACTION | SSM_CREATE_KEY_PAIR)) {
goto loser;
}
/* Decode the message */
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*keyPairId = reply.value;
return CMTSuccess;
loser:
*keyPairId = 0;
return CMTFailure;
}
CMTStatus
CMT_CreateNewCRMFRequest(PCMT_CONTROL control, CMUint32 keyPairID,
SSMKeyGenType keyGenType, CMUint32 *reqID)
{
CMTItem message;
CMTStatus rv;
SingleNumMessage request;
SingleNumMessage reply;
if (!control) {
return CMTFailure;
}
request.value = keyPairID;
if (CMT_EncodeMessage(SingleNumMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
message.type = SSM_REQUEST_MESSAGE | SSM_CRMF_ACTION |
SSM_CREATE_CRMF_REQ;
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_CRMF_ACTION | SSM_CREATE_CRMF_REQ)) {
goto loser;
}
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*reqID = reply.value;
rv = CMT_SetNumericAttribute(control, *reqID, SSM_FID_CRMFREQ_KEY_TYPE,
keyGenType);
if (rv != CMTSuccess) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus
CMT_EncodeCRMFRequest(PCMT_CONTROL control, CMUint32 *crmfReqID,
CMUint32 numRequests, char ** der)
{
CMTItem message;
CMTStatus rv;
EncodeCRMFReqRequest request;
SingleItemMessage reply;
if (!control) {
return CMTFailure;
}
request.numRequests = numRequests;
request.reqIDs = (long *) crmfReqID;
/* Encode the request */
if (CMT_EncodeMessage(EncodeCRMFReqRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
message.type = SSM_REQUEST_MESSAGE | SSM_CRMF_ACTION | SSM_DER_ENCODE_REQ;
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_CRMF_ACTION | SSM_DER_ENCODE_REQ)) {
goto loser;
}
/* XXX Should this be a string? Decode the message */
if (CMT_DecodeMessage(SingleItemMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*der = (char *) reply.item.data;
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus
CMT_ProcessCMMFResponse(PCMT_CONTROL control, char *nickname,
char *certRepString, CMBool doBackup,
void *clientContext)
{
CMTItem message;
CMTStatus rv;
CMMFCertResponseRequest request;
if(!control) {
return CMTFailure;
}
request.nickname = nickname;
request.base64Der = certRepString;
request.doBackup = doBackup;
request.clientContext = CMT_CopyPtrToItem(clientContext);
/* Encode the request */
if (CMT_EncodeMessage(CMMFCertResponseRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
message.type = SSM_REQUEST_MESSAGE | SSM_CRMF_ACTION | SSM_PROCESS_CMMF_RESP;
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_CRMF_ACTION | SSM_PROCESS_CMMF_RESP)) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus
CMT_CreateResource(PCMT_CONTROL control, SSMResourceType resType,
CMTItem *params, CMUint32 *rsrcId, CMUint32 *errorCode)
{
CMTItem message;
CMTStatus rv;
CreateResourceRequest request = {0, {0, NULL, 0}};
CreateResourceReply reply;
request.type = resType;
if (params) {
request.params = *params;
}
/* Encode the request */
if (CMT_EncodeMessage(CreateResourceRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_CREATE_RESOURCE;
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION | SSM_CREATE_RESOURCE)) {
goto loser;
}
/* Decode the message */
if (CMT_DecodeMessage(CreateResourceReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*rsrcId = reply.resID;
*errorCode = reply.result;
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_SignText(PCMT_CONTROL control, CMUint32 resID, char* stringToSign, char* hostName, char* caOption, CMInt32 numCAs, char** caNames)
{
CMTItem message;
SignTextRequest request;
/* So some basic parameter checking */
if (!control || !stringToSign) {
goto loser;
}
/* Set up the request */
request.resID = resID;
request.stringToSign = stringToSign;
request.hostName = hostName;
request.caOption = caOption;
request.numCAs = numCAs;
request.caNames = caNames;
/* Encode the message */
if (CMT_EncodeMessage(SignTextRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_FORMSIGN_ACTION | SSM_SIGN_TEXT;
/* Send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_FORMSIGN_ACTION | SSM_SIGN_TEXT)) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus
CMT_ProcessChallengeResponse(PCMT_CONTROL control, char *challengeString,
char **responseString)
{
CMTItem message;
CMTStatus rv;
SingleStringMessage request;
SingleStringMessage reply;
/* Set the request */
request.string = challengeString;
/* Encode the request */
if (CMT_EncodeMessage(SingleStringMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_CRMF_ACTION | SSM_CHALLENGE;
/* Send the message */
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_CRMF_ACTION | SSM_CHALLENGE)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(SingleStringMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*responseString = reply.string;
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus
CMT_FinishGeneratingKeys(PCMT_CONTROL control, CMUint32 keyGenContext)
{
CMTItem message;
CMTStatus rv;
SingleNumMessage request;
/* Set up the request */
request.value = keyGenContext;
/* Encode the request */
if (CMT_EncodeMessage(SingleNumMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_PKCS11_ACTION | SSM_FINISH_KEY_GEN;
/* Send the message */
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
/* Validate the reply */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_PKCS11_ACTION | SSM_FINISH_KEY_GEN)) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus
CMT_GetLocalizedString(PCMT_CONTROL control,
SSMLocalizedString whichString,
char **localizedString)
{
CMTItem message;
CMTStatus rv;
SingleNumMessage request;
GetLocalizedTextReply reply;
/* Set up the request */
request.value = whichString;
/* Encode the request */
if (CMT_EncodeMessage(SingleNumMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_LOCALIZED_TEXT;
/* Send the message */
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_LOCALIZED_TEXT)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(GetLocalizedTextReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
if (reply.whichString != whichString) {
goto loser;
}
*localizedString = reply.localizedString;
return CMTSuccess;
loser:
*localizedString = NULL;
return rv;
}
CMTStatus
CMT_AddNewModule(PCMT_CONTROL control,
char *moduleName,
char *libraryPath,
unsigned long pubMechFlags,
unsigned long pubCipherFlags)
{
CMTItem message;
CMTStatus rv;
AddNewSecurityModuleRequest request;
SingleNumMessage reply;
/* Set up the request */
request.moduleName = moduleName;
request.libraryPath = libraryPath;
request.pubMechFlags = pubMechFlags;
request.pubCipherFlags = pubCipherFlags;
/* Encode the request */
if (CMT_EncodeMessage(AddNewSecurityModuleRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_PKCS11_ACTION | SSM_ADD_NEW_MODULE;
/* Send the message */
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_PKCS11_ACTION | SSM_ADD_NEW_MODULE)) {
goto loser;
}
/* Decode the response */
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
return (CMTStatus) reply.value;
loser:
return CMTFailure;
}
CMTStatus
CMT_DeleteModule(PCMT_CONTROL control,
char *moduleName,
int *moduleType)
{
CMTItem message;
CMTStatus rv;
SingleStringMessage request;
SingleNumMessage reply;
/* Set up the request */
request.string = moduleName;
/* Encode the request */
if (CMT_EncodeMessage(SingleStringMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_PKCS11_ACTION | SSM_DEL_MODULE;
/* Send the message */
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_PKCS11_ACTION | SSM_DEL_MODULE)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*moduleType = reply.value;
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_LogoutAllTokens(PCMT_CONTROL control)
{
CMTItem message;
CMTStatus rv;
message.type = SSM_REQUEST_MESSAGE | SSM_PKCS11_ACTION | SSM_LOGOUT_ALL;
message.data = NULL;
message.len = 0;
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) {
return rv;
}
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_PKCS11_ACTION |
SSM_LOGOUT_ALL)) {
return CMTFailure;
}
return CMTSuccess;
}
CMTStatus CMT_GetSSLCapabilities(PCMT_CONTROL control, CMInt32 *capabilites)
{
SingleNumMessage reply;
CMTItem message;
CMTStatus rv;
message.type = (SSM_REQUEST_MESSAGE | SSM_PKCS11_ACTION |
SSM_ENABLED_CIPHERS);
message.data = NULL;
message.len = 0;
rv = CMT_SendMessage(control, &message);
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_PKCS11_ACTION |
SSM_ENABLED_CIPHERS)) {
goto loser;
}
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply,
&message) != CMTSuccess) {
goto loser;
}
*capabilites = reply.value;
return CMTSuccess;
loser:
return CMTFailure;
}

View File

@@ -1,555 +0,0 @@
/*
* 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 _CMTJS_H_
#define _CMTJS_H_
#include "cmtcmn.h"
#include "ssmdefs.h"
#include "rsrcids.h"
/*
* Define some constants.
*/
/*
* These defines are used in conjuction with the function
* CMT_AddNewModule.
*/
#define PUBLIC_MECH_RSA_FLAG 0x00000001ul
#define PUBLIC_MECH_DSA_FLAG 0x00000002ul
#define PUBLIC_MECH_RC2_FLAG 0x00000004ul
#define PUBLIC_MECH_RC4_FLAG 0x00000008ul
#define PUBLIC_MECH_DES_FLAG 0x00000010ul
#define PUBLIC_MECH_DH_FLAG 0x00000020ul
#define PUBLIC_MECH_FORTEZZA_FLAG 0x00000040ul
#define PUBLIC_MECH_RC5_FLAG 0x00000080ul
#define PUBLIC_MECH_SHA1_FLAG 0x00000100ul
#define PUBLIC_MECH_MD5_FLAG 0x00000200ul
#define PUBLIC_MECH_MD2_FLAG 0x00000400ul
#define PUBLIC_MECH_RANDOM_FLAG 0x08000000ul
#define PUBLIC_MECH_FRIENDLY_FLAG 0x10000000ul
#define PUBLIC_OWN_PW_DEFAULTS 0X20000000ul
#define PUBLIC_DISABLE_FLAG 0x40000000ul
/*
* This is the lone supported constant for the Cipher flag
* for CMT_AddNewModule
*/
#define PUBLIC_CIPHER_FORTEZZA_FLAG 0x00000001ul
CMT_BEGIN_EXTERN_C
/*
* FUNCTION: CMT_GenerateKeyPair
* -----------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* keyGenContext
* The Resource ID of a key gen context to use for creating the
* key pair.
* mechType
* A PKCS11 mechanism used to generate the key pair. Valid values are:
* CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000
* CKM_DSA_KEY_PAIR_GEN 0x00000010
* The definition of these values can be found at
* http://www.rsa.com/rsalabs/pubs/pkcs11.html
* The psm module currently supports v2.01 of PKCS11
* params
* This parameter will be used to pass parameters to the Key Pair
* generation process. Currently this feature is not supported, so
* pass in NULL for this parameter.
* keySize
* The size (in bits) of the key to generate.
* keyPairId
* A pointer to pre-allocated memory where the function can place
* the value of the resource ID of the key pair that gets created.
*
* NOTES:
* This function will send a message to the psm server requesting that
* a public/private key pair be generated. The key gen context will queue
* the request. You can send as many key gen requests as you want with a
* given key gen context. After sending all the key gen requests, the user
* must call CMT_FinishGeneratingKeys so that the key gen context actually
* generates the keys.
*
* RETURN:
* A return value of CMTSuccess indicates the request for key generation
* was queued successfully and the corresponding resource ID can be found
* at *keyPairId. Any other return value indicates an error and the value
* at *keyPairId should be ignored.
*/
CMTStatus
CMT_GenerateKeyPair(PCMT_CONTROL control, CMUint32 keyGenContext,
CMUint32 mechType, CMTItem *params, CMUint32 keySize,
CMUint32 *keyPairId);
/*
* FUNCTION: CMT_FinishGeneratingKeys
* ----------------------------------
* INPUTS
* control
* The Control Connection that has already established a connection
* with the psm server.
* keyGenContext
* The resource ID of the key gen context which should finish
* generating its key pairs.
* NOTES
* This function will send a message to the psm server notifying the key
* gen context with the resource ID of keyGenContext to finish generating
* all of the key gen requests it has queued up. After each key gen has
* finished, the psm server will send a SSM_TASK_COMPLETED_EVENT. So in order
* to detect when all of the key gens are done, the user should register
* an event handler. See comments for CMT_RegisterEventHandler for information
* on how to successfully register event handler callbacks. You must register
* the event handler with keyGenContext as the target resource ID for this
* to work correctly.
*
* RETURN:
* A return value of CMTSuccess indicates the key gen context has started to
* generate the key pairs in its queue. Any other return value indicates an
* error and the key pairs will not be generated.
*/
CMTStatus
CMT_FinishGeneratingKeys(PCMT_CONTROL control, CMUint32 keyGenContext);
/*
* FUNCTION: CMT_CreateNewCRMFRequest
* ----------------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* keyPairID
* The resource ID of the key pair that should be associated with
* the CRMF request created. At the time this function is called,
* key pair should have already been created.
* keyGenType
* An enumeration that explains how the key pair will be used.
* Look at the definition of SSMKeyGenType in ssmdefs.h for valid
* values and their affects on the request.
* reqID
* A pointer to a pre-allocatd chunk of memory where the library
* can place the resource ID of the new CRMF request.
* NOTES:
* This function sends a message to the psm server requesting that a new
* CRMF resource object be created. Each CRMF request must be associated with
* a public/private key pair, that is why the keyPairID parameter exists.
* The keyGenType parameter is used to initialize the request, eg set the
* correct keyUsage extension.
*
* Before encoding a CRMF request, the user will want to set the appropriate
* attributes to build up the request. The supported attributes are:
*
* Attribute Enumeration Attribute Type What value means
* --------------------- -------------- ----------------
* SSM_FID_CRMFREQ_REGTOKEN String The value to encode as
* the registration token
* value for the request.
*
* SSM_FID_CRMFREQ_AUTHENTICATOR String The value to encode as
* authenticator control
* in the request.
*
* SSM_FID_DN String The RFC1485 formatted
* DN to include in the
* CRMF request.
*
* For information on how to properly set the attribute of a resource, refer
* to the comments for the functions CMT_SetNumericAttribute and
* CMT_SetStringAttribute.
*
* RETURN:
* A return value of CMTSuccess indicates a new CRMF resource was created by
* the psm server and has the resource ID placed at *reqID. Any other return
* value indicates an error and the value at *reqID should be ignored.
*/
CMTStatus
CMT_CreateNewCRMFRequest(PCMT_CONTROL control, CMUint32 keyPairID,
SSMKeyGenType keyGenType, CMUint32 *reqID);
/*
* FUNCTION: CMT_EncodeCRMFRequest
* ------------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* crmfReqID
* An array of resource ID's for CRMF objects to be encoded.
* numRequests
* The length of the array crmfReqID that is passed in.
* der
* A pointer to a pre-allocated pointer for a char* where the library
* can place the final DER-encoding of the requests.
* NOTES
* This function will send a message to the psm server requesting that
* a number of CRMF requests be encoded into their appropriate DER
* representation. The DER that is sent back will be of the type
* CertReqMessages as define in the internet draft for CRMF. To look at the
* draft, visit the following URL:
* http://search.ietf.org/internet-drafts/internet-draft-ietf-pkix-crmf-01.txt
*
* RETURN:
* A return value of CMTSuccess indicates psm successfully encoded the requests
* and placed the base64 DER encoded request at *der. Any other return value
* indicates an error and the value at *der should be ignored.
*/
CMTStatus
CMT_EncodeCRMFRequest(PCMT_CONTROL control, CMUint32 *crmfReqID,
CMUint32 numRequests, char ** der);
/*
* FUNCTION: CMT_ProcessCMMFResponse
* ---------------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* nickname
* The nickname that should be associated with the certificate
* contained in the CMMF Response.
* certRepString
* This is the base 64 encoded CertRepContent that issues a certificate.
* The psm server will decode the base 64 data and then parse the
* CertRepContent.
* doBackup
* A boolean value indicating whether or not psm should initiate the
* process of backing up the newly issued certificate into a PKCS-12
* file.
* clientContext
* Client supplied data pointer that is returned to the client during
* a UI event.
* NOTES:
* This function takes a CertRepContent as defined in the CMMF internet draft
* (http://search.ietf.org/internet-drafts/draft-ietf-pkix-cmmf-02.txt) and
* imports the certificate into the user's database. The certificate will have
* the string value of nickanme as it's nickname when added to the database
* unless another certificate with that same Distinguished Name (DN) already
* exists in the database, in which case the nickname of the certificate that
* already exists will be used. If the value passed in for doBackup is
* non-zero, then the psm server will initiate the process of backing up the
* certificate(s) that were just imported.
*
* RETURN:
* A return value of CMTSuccess indicates the certificate(s) were successfully
* added to the database. Any other return value means the certificate(s) could
* not be successfully added to the database.
*/
CMTStatus
CMT_ProcessCMMFResponse(PCMT_CONTROL control, char *nickname,
char *certRepString, CMBool doBackup,
void *clientContext);
/*
* FUNCTION: CMT_CreateResource
* ----------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* resType
* The enumeration representing the resource type to create.
* params
* A resource dependent binary string that will be sent to the psm
* server. Each resource will expect a binary string it defines.
* rsrcId
* A pointer to a pre-allocated chunk of memory where the library
* can place the resource ID of the newly created resource.
* errorCode
* A pointer to a pre-allocated chunk of memory where the library
* can place the errorCode returned by the psm server after creating
* the resource.
* NOTES:
* This function sends a message to the psm server requesting that a new
* resource be created. The params parameter depends on the type of resource
* being created. Below is a table detailing the format of the params for
* a given resource type. Only the resource types listed below can be created
* by calling this function.
*
* Resource Type constant Value for params
* ------------------------------ ----------------
* SSM_RESTYPE_KEYGEN_CONTEXT NULL
* SSM_RESTYPE_SECADVISOR_CONTEXT NULL
* SSM_RESTYPE_SIGNTEXT NULL
*
* RETURN
* A return value of CMTSuccess means the psm server received the request and
* processed the create resource create. If the value at *errorCode is zero,
* then the value at *rsrcId is the resource ID of the newly created resource.
* Otherwise, creating the new resource failed and *errorCode contains the
* error code returned by the psm server. ???What are the return values and
* what do they mean. Any other return value indicates there was an error
* in the communication with the psm server and the values at *rsrcId and
* *errorCode should be ignored.
*/
CMTStatus
CMT_CreateResource(PCMT_CONTROL control, SSMResourceType resType,
CMTItem *params, CMUint32 *rsrcId, CMUint32 *errorCode);
/*
* FUNCTION: CMT_SignText
* ----------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* resID
* The resource ID of an SSMSignTextResource.
* stringToSign
* The string that the psm server should sign.
* hostName
* The host name of the site that is requesting a string to be
* signed. This is used for displaying the UI that tells the user
* a web site has requested the use sign some text.
* caOption
* If the value is "auto" then psm will select the certificate
* to use for signing automatically.
* If the value is "ask" then psm will display a list of
* certificates for signing.
* numCAs
* The number of CA names included in the array caNames passed in as
* the last parameter to this function.
* caNames
* An array of CA Names to use for filtering the user certs to use
* for signing the text.
* NOTES
* This function will sign the text passed via the parameter stringToSign.
* The function will also cause the psm server to send some UI notifying the
* user that a site has requested the user sign some text. The hostName
* parameter is used in the UI to inform the user which site is requesting
* the signed text. The caOption is used to determine if the psm server
* should automatically select which personal cert to use in signing the
* text. The caNames array is ussed to narrow down the field of personal
* certs to use when signing the text. In other words, only personal certs
* trusted by the CA's passed in will be used.
*
* RETURN
* If the function returns CMTSuccess, that indicates the psm server
* successfully signed the text. The signed text can be retrieved by
* calling CMT_GetStringResource and passing in SSM_FID_SIGNTEXT_RESULT
* as the field ID. Any other return value indicates an error meaning the
* string was not signed successfully.
*/
CMTStatus
CMT_SignText(PCMT_CONTROL control, CMUint32 resID, char* stringToSign,
char* hostName, char *caOption, CMInt32 numCAs, char** caNames);
/*
* FUNCTION: CMT_ProcessChallengeResponse
* --------------------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* challengeString
* The base64 encoded Challenge string received as the
* Proof-Of-Possession Challenge in response to CRMF request that
* specified Challenge-Reponse as the method for Proof-Of-Possession.
* responseString
* A pointer to pre-allocated char* where the library can place a
* copy of the bas64 encoded response to the challenge presented.
* NOTES
* This function takes the a challenge--that is encrypted with the public key
* of a certificate we created--and decrypts it with the private key we
* generated. The format of the challenge is as follows:
*
* Challenge ::= SEQUENCE {
* owf AlgorithmIdentifier OPTIONAL,
* -- MUST be present in the first Challenge; MAY be omitted in any
* -- subsequent Challenge in POPODecKeyChallContent (if omitted,
* -- then the owf used in the immediately preceding Challenge is
* -- to be used).
* witness OCTET STRING,
* -- the result of applying the one-way function (owf) to a
* -- randomly-generated INTEGER, A. [Note that a different
* -- INTEGER MUST be used for each Challenge.]
* sender GeneralName,
* -- the name of the sender.
* key OCTET STRING,
* -- the public key used to encrypt the challenge. This will allow
* -- the client to find the appropriate key to do the decryption.
* challenge OCTET STRING
* -- the encryption (under the public key for which the cert.
* -- request is being made) of Rand, where Rand is specified as
* -- Rand ::= SEQUENCE {
* -- int INTEGER,
* -- - the randomly-generated INTEGER A (above)
* -- senderHash OCTET STRING
* -- - the result of applying the one-way function (owf) to
* -- - the sender's general name
* -- }
* -- the size of "int" must be small enough such that "Rand" can be
* -- contained within a single PKCS #1 encryption block.
* }
* This challenge is based on the Challenge initially defined in the CMMF
* internet draft, but differs in that this structure includes the sender
* as part of the challenge along with the public key and includes a has
* of the sender in the encrypted Rand structure. The reason for including
* the key is to facilitate looking up the key that should be used to
* decipher the challenge. Including the hash of the sender in the encrypted
* Rand structure makes the challenge smaller and allows it to fit in
* one RSA block.
*
* The response is of the type POPODecKeyRespContent as defined in the CMMF
* internet draft.
*
* RETURN
* A return value of CMTSuccess indicates psm successfully parsed and processed
* the challenge and created a response. The base64 encoded response to the
* challenge is placed at *responseString. Any other return value indicates
* an error and the value at *responseString should be ignored.
*/
CMTStatus
CMT_ProcessChallengeResponse(PCMT_CONTROL control, char *challengeString,
char **responseString);
/*
* FUNCTION: CMT_GetLocalizedString
* --------------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* whichString
* The enumerated value corresponding to the localized string to
* retrieve from the psm server
* localizedString
* A pointer to a pre-allocated char* where the library can place
* copy of the localized string retrieved from the psm server.
* NOTES
* This function retrieves a localized string from the psm server. These
* strings are useful for strings that aren't localized in the client
* making use of the psm server, but need to be displayed by the user. Look
* in protocol.h for the enumerations of the localized strings that can
* be fetched from psm via this method.
*
* RETURN
* A return value of CMTSuccess indicates the localized string was retrieved
* successfully and the localized value is located at *localizedString. Any
* other return value indicates an error and the value at *localizedString
* should be ignored.
*/
CMTStatus
CMT_GetLocalizedString(PCMT_CONTROL control,
SSMLocalizedString whichString,
char **localizedString);
/*
* FUNCTION: CMT_DeleteModule
* --------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* moduleName
* The name of the PKCS11 module to delete.
* moduleType
* A pointer to a pre-allocated integer where the library can place
* a value that tells what the type of module was deleted.
* NOTES
* This function will send a message to the psm server requesting the server
* delete a PKCS-11 module stored in psm's security module database. moduleName
* is the value passed in as moduleName when the module was added to the
* security module database of psm.
* The values that may be returned by psm for moduleType are:
*
* 0 The module was an external module developped by a third party
* that was added to the psm security module.
*
* 1 The module deleted was the internal PKCS-11 module that comes
* built in with the psm server.
*
* 2 The module that was deleted was the FIPS internal module.
*
* RETURN
* A return value of CMTSuccess indicates the security module was successfully
* delete from the psm security module database and the value at *moduleType
* will tell what type of module was deleted.
* Any other return value indicates an error and the value at *moduleType
* should be ignored.
*/
CMTStatus
CMT_DeleteModule(PCMT_CONTROL control,
char *moduleName,
int *moduleType);
/*
* FUNCTION: CMT_AddNewModule
* --------------------------
* INPUTS:
* control
* The Control Connection that has already established a connection
* with the psm server.
* moduleName
* The name to be associated with the module once it is added to
* the psm security module database.
* libraryPath
* The path to the library to be loaded. The library should be
* loadable at run-time.
* pubMechFlags
* A bit vector indicating all cryptographic mechanisms that should
* be turned on by default. This module will become the default
* handler for the mechanisms that are set by this bit vector.
* pubCipherFlags
* A bit vector indicating all SSL or S/MIME cipher functions
* supported by the module. Most modules will pas in 0x0 for this
* parameter.
* NOTES:
* This function sends a message to the psm server and requests the .so
* file on UNIX or .dll file on Windows be loaded as a PKCS11 module and
* be stored in the psm security module database. The module will be stored
* with the name moduleName that is passed in and will always expect the
* library to live at the path passed in via the parameter libraryPath.
* The pubMechFlags tell the psm server how this module should be used.
* Valid values are the #define constants defined at the beginning of
* this file.
*
* RETURN
* A return value of CMTSuccess indicates the module was successfully loaded
* and placed in the security module database of psm. Any other return value
* indicates an error and means the module was not loaded successfully and
* not stored in the psm server's security module database.
*/
CMTStatus
CMT_AddNewModule(PCMT_CONTROL control,
char *moduleName,
char *libraryPath,
unsigned long pubMechFlags,
unsigned long pubCipherFlags);
CMT_END_EXTERN_C
#endif /*_CMTJS_H_*/

View File

@@ -1,75 +0,0 @@
/* -*- 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.
*/
#include "cmtmac.h"
#include "macsocket.h"
#include "stdlib.h"
#ifndef XP_MAC
#error Link with the builtin strdup() on your platform.
#endif
static void
my_strcpy(char *dest, const char *source)
{
char *i = dest;
const char *j = source;
while(*j)
*i++ = *j++;
*i = '\0';
}
static int
my_strlen(const char *str)
{
const char *c = str;
int i = 0;
while(*c++ != '\0')
i++;
return i;
}
char * strdup(const char *oldstr)
{
/* used to keep the mac client library from referring to strdup elsewhere */
char *newstr;
newstr = (char *) malloc(my_strlen(oldstr)+1);
if (newstr)
my_strcpy(newstr, oldstr);
return newstr;
}

View File

@@ -1,40 +0,0 @@
/* -*- 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.
*/
#ifndef __CMTMAC_H__
#define __CMTMAC_H__
char * strdup(const char *str);
#endif

View File

@@ -1,119 +0,0 @@
/*
* 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.
*/
/************************************************************************
* Code to handle password requests from the the PSM module.
*
************************************************************************
*/
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
void CMT_SetAppFreeCallback(PCMT_CONTROL control,
applicationFreeCallback_fn f)
{
control->userFuncs.userFree = f;
}
void CMT_ServicePasswordRequest(PCMT_CONTROL cm_control, CMTItem * requestData)
{
CMTItem response = {0, NULL, 0};
PasswordRequest request;
PasswordReply reply;
void * clientContext;
/********************************************
* What we trying to do here:
* 1) Throw up a dialog box and request a password.
* 2) Create a message and send it to the PSM module.
********************************************
*/
/* Decode the request */
if (CMT_DecodeMessage(PasswordRequestTemplate, &request, requestData) != CMTSuccess) {
goto loser;
}
/* Copy the client context to a pointer */
clientContext = CMT_CopyItemToPtr(request.clientContext);
if (cm_control->userFuncs.promptCallback == NULL) {
goto loser;
}
reply.passwd =
cm_control->userFuncs.promptCallback(cm_control->userFuncs.promptArg,
request.prompt, clientContext, 1);
reply.tokenID = request.tokenKey;
if (!reply.passwd) {
/* the user cancelled the prompt or other errors occurred */
reply.result = -1;
}
else {
/* note that this includes an empty string (zero length password) */
reply.result = 0;
}
/* Encode the reply */
if (CMT_EncodeMessage(PasswordReplyTemplate, &response, &reply) != CMTSuccess) {
goto loser;
}
/* Set the message response type */
response.type = SSM_EVENT_MESSAGE | SSM_AUTH_EVENT;
CMT_TransmitMessage(cm_control, &response);
goto done;
loser:
/* something has gone wrong */
done:
/*clean up anyway */
/* We can't just free up memory allocated by the host
application because the versions of free may not match up.
When you run the plug-in with an optimized older browser,
you'll see tons of Asserts (why they still have asserts in an
optimized build is a different question, but without them
I wouldn't have figured out this problem) about a pointer not
being a valid heap pointer and eventually crash. This was
the offending free line.
So we need to call a function within the browser that
calls the free linked in with it. js_free is
such a function. But this is extremely ugly.
*/
if (reply.passwd)
cm_control->userFuncs.userFree(reply.passwd);
if (request.prompt)
free(request.prompt);
return;
}

View File

@@ -1,636 +0,0 @@
/* -*- 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.
*/
#ifdef XP_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/time.h>
#else
#ifdef XP_MAC
#include "macsocket.h"
#else /* Windows */
#include <windows.h>
#include <winsock.h>
#endif
#endif
#include <errno.h>
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
#include "rsrcids.h"
typedef struct _CMTP7Private {
CMTPrivate priv;
CMTP7ContentCallback cb;
void *cb_arg;
} CMTP7Private;
CMTStatus CMT_PKCS7DecoderStart(PCMT_CONTROL control, void* clientContext, CMUint32 * connectionID, CMInt32 * result,
CMTP7ContentCallback cb, void *cb_arg)
{
CMTItem message;
CMTStatus rv;
CMTP7Private *priv=NULL;
SingleItemMessage request;
DataConnectionReply reply;
/* Check passed in parameters */
if (!control) {
goto loser;
}
request.item = CMT_CopyPtrToItem(clientContext);
/* Encode message */
if (CMT_EncodeMessage(SingleItemMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_DATA_CONNECTION | SSM_PKCS7DECODE_STREAM;
/* Send the message. */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_DATA_CONNECTION | SSM_PKCS7DECODE_STREAM)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(DataConnectionReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
CMTSocket sock;
priv = (CMTP7Private *)malloc(sizeof(CMTP7Private));
if (priv == NULL)
goto loser;
priv->priv.dest = (CMTReclaimFunc) free;
priv->cb = cb;
priv->cb_arg = cb_arg;
sock = control->sockFuncs.socket(0);
if (sock == NULL) {
goto loser;
}
if (control->sockFuncs.connect(sock, (short)reply.port,
NULL) != CMTSuccess) {
goto loser;
}
if (control->sockFuncs.send(sock, control->nonce.data,
control->nonce.len) != control->nonce.len){
goto loser;
}
/* Save connection info */
if (CMT_AddDataConnection(control, sock, reply.connID)
!= CMTSuccess) {
goto loser;
}
*connectionID = reply.connID;
rv = CMT_SetPrivate(control, reply.connID, &priv->priv);
if (rv != CMTSuccess)
goto loser;
return CMTSuccess;
}
loser:
if (priv) {
free(priv);
}
*result = reply.result;
return CMTFailure;
}
CMTStatus CMT_PKCS7DecoderUpdate(PCMT_CONTROL control, CMUint32 connectionID, const char * buf, CMUint32 len)
{
CMUint32 sent;
CMTP7Private *priv;
unsigned long nbytes;
char read_buf[128];
CMTSocket sock, ctrlsock, selSock, sockArr[2];
/* Do some parameter checking */
if (!control || !buf) {
goto loser;
}
/* Get the data socket */
if (CMT_GetDataSocket(control, connectionID, &sock) == CMTFailure) {
goto loser;
}
priv = (CMTP7Private *)CMT_GetPrivate(control, connectionID);
if (priv == NULL)
goto loser;
/* Write the data to the socket */
sent = CMT_WriteThisMany(control, sock, (void*)buf, len);
if (sent != len) {
goto loser;
}
ctrlsock = control->sock;
sockArr[0] = ctrlsock;
sockArr[1] = sock;
while ((selSock = control->sockFuncs.select(sockArr,2,1)))
{
if (selSock == ctrlsock) {
CMT_ProcessEvent(control);
} else {
nbytes = control->sockFuncs.recv(sock, read_buf, sizeof(read_buf));
if (nbytes == -1) {
goto loser;
}
if (nbytes == 0) {
break;
}
priv->cb(priv->cb_arg, read_buf, nbytes);
}
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_PKCS7DecoderFinish(PCMT_CONTROL control, CMUint32 connectionID,
CMUint32 * resourceID)
{
CMTP7Private *priv;
long nbytes;
char buf[128];
CMTSocket sock, ctrlsock, selSock, sockArr[2];
/* Do some parameter checking */
if (!control) {
goto loser;
}
priv = (CMTP7Private *)CMT_GetPrivate(control, connectionID);
if (priv == NULL)
goto loser;
if (CMT_GetDataSocket(control, connectionID, &sock) == CMTFailure) {
goto loser;
}
ctrlsock = control->sock;
/* drain socket before we close it */
control->sockFuncs.shutdown(sock);
sockArr[0] = sock;
sockArr[1] = ctrlsock;
/* Let's see if doing a poll first gets rid of a weird bug where we
* lock up the client.
*/
#ifndef XP_MAC
if (control->sockFuncs.select(sockArr,2,1) != NULL)
#endif
{
while (1) {
selSock = control->sockFuncs.select(sockArr,2,0);
if (selSock == ctrlsock) {
CMT_ProcessEvent(control);
} else if (selSock == sock) {
nbytes = control->sockFuncs.recv(sock, buf, sizeof(buf));
if (nbytes < 0) {
goto loser;
} else if (nbytes == 0) {
break;
}
priv->cb(priv->cb_arg, buf, nbytes);
}
}
}
if (CMT_CloseDataConnection(control, connectionID) == CMTFailure) {
goto loser;
}
/* Get the PKCS7 content info */
if (CMT_GetRIDAttribute(control, connectionID, SSM_FID_P7CONN_CONTENT_INFO,
resourceID) == CMTFailure) {
goto loser;
}
return CMTSuccess;
loser:
if (control) {
CMT_CloseDataConnection(control, connectionID);
}
return CMTFailure;
}
CMTStatus CMT_PKCS7DestroyContentInfo(PCMT_CONTROL control, CMUint32 resourceID)
{
if (!control) {
goto loser;
}
/* Delete the resource */
if (CMT_DestroyResource(control, resourceID, SSM_FID_P7CONN_CONTENT_INFO) == CMTFailure) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_PKCS7VerifyDetachedSignature(PCMT_CONTROL control, CMUint32 resourceID, CMUint32 certUsage, CMUint32 hashAlgID, CMUint32 keepCerts, CMTItem* digest, CMInt32 * result)
{
CMTItem message;
VerifyDetachedSigRequest request;
SingleNumMessage reply;
/* Do some parameter checking */
if (!control || !digest || !result) {
goto loser;
}
/* Set the request */
request.pkcs7ContentID = resourceID;
request.certUsage = certUsage;
request.hashAlgID = hashAlgID;
request.keepCert = (CMBool) keepCerts;
request.hash = *digest;
/* Encode the request */
if (CMT_EncodeMessage(VerifyDetachedSigRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_OBJECT_SIGNING | SSM_VERIFY_DETACHED_SIG;
/* Send the message */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_OBJECT_SIGNING |SSM_VERIFY_DETACHED_SIG)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*result = reply.value;
return CMTSuccess;
loser:
*result = reply.value;
return CMTFailure;
}
CMTStatus CMT_PKCS7VerifySignature(PCMT_CONTROL control, CMUint32 pubKeyAlgID,
CMTItem *pubKeyParams, CMTItem *signerPubKey,
CMTItem *computedHash, CMTItem *signature,
CMInt32 *result)
{
return CMTFailure;
}
CMTStatus CMT_CreateSigned(PCMT_CONTROL control, CMUint32 scertRID,
CMUint32 ecertRID, CMUint32 dig_alg,
CMTItem *digest, CMUint32 *ciRID, CMInt32 *errCode)
{
CMTItem message;
CreateSignedRequest request;
CreateContentInfoReply reply;
/* Do some parameter checking */
if (!control || !scertRID || !ecertRID || !digest || !ciRID) {
goto loser;
}
/* Set the request */
request.scertRID = scertRID;
request.ecertRID = ecertRID;
request.dig_alg = dig_alg;
request.digest = *digest;
/* Encode the request */
if (CMT_EncodeMessage(CreateSignedRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_OBJECT_SIGNING | SSM_CREATE_SIGNED;
/* Send the message */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_OBJECT_SIGNING | SSM_CREATE_SIGNED)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(CreateContentInfoReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*ciRID = reply.ciRID;
if (reply.result == 0) {
return CMTSuccess;
}
loser:
if (CMT_DecodeMessage(CreateContentInfoReplyTemplate, &reply, &message) == CMTSuccess) {
*errCode = reply.errorCode;
} else {
*errCode = 0;
}
return CMTFailure;
}
CMTStatus CMT_CreateEncrypted(PCMT_CONTROL control, CMUint32 scertRID,
CMUint32 *rcertRIDs, CMUint32 *ciRID)
{
CMTItem message;
CMInt32 nrcerts;
CreateEncryptedRequest request;
CreateContentInfoReply reply;
/* Do some parameter checking */
if (!control || !scertRID || !rcertRIDs || !ciRID) {
goto loser;
}
/* Calculate the number of certs */
for (nrcerts =0; rcertRIDs[nrcerts] != 0; nrcerts++) {
/* Nothing */
;
}
/* Set up the request */
request.scertRID = scertRID;
request.nrcerts = nrcerts;
request.rcertRIDs = (long *) rcertRIDs;
/* Encode the request */
if (CMT_EncodeMessage(CreateEncryptedRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_OBJECT_SIGNING | SSM_CREATE_ENCRYPTED;
/* Send the message */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message response type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_OBJECT_SIGNING | SSM_CREATE_ENCRYPTED)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(CreateContentInfoReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*ciRID = reply.ciRID;
if (reply.result == 0) {
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_PKCS7EncoderStart(PCMT_CONTROL control, CMUint32 ciRID,
CMUint32 *connectionID, CMTP7ContentCallback cb,
void *cb_arg)
{
CMTItem message;
CMTStatus rv;
CMTP7Private *priv;
PKCS7DataConnectionRequest request;
DataConnectionReply reply;
/* Check passed in parameters */
if (!control || !ciRID) {
goto loser;
}
/* Set up the request */
request.resID = ciRID;
request.clientContext.len = 0;
request.clientContext.data = NULL;
/* Encode the request */
if (CMT_EncodeMessage(PKCS7DataConnectionRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_DATA_CONNECTION | SSM_PKCS7ENCODE_STREAM;
/* Send the message */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_DATA_CONNECTION | SSM_PKCS7ENCODE_STREAM)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(DataConnectionReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
CMTSocket sock;
priv = (CMTP7Private *)malloc(sizeof(CMTP7Private));
if (priv == NULL)
goto loser;
priv->priv.dest = (CMTReclaimFunc) free;
priv->cb = cb;
priv->cb_arg = cb_arg;
sock = control->sockFuncs.socket(0);
if (sock == NULL) {
goto loser;
}
if (control->sockFuncs.connect(sock, (short)reply.port,
NULL) != CMTSuccess) {
goto loser;
}
if (control->sockFuncs.send(sock, control->nonce.data,
control->nonce.len) != control->nonce.len) {
goto loser;
}
/* Save connection info */
if (CMT_AddDataConnection(control, sock, reply.connID)
!= CMTSuccess) {
goto loser;
}
*connectionID = reply.connID;
rv = CMT_SetPrivate(control, reply.connID, &priv->priv);
if (rv != CMTSuccess)
goto loser;
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_PKCS7EncoderUpdate(PCMT_CONTROL control, CMUint32 connectionID,
const char *buf, CMUint32 len)
{
CMUint32 sent;
CMTP7Private *priv;
unsigned long nbytes;
char read_buf[128];
CMTSocket sock, ctrlsock, sockArr[2], selSock;
/* Do some parameter checking */
if (!control || !connectionID || !buf) {
goto loser;
}
/* Get the data socket */
if (CMT_GetDataSocket(control, connectionID, &sock) == CMTFailure) {
goto loser;
}
priv = (CMTP7Private *)CMT_GetPrivate(control, connectionID);
if (priv == NULL)
goto loser;
/* Write the data to the socket */
sent = CMT_WriteThisMany(control, sock, (void*)buf, len);
if (sent != len) {
goto loser;
}
ctrlsock = control->sock;
sockArr[0] = ctrlsock;
sockArr[1] = sock;
while ((selSock = control->sockFuncs.select(sockArr, 2, 1)) != NULL)
{
if (selSock == ctrlsock) {
CMT_ProcessEvent(control);
} else {
nbytes = control->sockFuncs.recv(sock, read_buf, sizeof(read_buf));
if (nbytes == -1) {
goto loser;
} else if (nbytes == 0) {
break;
} else {
priv->cb(priv->cb_arg, read_buf, nbytes);
}
}
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_PKCS7EncoderFinish(PCMT_CONTROL control, CMUint32 connectionID)
{
CMTP7Private *priv;
unsigned long nbytes;
char buf[128];
CMTSocket sock, ctrlsock, sockArr[2], selSock;
/* Do some parameter checking */
if (!control) {
goto loser;
}
priv = (CMTP7Private *)CMT_GetPrivate(control, connectionID);
if (priv == NULL)
goto loser;
if (CMT_GetDataSocket(control, connectionID, &sock) == CMTFailure) {
goto loser;
}
ctrlsock = control->sock;
sockArr[0] = ctrlsock;
sockArr[1] = sock;
control->sockFuncs.shutdown(sock);
while (1) {
selSock = control->sockFuncs.select(sockArr, 2, 0);
if (selSock == ctrlsock) {
CMT_ProcessEvent(control);
} else if (selSock == sock) {
nbytes = control->sockFuncs.recv(sock, buf, sizeof(buf));
if (nbytes < 0) {
goto loser;
} else if (nbytes == 0) {
break;
} else {
priv->cb(priv->cb_arg, buf, nbytes);
}
}
}
if (CMT_CloseDataConnection(control, connectionID) == CMTFailure) {
goto loser;
}
return CMTSuccess;
loser:
if (control) {
CMT_CloseDataConnection(control, connectionID);
}
return CMTFailure;
}

View File

@@ -1,479 +0,0 @@
/* -*- 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.
*/
#ifdef XP_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#else
#ifdef XP_MAC
#include "macsocket.h"
#else
#include <windows.h>
#include <winsock.h>
#endif
#endif
#include <errno.h>
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
#include <string.h>
CMTStatus CMT_GetNumericAttribute(PCMT_CONTROL control, CMUint32 resourceID, CMUint32 fieldID, CMInt32 *value)
{
CMTItem message;
GetAttribRequest request;
GetAttribReply reply;
/* Do some parameter checking */
if (!control) {
goto loser;
}
/* Set up the request */
request.resID = resourceID;
request.fieldID = fieldID;
/* Encode the request */
if (CMT_EncodeMessage(GetAttribRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_GET_ATTRIBUTE | SSM_NUMERIC_ATTRIBUTE;
/* Send the mesage and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION | SSM_GET_ATTRIBUTE | SSM_NUMERIC_ATTRIBUTE)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(GetAttribReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
*value = reply.value.u.numeric;
/* Success */
if (reply.result == 0) {
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_SetNumericAttribute(PCMT_CONTROL control, CMUint32 resourceID,
CMUint32 fieldID, CMInt32 value)
{
CMTItem message;
SetAttribRequest request;
if (!control) {
goto loser;
}
/* Set the request */
request.resID = resourceID;
request.fieldID = fieldID;
request.value.type = SSM_NUMERIC_ATTRIBUTE;
request.value.u.numeric = value;
/* Encode the message */
if (CMT_EncodeMessage(SetAttribRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION |
SSM_SET_ATTRIBUTE | SSM_NUMERIC_ATTRIBUTE;
if (CMT_SendMessage(control, &message) != CMTSuccess) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION |
SSM_SET_ATTRIBUTE | SSM_NUMERIC_ATTRIBUTE)) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus
CMT_PadStringValue(CMTItem *dest, CMTItem src)
{
dest->data = NewArray(unsigned char, src.len+1);
if (dest->data == NULL) {
return CMTFailure;
}
memcpy(dest->data, src.data, src.len);
dest->data[src.len] = '\0';
dest->len = src.len;
free(src.data);
return CMTSuccess;
}
CMTStatus CMT_GetStringAttribute(PCMT_CONTROL control, CMUint32 resourceID, CMUint32 fieldID, CMTItem *value)
{
CMTItem message;
GetAttribRequest request;
GetAttribReply reply;
/* Do some parameter checking */
if (!control) {
goto loser;
}
/* Set up the request */
request.resID = resourceID;
request.fieldID = fieldID;
/* Encode the request */
if (CMT_EncodeMessage(GetAttribRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_GET_ATTRIBUTE | SSM_STRING_ATTRIBUTE;
/* Send the mesage and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION | SSM_GET_ATTRIBUTE | SSM_STRING_ATTRIBUTE)) {
goto loser;
}
/* Decode the response */
if (CMT_DecodeMessage(GetAttribReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
return CMT_PadStringValue(value, reply.value.u.string);
}
loser:
return CMTFailure;
}
CMTStatus
CMT_SetStringAttribute(PCMT_CONTROL control, CMUint32 resourceID,
CMUint32 fieldID, CMTItem *value)
{
CMTItem message;
SetAttribRequest request;
if (!control) {
goto loser;
}
/* Set up the request */
request.resID = resourceID;
request.fieldID = fieldID;
request.value.type = SSM_STRING_ATTRIBUTE;
request.value.u.string = *value;
/* Encode the request */
if (CMT_EncodeMessage(SetAttribRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION |
SSM_SET_ATTRIBUTE | SSM_STRING_ATTRIBUTE;
/* Send the message */
if (CMT_SendMessage(control, &message) != CMTSuccess) {
goto loser;
}
/* Validate the message request type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION |
SSM_SET_ATTRIBUTE | SSM_STRING_ATTRIBUTE)) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_DuplicateResource(PCMT_CONTROL control, CMUint32 resourceID,
CMUint32 *newResID)
{
CMTItem message;
SingleNumMessage request;
DupResourceReply reply;
/* Do some parameter checking */
if (!control) {
goto loser;
}
/* Set up the request */
request.value = resourceID;
/* Encode the request */
if (CMT_EncodeMessage(SingleNumMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_DUPLICATE_RESOURCE;
/* Send the mesage */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION | SSM_DUPLICATE_RESOURCE)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(DupResourceReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
*newResID = reply.resID;
return CMTSuccess;
}
loser:
*newResID = 0;
return CMTFailure;
}
CMTStatus CMT_DestroyResource(PCMT_CONTROL control, CMUint32 resourceID, CMUint32 resourceType)
{
CMTItem message;
DestroyResourceRequest request;
SingleNumMessage reply;
/* Do some parameter checking */
if (!control) {
goto loser;
}
/* Set up the request */
request.resID = resourceID;
request.resType = resourceType;
/* Encode the message */
if (CMT_EncodeMessage(DestroyResourceRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_DESTROY_RESOURCE;
/* Send the message */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION | SSM_DESTROY_RESOURCE)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.value == 0) {
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_PickleResource(PCMT_CONTROL control, CMUint32 resourceID, CMTItem * pickledResource)
{
CMTItem message;
SingleNumMessage request;
PickleResourceReply reply;
/* Do some parameter checking */
if (!control) {
goto loser;
}
/* Set up the request */
request.value = resourceID;
/* Encode the request */
if (CMT_EncodeMessage(SingleNumMessageTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_CONSERVE_RESOURCE | SSM_PICKLE_RESOURCE;
/* Send the mesage and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION | SSM_CONSERVE_RESOURCE | SSM_PICKLE_RESOURCE)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(PickleResourceReplyTemplate, &reply,&message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
*pickledResource = reply.blob;
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_UnpickleResource(PCMT_CONTROL control, CMUint32 resourceType, CMTItem pickledResource, CMUint32 * resourceID)
{
CMTItem message;
UnpickleResourceRequest request;
UnpickleResourceReply reply;
/* Do some parameter checking */
if (!control) {
goto loser;
}
/* Set up the request */
request.resourceType = resourceType;
request.resourceData = pickledResource;
/* Encode the request */
if (CMT_EncodeMessage(UnpickleResourceRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_CONSERVE_RESOURCE | SSM_UNPICKLE_RESOURCE;
/* Send the mesage and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION | SSM_CONSERVE_RESOURCE | SSM_UNPICKLE_RESOURCE)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(UnpickleResourceReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
*resourceID = reply.resID;
return CMTSuccess;
}
loser:
*resourceID = 0;
return CMTFailure;
}
CMTStatus CMT_GetRIDAttribute(PCMT_CONTROL control, CMUint32 resourceID, CMUint32 fieldID, CMUint32 *value)
{
CMTItem message;
GetAttribRequest request;
GetAttribReply reply;
/* Do some parameter checking */
if (!control) {
goto loser;
}
/* Set the request */
request.resID = resourceID;
request.fieldID = fieldID;
/* Encode the message */
if (CMT_EncodeMessage(GetAttribRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_GET_ATTRIBUTE | SSM_RID_ATTRIBUTE;
/* Send the mesage and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message response type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION | SSM_GET_ATTRIBUTE | SSM_RID_ATTRIBUTE)) {
goto loser;
}
/* Decode the reply */
if (CMT_DecodeMessage(GetAttribReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
*value = reply.value.u.rid;
return CMTSuccess;
}
loser:
return CMTFailure;
}

View File

@@ -1,270 +0,0 @@
/*
* 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.
*/
/*
cmtrng.c -- Support for PSM random number generator and the seeding
thereof with data from the client.
Created by mwelch 1999 Oct 21
*/
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
#include "rsrcids.h"
#include <string.h>
CMTStatus
CMT_EnsureInitializedRNGBuf(PCMT_CONTROL control)
{
if (control->rng.outBuf == NULL)
{
control->rng.outBuf = (char *) calloc(RNG_OUT_BUFFER_LEN, sizeof(char));
if (control->rng.outBuf == NULL)
goto loser;
control->rng.validOutBytes = 0;
control->rng.out_cur = control->rng.outBuf;
control->rng.out_end = control->rng.out_cur + RNG_OUT_BUFFER_LEN;
control->rng.inBuf = (char *) calloc(RNG_IN_BUFFER_LEN, sizeof(char));
if (control->rng.outBuf == NULL)
goto loser;
}
return CMTSuccess;
loser:
if (control->rng.outBuf != NULL)
{
free(control->rng.outBuf);
control->rng.outBuf = NULL;
}
if (control->rng.inBuf != NULL)
{
free(control->rng.inBuf);
control->rng.inBuf = NULL;
}
return CMTFailure;
}
size_t
CMT_RequestPSMRandomData(PCMT_CONTROL control,
void *buf, CMUint32 maxbytes)
{
SingleNumMessage req;
SingleItemMessage reply;
CMTItem message;
size_t rv = 0;
/* Parameter checking */
if (!control || !buf || (maxbytes == 0))
goto loser;
/* Initialization. */
memset(&reply, 0, sizeof(SingleItemMessage));
/* Ask PSM for the data. */
req.value = maxbytes;
if (CMT_EncodeMessage(SingleNumMessageTemplate, &message, &req) != CMTSuccess)
goto loser;
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_MISC_ACTION | SSM_MISC_GET_RNG_DATA;
/* Send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure)
goto loser;
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_MISC_ACTION | SSM_MISC_GET_RNG_DATA))
goto loser;
/* Decode message */
if (CMT_DecodeMessage(SingleItemMessageTemplate, &reply, &message) != CMTSuccess)
goto loser;
/* Success - fill the return buf with what we got */
if (reply.item.len > maxbytes)
reply.item.len = maxbytes;
memcpy(buf, reply.item.data, reply.item.len);
rv = reply.item.len;
loser:
if (reply.item.data)
free(reply.item.data);
if (message.data)
free(message.data);
return rv;
}
size_t
CMT_GenerateRandomBytes(PCMT_CONTROL control,
void *buf, CMUint32 maxbytes)
{
CMUint32 remaining = maxbytes;
CMT_RNGState *rng = &(control->rng);
char *walk = (char *) buf;
/* Is there already enough in the incoming cache? */
while(remaining > rng->validInBytes)
{
/* Get what we have on hand. */
memcpy(walk, rng->in_cur, rng->validInBytes);
walk += rng->validInBytes;
remaining -= rng->validInBytes;
/* Request a buffer from PSM. */
rng->validInBytes = CMT_RequestPSMRandomData(control,
rng->inBuf,
RNG_IN_BUFFER_LEN);
if (rng->validInBytes == 0)
return (maxbytes - remaining); /* call failed */
rng->in_cur = rng->inBuf;
}
if (remaining > 0)
{
memcpy(walk, rng->in_cur, remaining);
rng->in_cur += remaining;
rng->validInBytes -= remaining;
}
return maxbytes;
}
void
cmt_rng_xor(void *dstBuf, void *srcBuf, int len)
{
unsigned char *s = (unsigned char*) srcBuf;
unsigned char *d = (unsigned char*) dstBuf;
unsigned char tmp;
int i;
for(i=0; i<len; i++, s++, d++)
{
tmp = *d;
/* I wish C had circular shift operators. So do others on the team. */
tmp = ((tmp << 1) | (tmp >> 7));
*d = tmp ^ *s;
}
}
CMTStatus
CMT_RandomUpdate(PCMT_CONTROL control, void *data, size_t numbytes)
{
size_t dataLeft = numbytes, cacheLeft;
char *walk = (char *) data;
if (CMT_EnsureInitializedRNGBuf(control) != CMTSuccess)
goto loser;
/* If we have more than what the buffer can handle, wrap around. */
cacheLeft = (control->rng.out_end - control->rng.out_cur);
while (dataLeft >= cacheLeft)
{
cmt_rng_xor(control->rng.out_cur, walk, cacheLeft);
walk += cacheLeft;
dataLeft -= cacheLeft;
control->rng.out_cur = control->rng.outBuf;
/* Max out used space */
control->rng.validOutBytes = cacheLeft = RNG_OUT_BUFFER_LEN;
}
/*
We now have less seed data available than we do space in the buf.
Write what we have and update validOutBytes if we're not looping already.
*/
cmt_rng_xor(control->rng.out_cur, walk, dataLeft);
control->rng.out_cur += dataLeft;
if (control->rng.validOutBytes < RNG_OUT_BUFFER_LEN)
control->rng.validOutBytes += dataLeft;
return CMTSuccess;
loser:
return CMTFailure;
}
size_t
CMT_GetNoise(PCMT_CONTROL control, void *buf, CMUint32 maxbytes)
{
/* ### mwelch - GetNoise and GenerateRandomBytes can be the
same function now, because presumably the RNG is being
seeded with environmental noise on the PSM end before we
make any of these requests */
return CMT_GenerateRandomBytes(control, buf, maxbytes);
}
CMTStatus
CMT_FlushPendingRandomData(PCMT_CONTROL control)
{
CMTItem message;
memset(&message, 0, sizeof(CMTItem));
if (CMT_EnsureInitializedRNGBuf(control) != CMTSuccess)
return CMTFailure; /* couldn't initialize RNG buffer */
if (control->rng.validOutBytes == 0)
return CMTSuccess; /* no random data available == we're flushed */
/* We have random data available. Send this to PSM.
We're sending an event, so no reply is needed. */
message.type = SSM_EVENT_MESSAGE
| SSM_MISC_ACTION
| SSM_MISC_PUT_RNG_DATA;
message.len = control->rng.validOutBytes;
message.data = (unsigned char *) calloc(message.len, sizeof(char));
if (!message.data)
goto loser;
memcpy(message.data, control->rng.outBuf, message.len);
if (CMT_TransmitMessage(control, &message) == CMTFailure)
goto loser;
/* Clear the RNG ring buffer, we've used that data */
control->rng.out_cur = control->rng.outBuf;
control->rng.validOutBytes = 0;
/* zero the buffer, because we XOR in new data */
memset(control->rng.outBuf, 0, RNG_OUT_BUFFER_LEN);
goto done;
loser:
if (message.data)
free(message.data);
return CMTFailure;
done:
return CMTSuccess;
}

View File

@@ -1,237 +0,0 @@
/*
* 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.
*/
/*
cmtsdr.c -- Support for the Secret Decoder Ring, which provides
encryption and decryption using stored keys.
Created by thayes 18 April 2000
*/
#include "stddef.h"
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
#include "protocolshr.h"
#include "rsrcids.h"
#include <string.h>
#undef PROCESS_LOCALLY
/* Encryption result - contains the key id and the resulting data */
/* An empty key id indicates that NO encryption was performed */
typedef struct EncryptionResult
{
CMTItem keyid;
CMTItem data;
} EncryptionResult;
/* Constants for testing */
static const char *kPrefix = "Encrypted:";
static CMTItem
CMT_CopyDataToItem(const unsigned char *data, CMUint32 len)
{
CMTItem item;
item.data = (unsigned char*) calloc(len, 1);
item.len = len;
memcpy(item.data, data, len);
return item;
}
static CMTStatus
tmp_SendMessage(PCMT_CONTROL control, CMTItem *message)
{
#ifndef PROCESS_LOCALLY
return CMT_SendMessage(control, message);
#else
if (message->type == SSM_SDR_ENCRYPT_REQUEST)
return CMT_DoEncryptionRequest(message);
else if (message->type == SSM_SDR_DECRYPT_REQUEST)
return CMT_DoDecryptionRequest(message);
return CMTFailure;
#endif
}
/* End test code */
CMTStatus
CMT_SDREncrypt(PCMT_CONTROL control, void *ctx,
const unsigned char *key, CMUint32 keyLen,
const unsigned char *data, CMUint32 dataLen,
unsigned char **result, CMUint32 *resultLen)
{
CMTStatus rv = CMTSuccess;
CMTItem message;
EncryptRequestMessage request;
SingleItemMessage reply;
/* Fill in the request */
request.keyid = CMT_CopyDataToItem(key, keyLen);
request.data = CMT_CopyDataToItem(data, dataLen);
request.ctx = CMT_CopyPtrToItem(ctx);
reply.item.data = 0;
reply.item.len = 0;
message.data = 0;
message.len = 0;
/* Encode */
rv = CMT_EncodeMessage(EncryptRequestTemplate, &message, &request);
if (rv != CMTSuccess) {
goto loser;
}
message.type = SSM_SDR_ENCRYPT_REQUEST;
/* Send */
/* if (CMT_SendMessage(control, &message) != CMTSuccess) goto loser; */
rv = tmp_SendMessage(control, &message);
if (rv != CMTSuccess) goto loser;
if (message.type != SSM_SDR_ENCRYPT_REPLY) { rv = CMTFailure; goto loser; }
rv = CMT_DecodeMessage(SingleItemMessageTemplate, &reply, &message);
if (rv != CMTSuccess)
goto loser;
*result = reply.item.data;
*resultLen = reply.item.len;
reply.item.data = 0;
loser:
if (message.data) free(message.data);
if (request.keyid.data) free(request.keyid.data);
if (request.data.data) free(request.data.data);
if (request.ctx.data) free(request.ctx.data);
if (reply.item.data) free(reply.item.data);
return rv; /* need return value */
}
CMTStatus
CMT_SDRDecrypt(PCMT_CONTROL control, void *ctx,
const unsigned char *data, CMUint32 dataLen,
unsigned char **result, CMUint32 *resultLen)
{
CMTStatus rv;
CMTItem message;
DecryptRequestMessage request;
SingleItemMessage reply;
/* Fill in the request */
request.data = CMT_CopyDataToItem(data, dataLen);
request.ctx = CMT_CopyPtrToItem(ctx);
reply.item.data = 0;
reply.item.len = 0;
message.data = 0;
message.len = 0;
/* Encode */
rv = CMT_EncodeMessage(DecryptRequestTemplate, &message, &request);
if (rv != CMTSuccess) {
goto loser;
}
message.type = SSM_SDR_DECRYPT_REQUEST;
/* Send */
/* if (CMT_SendMessage(control, &message) != CMTSuccess) goto loser; */
rv = tmp_SendMessage(control, &message);
if (rv != CMTSuccess) goto loser;
if (message.type != SSM_SDR_DECRYPT_REPLY) { rv = CMTFailure; goto loser; }
rv = CMT_DecodeMessage(SingleItemMessageTemplate, &reply, &message);
if (rv != CMTSuccess)
goto loser;
*result = reply.item.data;
*resultLen = reply.item.len;
reply.item.data = 0;
loser:
if (message.data) free(message.data);
if (request.data.data) free(request.data.data);
if (request.ctx.data) free(request.ctx.data);
if (reply.item.data) free(reply.item.data);
return rv; /* need return value */
}
CMTStatus
CMT_SDRChangePassword(PCMT_CONTROL control, void *ctx)
{
CMTStatus rv = CMTSuccess;
CMTItem message;
SingleItemMessage request;
SingleNumMessage reply;
/* Fill in the request */
request.item = CMT_CopyPtrToItem(ctx);
message.data = 0;
message.len = 0;
/* Encode */
rv = CMT_EncodeMessage(SingleItemMessageTemplate, &message, &request);
if (rv != CMTSuccess) {
goto loser;
}
message.type = (SSM_REQUEST_MESSAGE|SSM_MISC_ACTION|SSM_MISC_UI|SSM_UI_CHANGE_PASSWORD);
/* Send */
rv = CMT_SendMessage(control, &message);
if (rv != CMTSuccess) goto loser;
if (message.type !=
(SSM_REPLY_OK_MESSAGE|SSM_MISC_ACTION|SSM_MISC_UI|SSM_UI_CHANGE_PASSWORD)) {
rv = CMTFailure;
goto loser;
}
rv = CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message);
if (rv != CMTSuccess)
goto loser;
loser:
if (request.item.data) free(request.item.data);
if (message.data) free(message.data);
return rv; /* need return value */
}

View File

@@ -1,467 +0,0 @@
/* -*- 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.
*/
#ifdef XP_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#else
#ifdef XP_MAC
#else /* windows */
#include <windows.h>
#include <winsock.h>
#endif
#endif
#include <errno.h>
#include "cmtcmn.h"
#include "cmtutils.h"
#include "messages.h"
#include "rsrcids.h"
CMTStatus CMT_OpenSSLConnection(PCMT_CONTROL control, CMTSocket sock,
SSMSSLConnectionRequestType flags,
CMUint32 port, char * hostIP,
char * hostName, CMBool forceHandshake, void* clientContext)
{
CMTItem message;
SSLDataConnectionRequest request;
DataConnectionReply reply;
CMUint32 sent;
/* Do some parameter checking */
if (!control || !hostIP || !hostName) {
goto loser;
}
request.flags = flags;
request.port = port;
request.hostIP = hostIP;
request.hostName = hostName;
request.forceHandshake = forceHandshake;
request.clientContext = CMT_CopyPtrToItem(clientContext);
/* Encode message */
if (CMT_EncodeMessage(SSLDataConnectionRequestTemplate, &message, &request) != CMTSuccess) {
goto loser;
}
/* Set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_DATA_CONNECTION | SSM_SSL_CONNECTION;
/* Send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* Validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_DATA_CONNECTION | SSM_SSL_CONNECTION)) {
goto loser;
}
/* Decode message */
if (CMT_DecodeMessage(DataConnectionReplyTemplate, &reply, &message) != CMTSuccess) {
goto loser;
}
/* Success */
if (reply.result == 0) {
if (control->sockFuncs.connect(sock, reply.port, NULL) != CMTSuccess) {
goto loser;
}
sent = CMT_WriteThisMany(control, sock, control->nonce.data,
control->nonce.len);
if (sent != control->nonce.len) {
goto loser;
}
/* Save connection info */
if (CMT_AddDataConnection(control, sock, reply.connID)
!= CMTSuccess) {
goto loser;
}
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_GetSSLDataErrorCode(PCMT_CONTROL control, CMTSocket sock,
CMInt32* errorCode)
{
CMUint32 connID;
if (!control || !errorCode) {
goto loser;
}
/* get the data connection */
if (CMT_GetDataConnectionID(control, sock, &connID) != CMTSuccess) {
goto loser;
}
/* get the PR error */
if (CMT_GetNumericAttribute(control, connID, SSM_FID_SSLDATA_ERROR_VALUE,
errorCode) != CMTSuccess) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_ReleaseSSLSocketStatus(PCMT_CONTROL control, CMTSocket sock)
{
CMUint32 connectionID;
if (!control || !sock) {
goto loser;
}
if (CMT_GetDataConnectionID(control, sock, &connectionID) != CMTSuccess) {
goto loser;
}
if (CMT_SetNumericAttribute(control, connectionID,
SSM_FID_SSLDATA_DISCARD_SOCKET_STATUS,
0) != CMTSuccess) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_GetSSLSocketStatus(PCMT_CONTROL control, CMTSocket sock,
CMTItem* pickledStatus, CMInt32* level)
{
CMUint32 connectionID;
SingleNumMessage request;
CMTItem message;
PickleSecurityStatusReply reply;
if (!control || !pickledStatus || !level) {
goto loser;
}
/* get the data connection */
if (CMT_GetDataConnectionID(control, sock, &connectionID) != CMTSuccess) {
goto loser;
}
/* set up the request */
request.value = connectionID;
/* encode the request */
if (CMT_EncodeMessage(SingleNumMessageTemplate, &message, &request) !=
CMTSuccess) {
goto loser;
}
/* set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION |
SSM_CONSERVE_RESOURCE | SSM_PICKLE_SECURITY_STATUS;
/* send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION |
SSM_CONSERVE_RESOURCE | SSM_PICKLE_SECURITY_STATUS)) {
goto loser;
}
/* decode the reply */
if (CMT_DecodeMessage(PickleSecurityStatusReplyTemplate, &reply, &message)
!= CMTSuccess) {
goto loser;
}
/* success */
if (reply.result == 0) {
*pickledStatus = reply.blob;
*level = reply.securityLevel;
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_OpenTLSConnection(PCMT_CONTROL control, CMTSocket sock,
CMUint32 port, char* hostIP, char* hostName)
{
TLSDataConnectionRequest request;
CMTItem message;
DataConnectionReply reply;
CMUint32 sent;
/* do some parameter checking */
if (!control || !hostIP || !hostName) {
goto loser;
}
request.port = port;
request.hostIP = hostIP;
request.hostName = hostName;
/* encode the message */
if (CMT_EncodeMessage(TLSDataConnectionRequestTemplate, &message, &request)
!= CMTSuccess) {
goto loser;
}
/* set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_DATA_CONNECTION |
SSM_TLS_CONNECTION;
/* send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_DATA_CONNECTION |
SSM_TLS_CONNECTION)) {
goto loser;
}
/* decode the message */
if (CMT_DecodeMessage(DataConnectionReplyTemplate, &reply, &message) !=
CMTSuccess) {
goto loser;
}
/* success */
if (reply.result == 0) {
if (control->sockFuncs.connect(sock, reply.port, NULL) != CMTSuccess) {
goto loser;
}
sent = CMT_WriteThisMany(control, sock, control->nonce.data,
control->nonce.len);
if (sent != control->nonce.len) {
goto loser;
}
/* save connection info */
if (CMT_AddDataConnection(control, sock, reply.connID) != CMTSuccess) {
goto loser;
}
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_TLSStepUp(PCMT_CONTROL control, CMTSocket sock,
void* clientContext)
{
TLSStepUpRequest request;
SingleNumMessage reply;
CMTItem message;
CMUint32 connectionID;
/* check arguments */
if (!control || !sock) {
goto loser;
}
/* get the data connection ID */
if (CMT_GetDataConnectionID(control, sock, &connectionID) != CMTSuccess) {
goto loser;
}
/* set up the request */
request.connID = connectionID;
request.clientContext = CMT_CopyPtrToItem(clientContext);
/* encode the request */
if (CMT_EncodeMessage(TLSStepUpRequestTemplate, &message, &request) !=
CMTSuccess) {
goto loser;
}
/* set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION | SSM_TLS_STEPUP;
/* send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION |
SSM_TLS_STEPUP)) {
goto loser;
}
/* decode the reply */
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) !=
CMTSuccess) {
goto loser;
}
return (CMTStatus) reply.value;
loser:
return CMTFailure;
}
CMTStatus CMT_OpenSSLProxyConnection(PCMT_CONTROL control, CMTSocket sock,
CMUint32 port, char* hostIP,
char* hostName)
{
TLSDataConnectionRequest request;
CMTItem message;
DataConnectionReply reply;
CMUint32 sent;
/* do some parameter checking */
if (!control || !hostIP || !hostName) {
goto loser;
}
request.port = port;
request.hostIP = hostIP;
request.hostName = hostName;
/* encode the message */
if (CMT_EncodeMessage(TLSDataConnectionRequestTemplate, &message, &request)
!= CMTSuccess) {
goto loser;
}
/* set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_DATA_CONNECTION |
SSM_PROXY_CONNECTION;
/* send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_DATA_CONNECTION |
SSM_PROXY_CONNECTION)) {
goto loser;
}
/* decode the message */
if (CMT_DecodeMessage(DataConnectionReplyTemplate, &reply, &message) !=
CMTSuccess) {
goto loser;
}
/* success */
if (reply.result == 0) {
if (control->sockFuncs.connect(sock, reply.port, NULL) != CMTSuccess) {
goto loser;
}
sent = CMT_WriteThisMany(control, sock, control->nonce.data,
control->nonce.len);
if (sent != control->nonce.len) {
goto loser;
}
/* save connection info */
if (CMT_AddDataConnection(control, sock, reply.connID) != CMTSuccess) {
goto loser;
}
return CMTSuccess;
}
loser:
return CMTFailure;
}
CMTStatus CMT_ProxyStepUp(PCMT_CONTROL control, CMTSocket sock,
void* clientContext, char* remoteUrl)
{
ProxyStepUpRequest request;
SingleNumMessage reply;
CMTItem message;
CMUint32 connectionID;
/* check arguments */
if (!control || !sock || !remoteUrl) {
goto loser;
}
/* get the data connection ID */
if (CMT_GetDataConnectionID(control, sock, &connectionID) != CMTSuccess) {
goto loser;
}
/* set up the request */
request.connID = connectionID;
request.clientContext = CMT_CopyPtrToItem(clientContext);
request.url = remoteUrl;
/* encode the request */
if (CMT_EncodeMessage(ProxyStepUpRequestTemplate, &message, &request) !=
CMTSuccess) {
goto loser;
}
/* set the message request type */
message.type = SSM_REQUEST_MESSAGE | SSM_RESOURCE_ACTION |
SSM_PROXY_STEPUP;
/* send the message and get the response */
if (CMT_SendMessage(control, &message) == CMTFailure) {
goto loser;
}
/* validate the message reply type */
if (message.type != (SSM_REPLY_OK_MESSAGE | SSM_RESOURCE_ACTION |
SSM_PROXY_STEPUP)) {
goto loser;
}
/* decode the reply */
if (CMT_DecodeMessage(SingleNumMessageTemplate, &reply, &message) !=
CMTSuccess) {
goto loser;
}
return (CMTStatus) reply.value;
loser:
return CMTFailure;
}

View File

@@ -1,636 +0,0 @@
/* -*- 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.
*/
#ifdef XP_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#else
#ifdef XP_MAC
#include "macsocket.h"
#else /* Windows */
#include <windows.h>
#include <winsock.h>
#endif
#endif
#include "cmtcmn.h"
#include "cmtutils.h"
#include "newproto.h"
#include <string.h>
/* Local defines */
#if 0
#define PSM_WAIT_BEFORE_SLEEP (CM_TicksPerSecond() * 60)
#define PSM_SPINTIME PSM_WAIT_BEFORE_SLEEP
#define PSM_KEEP_CONNECTION_ALIVE (PSM_WAIT_BEFORE_SLEEP * 900)
#endif
/* If you want to dump the messages sent between the plug-in and the PSM
* server, then remove the comment for the appropriate define.
*/
#if 0
#define PRINT_SEND_MESSAGES
#define PRINT_RECEIVE_MESSAGES
#endif
#ifdef PRINT_SEND_MESSAGES
#ifndef DEBUG_MESSAGES
#define DEBUG_MESSAGES
#endif /*DEBUG_MESSAGES*/
#endif /*PRINT_SEND_MESSAGES*/
#ifdef PRINT_RECEIVE_MESSAGES
#ifndef DEBUG_MESSAGES
#define DEBUG_MESSAGES
#endif /*DEBUG_MESSAGES*/
#endif /*PRINT_RECEIVE_MESSAGES*/
#ifdef DEBUG_MESSAGES
#define LOG(x) do { FILE *f; f=fopen("cmnav.log","a+"); if (f) { \
fprintf(f, x); fclose(f); } } while(0);
#define LOG_S(x) do { FILE *f; f=fopen("cmnav.log","a+"); if (f) { \
fprintf(f, "%s", x); fclose(f); } } while(0);
#define ASSERT(x) if (!(x)) { LOG("ASSERT:"); LOG(#x); LOG("\n"); exit(-1); }
#else
#define LOG(x)
#define LOG_S(x)
#define ASSERT(x)
#endif
CMUint32
cmt_Strlen(char *str)
{
CMUint32 len = strlen(str);
return sizeof(CMInt32) + (((len + 3)/4)*4);
}
CMUint32
cmt_Bloblen(CMTItem *blob)
{
return sizeof(CMInt32) + (((blob->len +3)/4)*4);
}
char *
cmt_PackString(char *buf, char *str)
{
CMUint32 len = strlen(str);
CMUint32 networkLen = htonl(len);
CMUint32 padlen = ((len + 3)/4)*4;
memcpy(buf, &networkLen, sizeof(CMUint32));
memcpy(buf + sizeof(CMUint32), str, len);
memset(buf + sizeof(CMUint32) + len, 0, padlen - len);
return buf+sizeof(CMUint32)+padlen;
}
char *
cmt_PackBlob(char *buf, CMTItem *blob)
{
CMUint32 len = blob->len;
CMUint32 networkLen = htonl(len);
CMUint32 padlen = (((blob->len + 3)/4)*4);
*((CMUint32*)buf) = networkLen;
memcpy(buf + sizeof(CMUint32), blob->data, len);
memset(buf + sizeof(CMUint32) + len, 0, padlen - len);
return buf + sizeof(CMUint32) + padlen;
}
char *
cmt_UnpackString(char *buf, char **str)
{
char *p = NULL;
CMUint32 len, padlen;
/* Get the string length */
len = ntohl(*(CMUint32*)buf);
/* Get the padded length */
padlen = ((len + 3)/4)*4;
/* Allocate the string and copy the data */
p = (char *) malloc(len + 1);
if (!p) {
goto loser;
}
/* Copy the data and NULL terminate */
memcpy(p, buf+sizeof(CMUint32), len);
p[len] = 0;
*str = p;
return buf+sizeof(CMUint32)+padlen;
loser:
*str = NULL;
if (p) {
free(p);
}
return buf+sizeof(CMUint32)+padlen;
}
char *
cmt_UnpackBlob(char *buf, CMTItem **blob)
{
CMTItem *p = NULL;
CMUint32 len, padlen;
/* Get the blob length */
len = ntohl(*(CMUint32*)buf);
/* Get the padded length */
padlen = ((len + 3)/4)*4;
/* Allocate the CMTItem for the blob */
p = (CMTItem*)malloc(sizeof(CMTItem));
if (!p) {
goto loser;
}
p->len = len;
p->data = (unsigned char *) malloc(len);
if (!p->data) {
goto loser;
}
/* Copy that data across */
memcpy(p->data, buf+sizeof(CMUint32), len);
*blob = p;
return buf+sizeof(CMUint32)+padlen;
loser:
*blob = NULL;
CMT_FreeMessage(p);
return buf+sizeof(CMUint32)+padlen;
}
#ifdef DEBUG_MESSAGES
void prettyPrintMessage(CMTItem *msg)
{
int numLines = ((msg->len+7)/8);
char curBuffer[9], *cursor, string[2], hexVal[8];
char hexArray[25];
int i, j, numToCopy;
/*Try printing out 8 bytes at a time. */
LOG("\n**********************************************************\n");
LOG("About to pretty Print Message\n\n");
curBuffer[9] = '\0';
hexArray[24] = '\0';
hexVal[2] = '\0';
string[1] = '\0';
LOG("Header Info\n");
LOG("Message Type: ");
sprintf(hexArray, "%lx\n", msg->type);
LOG(hexArray);
LOG("Message Length: ");
sprintf (hexArray, "%ld\n\n", msg->len);
LOG(hexArray);
LOG("Body of Message\n");
for (i=0, cursor=msg->data; i<numLines; i++, cursor+=8) {
/* First copy over the buffer to our local array */
numToCopy = ((msg->len - (unsigned int)((unsigned long)cursor-(unsigned long)msg->data)) < 8) ?
msg->len - (unsigned int)((unsigned long)cursor-(unsigned long)msg->data) : 8;
memcpy(curBuffer, cursor, 8);
for (j=0;j<numToCopy;j++) {
string[0] = curBuffer[j];
if (isprint(curBuffer[j])) {
string[0] = curBuffer[j];
} else {
string[0] = ' ';
}
LOG(string);
}
string[0] = ' ';
for (;j<8;j++) {
LOG(string);
}
LOG("\t");
for (j=0; j<numToCopy; j++) {
sprintf (hexVal,"%.2x", 0x0ff & (unsigned short)curBuffer[j]);
LOG(hexVal);
LOG(" ");
}
LOG("\n");
}
LOG("Done Pretty Printing Message\n");
LOG("**********************************************************\n\n");
}
#endif
CMTStatus CMT_SendMessage(PCMT_CONTROL control, CMTItem* message)
{
CMTStatus status;
CMUint32 msgCategory;
CMBool done = CM_FALSE;
#ifdef PRINT_SEND_MESSAGES
LOG("About to print message sent to PSM\n");
prettyPrintMessage(message);
#endif
/* Acquire lock on the control connection */
CMT_LOCK(control->mutex);
/* Try to send pending random data */
if (message->type != (SSM_REQUEST_MESSAGE | SSM_HELLO_MESSAGE))
{
/* If we've already said hello, then flush random data
just before sending the request. */
status = CMT_FlushPendingRandomData(control);
if (status != CMTSuccess)
goto loser;
}
status = CMT_TransmitMessage(control, message);
if (status != CMTSuccess) {
goto loser;
}
/* We have to deal with other types of data on the socket and */
/* handle them accordingly */
while (!done) {
status = CMT_ReceiveMessage(control, message);
if (status != CMTSuccess) {
goto loser;
}
msgCategory = (message->type & SSM_CATEGORY_MASK);
switch (msgCategory) {
case SSM_REPLY_OK_MESSAGE:
done = CM_TRUE;
break;
case SSM_REPLY_ERR_MESSAGE:
done = CM_TRUE;
break;
case SSM_EVENT_MESSAGE:
CMT_DispatchEvent(control, message);
break;
/* XXX FIX THIS!!! For the moment I'm ignoring all other types */
default:
break;
}
}
/* Release the control connection lock */
CMT_UNLOCK(control->mutex);
return CMTSuccess;
loser:
/* Release the control connection lock */
CMT_UNLOCK(control->mutex);
return CMTFailure;
}
CMTStatus CMT_TransmitMessage(PCMT_CONTROL control, CMTItem * message)
{
CMTMessageHeader header;
CMUint32 sent, rv;
/* Set up the message header */
header.type = htonl(message->type);
header.len = htonl(message->len);
/* Send the message header */
sent = CMT_WriteThisMany(control, control->sock,
(void *)&header, sizeof(CMTMessageHeader));
if (sent != sizeof(CMTMessageHeader)) {
goto loser;
}
/* Send the message body */
sent = CMT_WriteThisMany(control, control->sock, (void *)message->data,
message->len);
if (sent != message->len) {
goto loser;
}
/* Free the buffer */
free(message->data);
message->data = NULL;
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_ReceiveMessage(PCMT_CONTROL control, CMTItem * response)
{
CMTMessageHeader header;
CMUint32 numread, rv;
/* Get the message header */
numread = CMT_ReadThisMany(control, control->sock,
(void *)&header, sizeof(CMTMessageHeader));
if (numread != sizeof(CMTMessageHeader)) {
goto loser;
}
response->type = ntohl(header.type);
response->len = ntohl(header.len);
response->data = (unsigned char *) malloc(response->len);
if (response->data == NULL) {
goto loser;
}
numread = CMT_ReadThisMany(control, control->sock,
(void *)(response->data), response->len);
if (numread != response->len) {
goto loser;
}
#ifdef PRINT_RECEIVE_MESSAGES
LOG("About to print message received from PSM.\n");
prettyPrintMessage(response);
#endif /*PRINT_RECEIVE_MESSAGES*/
return CMTSuccess;
loser:
if (response->data) {
free(response->data);
}
return CMTFailure;
}
CMUint32 CMT_ReadThisMany(PCMT_CONTROL control, CMTSocket sock,
void * buffer, CMUint32 thisMany)
{
CMUint32 total = 0;
while (total < thisMany) {
int got;
got = control->sockFuncs.recv(sock, (void*)((char*)buffer + total),
thisMany-total);
if (got < 0 ) {
break;
}
total += got;
}
return total;
}
CMUint32 CMT_WriteThisMany(PCMT_CONTROL control, CMTSocket sock,
void * buffer, CMUint32 thisMany)
{
CMUint32 total = 0;
while (total < thisMany) {
CMInt32 got;
got = control->sockFuncs.send(sock, (void*)((char*)buffer+total),
thisMany-total);
if (got < 0) {
break;
}
total += got;
}
return total;
}
CMTItem* CMT_ConstructMessage(CMUint32 type, CMUint32 length)
{
CMTItem * p;
p = (CMTItem*)malloc(sizeof(CMTItem));
if (!p) {
goto loser;
}
p->type = type;
p->len = length;
p->data = (unsigned char *) malloc(length);
if (!p->data) {
goto loser;
}
return p;
loser:
CMT_FreeMessage(p);
return NULL;
}
void CMT_FreeMessage(CMTItem * p)
{
if (p != NULL) {
if (p->data != NULL) {
free(p->data);
}
free(p);
}
}
CMTStatus CMT_AddDataConnection(PCMT_CONTROL control, CMTSocket sock,
CMUint32 connectionID)
{
PCMT_DATA ptr;
/* This is the first connection */
if (control->cmtDataConnections == NULL) {
control->cmtDataConnections = ptr =
(PCMT_DATA)calloc(sizeof(CMT_DATA), 1);
if (!ptr) {
goto loser;
}
} else {
/* Position at the last entry */
for (ptr = control->cmtDataConnections; (ptr != NULL && ptr->next
!= NULL); ptr = ptr->next);
ptr->next = (PCMT_DATA)calloc(sizeof(CMT_DATA), 1);
if (!ptr->next) {
goto loser;
}
/* Fix up the pointers */
ptr->next->previous = ptr;
ptr = ptr->next;
}
/* Fill in the data */
ptr->sock = sock;
ptr->connectionID = connectionID;
return CMTSuccess;
loser:
return CMTFailure;
}
int
CMT_DestroyDataConnection(PCMT_CONTROL control, CMTSocket sock)
{
PCMT_DATA ptr, pptr = NULL;
int rv=CMTSuccess;
control->sockFuncs.close(sock);
for (ptr = control->cmtDataConnections; ptr != NULL;
pptr = ptr, ptr = ptr->next) {
if (ptr->sock == sock) {
if (pptr == NULL) {
/* node is at head */
control->cmtDataConnections = ptr->next;
if (ptr->priv != NULL)
ptr->priv->dest(ptr->priv);
free(ptr);
return rv;
}
/* node is elsewhere */
pptr->next = ptr->next;
if (ptr->priv != NULL)
ptr->priv->dest(ptr->priv);
free(ptr);
return rv;
}
}
return rv;
}
CMTStatus CMT_CloseDataConnection(PCMT_CONTROL control, CMUint32 connectionID)
{
/* PCMT_DATA ptr, pptr = NULL; */
CMTSocket sock;
/* int rv;*/
/* Get the socket for this connection */
if (CMT_GetDataSocket(control, connectionID, &sock) == CMTFailure) {
goto loser;
}
/* Free data connection associated with this socket */
if (CMT_DestroyDataConnection(control, sock) == CMTFailure) {
goto loser;
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus CMT_GetDataConnectionID(PCMT_CONTROL control, CMTSocket sock, CMUint32 * connectionID)
{
PCMT_DATA ptr;
for (ptr = control->cmtDataConnections; ptr != NULL; ptr = ptr->next) {
if (ptr->sock == sock) {
*connectionID = ptr->connectionID;
return CMTSuccess;
}
}
return CMTFailure;
}
CMTStatus CMT_GetDataSocket(PCMT_CONTROL control, CMUint32 connectionID, CMTSocket * sock)
{
PCMT_DATA ptr;
for (ptr = control->cmtDataConnections; ptr != NULL; ptr = ptr->next) {
if (ptr->connectionID == connectionID) {
*sock = ptr->sock;
return CMTSuccess;
}
}
return CMTFailure;
}
CMTStatus CMT_SetPrivate(PCMT_CONTROL control, CMUint32 connectionID,
CMTPrivate *cmtpriv)
{
PCMT_DATA ptr;
for (ptr = control->cmtDataConnections; ptr != NULL; ptr = ptr->next) {
if (ptr->connectionID == connectionID) {
ptr->priv = cmtpriv;
return CMTSuccess;
}
}
return CMTFailure;
}
CMTPrivate *CMT_GetPrivate(PCMT_CONTROL control, CMUint32 connectionID)
{
PCMT_DATA ptr;
for (ptr = control->cmtDataConnections; ptr != NULL; ptr = ptr->next) {
if (ptr->connectionID == connectionID) {
return ptr->priv;
}
}
return NULL;
}
void CMT_FreeItem(CMTItem *p)
{
CMT_FreeMessage(p);
}
CMTItem CMT_CopyPtrToItem(void* p)
{
CMTItem value = {0, NULL, 0};
if (!p) {
return value;
}
value.len = sizeof(p);
value.data = (unsigned char *) malloc(value.len);
memcpy(value.data, &p, value.len);
return value;
}
void * CMT_CopyItemToPtr(CMTItem value)
{
void * p = NULL;
if (value.len == sizeof(void*)) {
memcpy(&p, value.data, value.len);
}
return p;
}
CMTStatus CMT_ReferenceControlConnection(PCMT_CONTROL control)
{
CMT_LOCK(control->mutex);
control->refCount++;
CMT_UNLOCK(control->mutex);
return CMTSuccess;
}
void
CMT_LockConnection(PCMT_CONTROL control)
{
CMT_LOCK(control->mutex);
}
void
CMT_UnlockConnection(PCMT_CONTROL control)
{
CMT_UNLOCK(control->mutex);
}

View File

@@ -1,75 +0,0 @@
/*
* 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 __CMTUTILS_H__
#define __CMTUTILS_H__
#include "cmtcmn.h"
#define New(type) (type*)malloc(sizeof(type))
#define NewArray(type, size) (type*)malloc(sizeof(type)*(size))
PCMT_EVENT CMT_GetEventHandler(PCMT_CONTROL control, CMUint32 type,
CMUint32 resourceID);
CMUint32 cmt_Strlen(char *str);
char *cmt_PackString(char *buf, char *str);
char *cmt_UnpackString(char *buf, char **str);
CMUint32 cmt_Bloblen(CMTItem* len);
char *cmt_PackBlob(char *buf, CMTItem * blob);
char *cmt_UnpackBlob(char *buf, CMTItem **blob);
CMTStatus CMT_SendMessage(PCMT_CONTROL control, CMTItem* message);
CMTStatus CMT_TransmitMessage(PCMT_CONTROL control, CMTItem * message);
CMTStatus CMT_ReceiveMessage(PCMT_CONTROL control, CMTItem * response);
CMUint32 CMT_ReadThisMany(PCMT_CONTROL control, CMTSocket sock,
void * buffer, CMUint32 thisMany);
CMUint32 CMT_WriteThisMany(PCMT_CONTROL control, CMTSocket sock,
void * buffer, CMUint32 thisMany);
CMTItem* CMT_ConstructMessage(CMUint32 type, CMUint32 length);
void CMT_FreeMessage(CMTItem * p);
CMTStatus CMT_AddDataConnection(PCMT_CONTROL control, CMTSocket sock, CMUint32 connectionID);
CMTStatus CMT_GetDataConnectionID(PCMT_CONTROL control, CMTSocket sock, CMUint32 * connectionID);
CMTStatus CMT_GetDataSocket(PCMT_CONTROL control, CMUint32 connectionID, CMTSocket * sock);
CMTStatus CMT_CloseDataConnection(PCMT_CONTROL control, CMUint32 connectionID);
CMTStatus CMT_SetPrivate(PCMT_CONTROL control, CMUint32 connectionID,
CMTPrivate *cmtpriv);
CMTPrivate *CMT_GetPrivate(PCMT_CONTROL control, CMUint32 connectionID);
void CMT_ServicePasswordRequest(PCMT_CONTROL cm_control, CMTItem * requestData);
void CMT_ProcessEvent(PCMT_CONTROL cm_control);
void CMT_DispatchEvent(PCMT_CONTROL cm_control, CMTItem * eventData);
CMTItem CMT_CopyPtrToItem(void* p);
void * CMT_CopyItemToPtr(CMTItem value);
#endif /* __CMTUTILS_H__ */

View File

@@ -1,44 +0,0 @@
#
# 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.
#
#
# Override TARGETS variable so that only static libraries
# are specifed as dependencies within rules.mk.
#
TARGETS = $(LIBRARY)
SHARED_LIBRARY =
IMPORT_LIBRARY =
PURE_LIBRARY =
PROGRAM =

View File

@@ -1,125 +0,0 @@
#//
#// 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.
#//
IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build the ssl library
#//
#//------------------------------------------------------------------------
!if "$(MOZ_BITS)" == "16"
!ifndef MOZ_DEBUG
OPTIMIZER=-Os -UDEBUG -DNDEBUG
!endif
!endif
#//------------------------------------------------------------------------
#//
#// Specify the depth of the current directory relative to the
#// root of NS
#//
#//------------------------------------------------------------------------
DEPTH= ..\..\..\..
!ifndef MAKE_OBJ_TYPE
MAKE_OBJ_TYPE=EXE
!endif
#//------------------------------------------------------------------------
#//
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
#//
#//------------------------------------------------------------------------
LIBNAME=cmt
PDBFILE=$(LIBNAME).pdb
LINCS = -I$(PUBLIC)\security \
-I$(PUBLIC)\nspr \
-I$(DEPTH)\include \
-I..\include
!ifndef OS_CONFIG
OS_CONFIG = WIN$(MOZ_BITS)
!endif
LCFLAGS = -DEXPORT_VERSION -DLIB_BUILD
#//------------------------------------------------------------------------
#//
#// Define the files necessary to build the target (ie. OBJS)
#//
#//------------------------------------------------------------------------
OBJS= \
.\$(OBJDIR)\cmtinit.obj \
.\$(OBJDIR)\cmtssl.obj \
.\$(OBJDIR)\cmtutils.obj \
.\$(OBJDIR)\cmtpkcs7.obj \
.\$(OBJDIR)\cmthash.obj \
.\$(OBJDIR)\cmtcert.obj \
.\$(OBJDIR)\cmtres.obj \
.\$(OBJDIR)\cmtjs.obj \
.\$(OBJDIR)\cmtevent.obj \
.\$(OBJDIR)\cmtpasswd.obj \
.\$(OBJDIR)\cmtadvisor.obj \
.\$(OBJDIR)\cmtrng.obj \
.\$(OBJDIR)\cmtsdr.obj \
$(NULL)
#//------------------------------------------------------------------------
#//
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
#// (these must be defined before the common makefiles are included)
#//
#//------------------------------------------------------------------------
LIBRARY=.\$(OBJDIR)\$(LIBNAME).lib
#//------------------------------------------------------------------------
#//
#// install headers
#//
#//------------------------------------------------------------------------
INSTALL_DIR=$(PUBLIC)\security
INSTALL_FILE_LIST=cmtcmn.h cmtjs.h cmtclist.h
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
export:: INSTALL_FILES

View File

@@ -1,64 +0,0 @@
#
# 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.
#
CORE_DEPTH = ../../..
DEPTH = ../../..
EXPORTS = \
cmtcmn.h \
cmtjs.h \
cmtclist.h \
$(NULL)
MODULE = security
CSRCS = cmtinit.c \
cmtssl.c \
cmtutils.c \
cmtcert.c \
cmthash.c \
cmtpkcs7.c \
cmtres.c \
cmtjs.c \
cmtevent.c \
cmtpasswd.c \
cmtadvisor.c \
cmtrng.c \
cmtsdr.c \
$(NULL)
REQUIRES = nspr security
LIBRARY_NAME = cmt
INCLUDES += -I$(CORE_DEPTH)/include

View File

@@ -1,128 +0,0 @@
#! gmake
#
# 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.
#
#######################################################################
# (1) Include initial platform-independent assignments (MANDATORY). #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "global" configuration information. (OPTIONAL) #
#######################################################################
include $(CORE_DEPTH)/coreconf/config.mk
#######################################################################
# (3) Include "component" configuration information. (OPTIONAL) #
#######################################################################
#######################################################################
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
ifneq ($(OS_ARCH), WINNT)
ifeq ($(OS_ARCH), Linux)
# On linux, we link with libstdc++
CPLUSPLUSRUNTIME = -L /usr/lib -lstdc++ -lm
else
# libC, presumably, is what we must link with elsewhere
CPLUSPLUSRUNTIME = -lC -lm
endif
endif
ifeq ($(OS_ARCH), SunOS)
ifeq ($(OS_RELEASE), 5.5.1)
OS_LIBS += -ldl -lsocket -lnsl -lthread -lposix4
endif
ifeq ($(OS_RELEASE), 5.6)
OS_LIBS += -ldl -lsocket -lnsl -lthread -lposix4
endif
endif
ifeq ($(OS_ARCH), Linux)
ifdef USE_PTHREADS
# Replace OS_LIBS, because the order of libpthread, libdl, and libc are
# very important. Otherwise you get horrible crashes.
OS_LIBS = -lpthread -ldl -lc
endif
endif
#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
#######################################################################
include $(CORE_DEPTH)/coreconf/rules.mk
#######################################################################
# (6) Execute "component" rules. (OPTIONAL) #
#######################################################################
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################
ifeq ($(OS_ARCH), WINNT)
LDFLAGS += /NODEFAULTLIB:library
endif
EXTRA_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)cmt.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)protocol.$(LIB_SUFFIX) \
$(NULL)
ifeq ($(OS_ARCH), WINNT)
EXTRA_LIBS += wsock32.lib \
winmm.lib \
$(NULL)
endif
link:
if test -f $(PROGRAM); then \
echo "rm $(PROGRAM)"; \
rm $(PROGRAM); \
fi; \
gmake \
build_sample:
ifneq ($(OS_ARCH),WINNT)
cd $(CORE_DEPTH)/coreconf; gmake
endif
cd $(CORE_DEPTH)/security; gmake import; gmake export
cd ../../protocol; gmake
cd ..; gmake
gmake

View File

@@ -1,250 +0,0 @@
/* -*- 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.
*/
#include "cmtcmn.h"
#include "appsock.h"
#ifdef XP_UNIX
#include <netinet/tcp.h>
#include <errno.h>
#endif
CMT_SocketFuncs socketFuncs = {
APP_GetSocket,
APP_Connect,
APP_VerifyUnixSocket,
APP_Send,
APP_Select,
APP_Receive,
APP_Shutdown,
APP_Close
};
CMTSocket APP_GetSocket(int unixSock)
{
APPSocket *sock;
int on = 1;
#ifndef XP_UNIX
if (unixSock) {
return NULL;
}
#endif
sock = malloc(sizeof(APPSocket));
if (sock == NULL) {
return NULL;
}
if (unixSock) {
sock->sock = socket(AF_UNIX, SOCK_STREAM, 0);
} else {
sock->sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
}
if (sock->sock < 0) {
free(sock);
return NULL;
}
if (!unixSock &&
setsockopt(sock->sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&on,
sizeof(on))) {
free(sock);
return NULL;
}
sock->isUnix = unixSock;
#ifdef XP_UNIX
memset (&sock->servAddr, 0, sizeof(struct sockaddr_un));
#endif
return (CMTSocket)sock;
}
CMTStatus APP_Connect(CMTSocket sock, short port, char *path)
{
APPSocket *cmSock = (APPSocket*)sock;
struct sockaddr_in iServAddr;
const struct sockaddr *servAddr;
size_t addrLen;
int error;
if (cmSock->isUnix){
#ifndef XP_UNIX
return CMTFailure;
#else
cmSock->servAddr.sun_family = AF_UNIX;
memcpy(&cmSock->servAddr.sun_path, path, strlen(path)+1);
servAddr = (const struct sockaddr*)&cmSock->servAddr;
addrLen = sizeof(cmSock->servAddr);
#endif
} else {
iServAddr.sin_family = AF_INET;
iServAddr.sin_port = htons(port);
iServAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
servAddr = (const struct sockaddr*)&iServAddr;
addrLen = sizeof(struct sockaddr_in);
}
while (connect(cmSock->sock, servAddr, addrLen) != 0) {
#ifdef WIN32
error = WSAGetLastError();
if (error == WSAEISCONN) {
break;
}
if ((error != WSAEINPROGRESS) && (error != WSAEWOULDBLOCK) &&
(error!= WSAEINVAL)) {
goto loser;
}
#else
error = errno;
if (error == EISCONN) {
break;
}
if (error != EINPROGRESS) {
goto loser;
}
#endif
}
return CMTSuccess;
loser:
return CMTFailure;
}
CMTStatus APP_VerifyUnixSocket(CMTSocket sock)
{
#ifndef XP_UNIX
return CMTFailure;
#else
APPSocket *cmSock = (APPSocket*)sock;
int rv;
struct stat statbuf;
if (!cmSock->isUnix) {
return CMTFailure;
}
rv = stat(cmSock->servAddr.sun_path, &statbuf);
if (rv < 0) {
goto loser;
}
if (statbuf.st_uid != geteuid()) {
goto loser;
}
return CMTSuccess;
loser:
close(cmSock->sock);
free(cmSock);
return CMTFailure;
#endif
}
size_t APP_Send(CMTSocket sock, void *buffer, size_t length)
{
APPSocket *cmSock = (APPSocket*) sock;
return send(cmSock->sock, buffer, length, 0);
}
CMTSocket APP_Select(CMTSocket *socks, int numsocks, int poll)
{
APPSocket **sockArr = (APPSocket**)socks;
SOCKET nsocks = 0;
int i, rv;
struct timeval timeout;
fd_set readfds;
#ifdef WIN32
win_startover:
#endif
FD_ZERO(&readfds);
for (i=0; i<numsocks; i++) {
FD_SET(sockArr[i]->sock, &readfds);
if (sockArr[i]->sock > nsocks) {
nsocks = sockArr[i]->sock;
}
}
if (poll) {
timeout.tv_sec = 0;
timeout.tv_usec = 0;
}
rv = select(nsocks+1, &readfds, NULL, NULL, (poll) ? &timeout : NULL);
#ifdef WIN32
/* XXX Win95/98 Bug (Q177346)
* select() with no timeout might return even if there is no data
* pending or no error has occurred. To get around this problem,
* we loop if these erroneous conditions happen.
*/
if (poll == 0 && rv == 0) {
goto win_startover;
}
#endif
/* Figure out which socket was selected */
if (rv == -1 || rv == 0) {
goto loser;
}
for (i=0; i<numsocks; i++) {
if (FD_ISSET(sockArr[i]->sock, &readfds)) {
return (CMTSocket)sockArr[i];
}
}
loser:
return NULL;
}
size_t APP_Receive(CMTSocket sock, void *buffer, size_t bufSize)
{
APPSocket *cmSock = (APPSocket*)sock;
return recv(cmSock->sock, buffer, bufSize, 0);
}
CMTStatus APP_Shutdown(CMTSocket sock)
{
APPSocket *cmSock = (APPSocket*)sock;
int rv;
rv = shutdown(cmSock->sock, 1);
return (rv == 0) ? CMTSuccess : CMTFailure;
}
CMTStatus APP_Close(CMTSocket sock)
{
APPSocket *cmSock = (APPSocket*)sock;
int rv;
#ifdef XP_UNIX
rv = close(cmSock->sock);
#else
rv = closesocket(cmSock->sock);
#endif
free(cmSock);
return (rv == 0) ? CMTSuccess : CMTFailure;
}

View File

@@ -1,69 +0,0 @@
/* -*- 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.
*/
#ifndef _APPSOCK_H_
#define _APPSOCK_H_
#include "cmtcmn.h"
#ifdef XP_UNIX
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <sys/stat.h>
typedef int SOCKET;
#endif
typedef struct APPSocketStr {
SOCKET sock;
int isUnix;
#ifdef XP_UNIX
struct sockaddr_un servAddr;
#endif
} APPSocket;
extern CMT_SocketFuncs socketFuncs;
CMTStatus APP_Close(CMTSocket sock);
CMTStatus APP_Shutdown(CMTSocket sock);
size_t APP_Receive(CMTSocket sock, void *buffer, size_t bufSize);
CMTSocket APP_Select(CMTSocket *socks, int numsocks, int poll);
size_t APP_Send(CMTSocket sock, void *buffer, size_t length);
CMTStatus APP_VerifyUnixSocket(CMTSocket sock);
CMTStatus APP_Connect(CMTSocket sock, short port, char *path);
CMTSocket APP_GetSocket(int unixSock);
#endif /* _APPSOCK_H_ */

View File

@@ -1,44 +0,0 @@
#
# 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.
#
#
# Override TARGETS variable so that only static libraries
# are specifed as dependencies within rules.mk.
#
TARGETS = $(PROGRAM)
SHARED_LIBRARY =
IMPORT_LIBRARY =
PURE_LIBRARY =
LIBRARY =

View File

@@ -1,52 +0,0 @@
#
# 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.
#
CORE_DEPTH = ../../../../..
# MODULE public and private header directories are implicitly REQUIRED.
MODULE = cmtsample
EXPORTS = \
$(NULL)
CSRCS = \
sample.c \
appsock.c \
$(NULL)
INCLUDES += -I../../protocol -I..
# The MODULE is always implicitly required.
# Listing it here in REQUIRES makes it appear twice in the cc command line.
REQUIRES = security
PROGRAM = cmtsample

View File

@@ -1,346 +0,0 @@
/* -*- 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.
*/
#include "cmtcmn.h"
#include "cmtjs.h"
#include "appsock.h"
#include <stdarg.h>
#include <string.h>
#ifdef XP_UNIX
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#ifdef WIN32
#include <direct.h>
#endif
/*
* This is a simple program that tries to detect if the psm server is loaded.
* If the server is not loaded, it will start it. The program will then
* connect to the server and fetch an HTML page from an SSL server.
*
* NOTE: This sample program does not implement a mutex for the libraries.
* If implementing a threaded application, then pass in a mutex structure
* so that connections to the psm server happen in a thread safe manner.
*/
#define NUM_CONNECT_TRIES 10
#define READ_BUFFER_SIZE 1024
void
usage(void)
{
printf("Usage:\n"
"\tcmtsample <secure site>\n\n"
"This program will then echo the retrieved HTML to the screen\n");
}
void
errorMessage(int err,char *msg, ...)
{
va_list args;
va_start(args, msg);
fprintf (stderr, "cmtSample%s: ", (err) ? " error" : "");
vfprintf (stderr, msg, args);
fprintf (stderr, "\n");
va_end(args);
if (err) {
exit (err);
}
}
#ifdef XP_UNIX
#define FILE_PATH_SEPARATOR '/'
#elif defined (WIN32)
#define FILE_PATH_SEPARATOR '\\'
#else
#error Tell me what the file path separator is.
#endif
PCMT_CONTROL
connect_to_psm(void)
{
PCMT_CONTROL control=NULL;
char path[256], *tmp;
#ifdef XP_UNIX
if (getcwd(path,256) == NULL) {
return NULL;
}
#elif defined(WIN32)
if (_getcwd(path,256) == NULL) {
return NULL;
}
#else
#error Teach me how to get the current working directory.
#endif
tmp = &path[strlen(path)];
sprintf(tmp,"%c%s", FILE_PATH_SEPARATOR, "psm");
return CMT_EstablishControlConnection(path, &socketFuncs, NULL);
}
#define HTTPS_STRING "https://"
char*
extract_host_from_url(char *url)
{
char *start, *end, *retString=NULL;
while(isspace(*url)) {
url++;
}
url = strdup(url);
start = strstr(url, HTTPS_STRING);
if (start == NULL) {
return NULL;
}
start += strlen(HTTPS_STRING);
/*
* Figure out the end of the host name.
*/
end = strchr(start, ':');
if (end != NULL) {
*end = '\0';
} else {
end = strchr(start, '/');
if (end != NULL) {
*end = '\0';
} else {
end = strchr(start, ' ');
if (end != NULL) {
*end = '\0';
}
}
}
retString = strdup(start);
return retString;
}
CMUint32
get_port_from_url(char *url)
{
char *colon, *port;
url = strdup(url);
colon = strrchr(url, ':');
if (colon == NULL ||
!isdigit(colon[1])) {
/* Return the default SSL port. */
free(url);
return 443;
}
colon++;
port = colon;
while(isdigit(*colon))
colon++;
colon[1] = '\0';
free(url);
return (CMUint32)atol(port);
}
char*
extract_get_target(char *url)
{
char *slash;
slash = strstr(url, "//");
slash += 2;
slash = strchr(slash, '/');
if (slash != NULL)
return strdup (slash);
else
return strdup ("/");
}
/*
* We'll use this function for prompting for a password.
*/
char*
passwordCallback(void *arg, char *prompt, void *cotext, int isPaswd)
{
char input[256];
printf(prompt);
fgets(input, 256, stdin);
return strdup(input);
}
void
freeCallback(char *userInput)
{
free (userInput);
}
#define NUM_PREFS 2
int
main(int argc, char **argv)
{
PCMT_CONTROL control;
CMTSocket sock, selSock;
char *hostname;
struct hostent *host;
char *ipAddress;
char buffer[READ_BUFFER_SIZE];
size_t bytesRead;
struct sockaddr_in destAddr;
char *getString;
char requestString[256];
char *profile;
CMTSetPrefElement prefs[NUM_PREFS];
char profileDir[256];
#ifdef WIN32
WORD WSAVersion = 0x0101;
WSADATA WSAData;
WSAStartup (WSAVersion, &WSAData);
#endif
if (argc < 2) {
usage();
return 1;
}
errorMessage (0,"cmtsample v1.0");
errorMessage (0,"Will try connecting to site %s", argv[1]);
if (strstr(argv[1], "https://") == NULL) {
errorMessage(2,"%s is not a secure site", argv[1]);
}
control = connect_to_psm();
if (control == NULL) {
errorMessage(3, "Could not connect to the psm server");
}
/*
* Now we have to send the hello message.
*/
#ifdef WIN32
profile = strdup("default");
sprintf(profileDir,"%s", "c:\\default");
#elif defined (XP_UNIX)
profile = getenv("LOGNAME");
sprintf(profileDir, "%s/.netscape", getenv("HOME"));
#else
#error Teach me how to fill in the user profile.
#endif
if (CMT_Hello(control, PROTOCOL_VERSION,
profile, profileDir) != CMTSuccess)
{
errorMessage(10, "Failed to send the Hello Message.");
}
CMT_SetPromptCallback(control, passwordCallback, NULL);
CMT_SetAppFreeCallback(control, freeCallback);
/*
* Now pass along some preferences to psm. We'll pass hard coded
* ones here, but apps should figure out a way to manage their user's
* preferences.
*/
prefs[0].key = "security.enable_ssl2";
prefs[0].value = "true";
prefs[0].type = CMT_PREF_BOOL;
prefs[1].key = "security.enable_ssl3";
prefs[1].value = "true";
prefs[1].type = CMT_PREF_BOOL;
CMT_PassAllPrefs(control, NUM_PREFS, prefs);
hostname = extract_host_from_url(argv[1]);
host = gethostbyname(hostname);
if (host == NULL) {
errorMessage(11, "gethostbyname for %s failed", hostname);
}
if (host->h_length != 4) {
errorMessage(4, "Site %s uses IV v6 socket. Not supported by psm.");
}
/* Create the socket we will use to get the decrypted data back from
* the psm server.
*/
sock = APP_GetSocket(0);
if (sock == NULL) {
errorMessage(5, "Could not create new socket for communication with "
"the psm server.");
}
memcpy(&(destAddr.sin_addr.s_addr), host->h_addr, host->h_length);
ipAddress = inet_ntoa(destAddr.sin_addr);
errorMessage(0, "Mapped %s to the following IP address: %s", argv[1],
ipAddress);
if (CMT_OpenSSLConnection(control, sock, SSM_REQUEST_SSL_DATA_SSL,
get_port_from_url(argv[1]), ipAddress,
hostname, CM_FALSE, NULL) != CMTSuccess) {
errorMessage(6, "Could not open SSL connection to %s.", argv[1]);
}
getString = extract_get_target(argv[1]);
sprintf(requestString,
"GET %s HTTP/1.0\r\n"
"\r\n", getString, hostname);
APP_Send(sock, requestString, strlen(requestString));
/*
* Now all we have to do is sit here and fetch the data from the
* socket.
*/
errorMessage (0, "About to print out the fetched page.");
while ((selSock=APP_Select(&sock, 1, 0)) != NULL) {
if (selSock == sock) {
bytesRead = APP_Receive(sock, buffer, READ_BUFFER_SIZE-1);
if (bytesRead == -1 || bytesRead == 0) {
break;
}
buffer[bytesRead] = '\0';
fprintf(stderr, buffer);
}
}
fprintf(stderr,"\n");
if (bytesRead == -1) {
errorMessage(7, "Error receiving decrypted data from psm.");
}
errorMessage(0, "Successfully read the entire page.");
if (CMT_DestroyDataConnection(control, sock) != CMTSuccess) {
errorMessage(8, "Error destroygin the SSL data connection "
"with the psm server.");
}
if (CMT_CloseControlConnection(control) != CMTSuccess) {
errorMessage(9, "Error closing the control connection.");
}
return 0;
}

View File

@@ -1,99 +0,0 @@
/*
* 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.
*/
#include "cmt.h"
CMTStatus myCallback(CMTControl * control, CMTItem * event, void * arg);
int main(int argc, char ** argv)
{
CMTItem * msg, * event = NULL;
CMTStatus status;
int socket, datasocket;
int sent;
CMTControl * connect;
char * buffer = "some weird text that I feel like passing to server";
connect = CMT_ControlConnect(myCallback, event);
msg = CMT_ConstructMessage(10);
msg->type = (int)CMTClientMessage;
sprintf((char *)msg->data, "first msg!");
status = CMT_SendMessage(connect, msg, event);
if (status != SECSuccess)
perror("CMT_SendMessage");
CMT_FreeEvent(event);
event = NULL;
sprintf((char *)msg->data, "second msg");
status = CMT_SendMessage(connect, msg, event);
if (status != SECSuccess)
perror("CMT_SendMessage");
datasocket = CMT_DataConnect(connect, NULL);
if (datasocket < 0)
perror("CMT_DataConnect");
sent = write(datasocket, (void *)buffer, strlen(buffer));
sent = write(datasocket, (void *)buffer, strlen(buffer));
close(datasocket);
msg->type = (int)CMTClientMessage;
sprintf((char *)msg->data, "third msg!");
status = CMT_SendMessage(connect, msg, event);
if (status != SECSuccess)
perror("CMT_SendMessage");
status = CMT_CloseControlConnection(connect);
if (status != SECSuccess)
perror("CMT_CloseControl");
CMT_FreeMessage(msg);
CMT_FreeEvent(event);
}
CMTStatus myCallback(CMTControl * control, CMTItem * event, void * arg)
{
if (event)
printf("Event received is : type %d, data %s\n", event->type, event->data);
else printf("No event!\n");
if (arg)
printf("Arg is %s\n", (char *)arg);
else printf("No arg!\n");
return SECSuccess;
}

View File

@@ -1,3 +0,0 @@
#include "MacPrefix.h"

View File

@@ -1,2 +0,0 @@
#include "MacPrefix_debug.h"

View File

@@ -1,27 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
include <$(DEPTH)/config/config.mak>
DIRS = client protocol
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,43 +0,0 @@
#
# 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.
#
#
CORE_DEPTH = ../..
DEPTH = ../..
DIRS = protocol client
#
# these dirs are not built at the moment
#
#NOBUILD_DIRS = jar

View File

@@ -1,3 +0,0 @@
obscure.h
rsrcids.h
ssmdefs.h

View File

@@ -1,74 +0,0 @@
#! gmake
#
# 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.
#
#######################################################################
# (1) Include initial platform-independent assignments (MANDATORY). #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "global" configuration information. (OPTIONAL) #
#######################################################################
include $(CORE_DEPTH)/coreconf/config.mk
#######################################################################
# (3) Include "component" configuration information. (OPTIONAL) #
#######################################################################
#######################################################################
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
include config.mk
#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
#######################################################################
include $(CORE_DEPTH)/coreconf/rules.mk
#######################################################################
# (6) Execute "component" rules. (OPTIONAL) #
#######################################################################
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -1,64 +0,0 @@
#! gmake
#
# 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.
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = protocol
MODULE = security
EXPORTS = \
protocol.h \
protocolf.h \
protocolport.h \
protocolnspr20.h \
protocolshr.h \
ssmdefs.h \
rsrcids.h \
messages.h \
newproto.h \
$(NULL)
CSRCS = newproto.c \
templates.c \
protocolshr.c \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,44 +0,0 @@
#
# 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.
#
#
# Override TARGETS variable so that only static libraries
# are specifed as dependencies within rules.mk.
#
TARGETS = $(LIBRARY)
SHARED_LIBRARY =
IMPORT_LIBRARY =
PURE_LIBRARY =
PROGRAM =

View File

@@ -1,124 +0,0 @@
#//
#// 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.
#//
IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build the ssl library
#//
#//------------------------------------------------------------------------
!if "$(MOZ_BITS)" == "16"
!ifndef MOZ_DEBUG
OPTIMIZER=-Os -UDEBUG -DNDEBUG
!endif
!endif
#//------------------------------------------------------------------------
#//
#// Specify the depth of the current directory relative to the
#// root of NS
#//
#//------------------------------------------------------------------------
DEPTH= ..\..\..\..
!ifndef MAKE_OBJ_TYPE
MAKE_OBJ_TYPE=EXE
!endif
#//------------------------------------------------------------------------
#//
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
#//
#//------------------------------------------------------------------------
LIBNAME=protocol
PDBFILE=$(LIBNAME).pdb
LINCS = -I$(PUBLIC)\security \
-I$(PUBLIC)\nspr \
-I$(DEPTH)\include \
-I..\include
!ifndef OS_CONFIG
OS_CONFIG = WIN$(MOZ_BITS)
!endif
LCFLAGS = -DEXPORT_VERSION -DLIB_BUILD
#//------------------------------------------------------------------------
#//
#// Define the files necessary to build the target (ie. OBJS)
#//
#//------------------------------------------------------------------------
OBJS= \
.\$(OBJDIR)\newproto.obj \
.\$(OBJDIR)\templates.obj \
.\$(OBJDIR)\protocolshr.obj \
$(NULL)
#//------------------------------------------------------------------------
#//
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
#// (these must be defined before the common makefiles are included)
#//
#//------------------------------------------------------------------------
LIBRARY=.\$(OBJDIR)\$(LIBNAME).lib
#//------------------------------------------------------------------------
#//
#// install headers
#//
#//------------------------------------------------------------------------
INSTALL_DIR=$(PUBLIC)\security
INSTALL_FILE_LIST= protocol.h \
protocolf.h \
protocolport.h \
protocolnspr20.h \
protocolshr.h \
ssmdefs.h \
rsrcids.h \
messages.h \
newproto.h \
$(NULL)
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
export:: INSTALL_FILES

View File

@@ -1,65 +0,0 @@
#
# 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.
#
CORE_DEPTH = ../../..
EXPORTS = \
protocol.h \
protocolf.h \
protocolport.h \
protocolnspr20.h \
protocolshr.h \
ssmdefs.h \
rsrcids.h \
messages.h \
newproto.h \
$(NULL)
MODULE = security
CSRCS = newproto.c \
protocolshr.c \
templates.c \
$(NULL)
ifeq ($(subst /,_,$(shell uname -s)),OS2)
CSRCS += os2_rand.c
endif
# mac_rand.c
# unix_rand.c
# win_rand.c
# prelib.c
REQUIRES = security dbm nspr
LIBRARY_NAME = protocol

View File

@@ -1,620 +0,0 @@
/* -*- 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.
*/
#ifndef __MESSAGES_H__
#define __MESSAGES_H__
#include "newproto.h"
typedef struct SingleNumMessage {
CMInt32 value;
} SingleNumMessage;
extern CMTMessageTemplate SingleNumMessageTemplate[];
typedef struct SingleStringMessage {
char *string;
} SingleStringMessage;
extern CMTMessageTemplate SingleStringMessageTemplate[];
typedef struct SingleItemMessage {
CMTItem item;
} SingleItemMessage;
extern CMTMessageTemplate SingleItemMessageTemplate[];
typedef struct HelloRequest {
CMInt32 version;
CMInt32 policy;
CMBool doesUI;
char *profile;
char* profileDir;
} HelloRequest;
extern CMTMessageTemplate HelloRequestTemplate[];
typedef struct HelloReply {
CMInt32 result;
CMInt32 sessionID;
CMInt32 version;
CMInt32 httpPort;
CMInt32 policy;
CMTItem nonce;
char *stringVersion;
} HelloReply;
extern CMTMessageTemplate HelloReplyTemplate[];
typedef struct SSLDataConnectionRequest {
CMInt32 flags;
CMInt32 port;
char *hostIP;
char *hostName;
CMBool forceHandshake;
CMTItem clientContext;
} SSLDataConnectionRequest;
extern CMTMessageTemplate SSLDataConnectionRequestTemplate[];
typedef struct TLSDataConnectionRequest {
CMInt32 port;
char* hostIP;
char* hostName;
} TLSDataConnectionRequest;
extern CMTMessageTemplate TLSDataConnectionRequestTemplate[];
typedef struct TLSStepUpRequest {
CMUint32 connID;
CMTItem clientContext;
} TLSStepUpRequest;
extern CMTMessageTemplate TLSStepUpRequestTemplate[];
typedef struct ProxyStepUpRequest {
CMUint32 connID;
CMTItem clientContext;
char* url;
} ProxyStepUpRequest;
extern CMTMessageTemplate ProxyStepUpRequestTemplate[];
typedef struct PKCS7DataConnectionRequest {
CMUint32 resID;
CMTItem clientContext;
} PKCS7DataConnectionRequest;
extern CMTMessageTemplate PKCS7DataConnectionRequestTemplate[];
typedef struct DataConnectionReply {
CMInt32 result;
CMInt32 connID;
CMInt32 port;
} DataConnectionReply;
extern CMTMessageTemplate DataConnectionReplyTemplate[];
typedef struct UIEvent {
CMInt32 resourceID;
CMInt32 width;
CMInt32 height;
CMBool isModal;
char *url;
CMTItem clientContext;
} UIEvent;
extern CMTMessageTemplate UIEventTemplate[];
extern CMTMessageTemplate OldUIEventTemplate[];
typedef struct TaskCompletedEvent {
CMInt32 resourceID;
CMInt32 numTasks;
CMInt32 result;
} TaskCompletedEvent;
extern CMTMessageTemplate TaskCompletedEventTemplate[];
typedef struct VerifyDetachedSigRequest {
CMInt32 pkcs7ContentID;
CMInt32 certUsage;
CMInt32 hashAlgID;
CMBool keepCert;
CMTItem hash;
} VerifyDetachedSigRequest;
extern CMTMessageTemplate VerifyDetachedSigRequestTemplate[];
typedef struct CreateSignedRequest {
CMInt32 scertRID;
CMInt32 ecertRID;
CMInt32 dig_alg;
CMTItem digest;
} CreateSignedRequest;
extern CMTMessageTemplate CreateSignedRequestTemplate[];
typedef struct CreateContentInfoReply {
CMInt32 ciRID;
CMInt32 result;
CMInt32 errorCode;
} CreateContentInfoReply;
extern CMTMessageTemplate CreateContentInfoReplyTemplate[];
typedef struct CreateEncryptedRequest {
CMInt32 scertRID;
CMInt32 nrcerts;
CMInt32 *rcertRIDs;
} CreateEncryptedRequest;
extern CMTMessageTemplate CreateEncryptedRequestTemplate[];
typedef struct CreateResourceRequest {
CMInt32 type;
CMTItem params;
} CreateResourceRequest;
extern CMTMessageTemplate CreateResourceRequestTemplate[];
typedef struct CreateResourceReply {
CMInt32 result;
CMInt32 resID;
} CreateResourceReply;
extern CMTMessageTemplate CreateResourceReplyTemplate[];
typedef struct GetAttribRequest {
CMInt32 resID;
CMInt32 fieldID;
} GetAttribRequest;
extern CMTMessageTemplate GetAttribRequestTemplate[];
typedef struct GetAttribReply {
CMInt32 result;
SSMAttributeValue value;
} GetAttribReply;
extern CMTMessageTemplate GetAttribReplyTemplate[];
typedef struct SetAttribRequest {
CMInt32 resID;
CMInt32 fieldID;
SSMAttributeValue value;
} SetAttribRequest;
extern CMTMessageTemplate SetAttribRequestTemplate[];
typedef struct PickleResourceReply {
CMInt32 result;
CMTItem blob;
} PickleResourceReply;
extern CMTMessageTemplate PickleResourceReplyTemplate[];
typedef struct UnpickleResourceRequest {
CMInt32 resourceType;
CMTItem resourceData;
} UnpickleResourceRequest;
extern CMTMessageTemplate UnpickleResourceRequestTemplate[];
typedef struct UnpickleResourceReply {
CMInt32 result;
CMInt32 resID;
} UnpickleResourceReply;
extern CMTMessageTemplate UnpickleResourceReplyTemplate[];
typedef struct PickleSecurityStatusReply {
CMInt32 result;
CMInt32 securityLevel;
CMTItem blob;
} PickleSecurityStatusReply;
extern CMTMessageTemplate PickleSecurityStatusReplyTemplate[];
typedef struct DupResourceReply {
CMInt32 result;
CMUint32 resID;
} DupResourceReply;
extern CMTMessageTemplate DupResourceReplyTemplate[];
typedef struct DestroyResourceRequest {
CMInt32 resID;
CMInt32 resType;
} DestroyResourceRequest;
extern CMTMessageTemplate DestroyResourceRequestTemplate[];
typedef struct VerifyCertRequest {
CMInt32 resID;
CMInt32 certUsage;
} VerifyCertRequest;
extern CMTMessageTemplate VerifyCertRequestTemplate[];
typedef struct AddTempCertToDBRequest {
CMInt32 resID;
char *nickname;
CMInt32 sslFlags;
CMInt32 emailFlags;
CMInt32 objSignFlags;
} AddTempCertToDBRequest;
extern CMTMessageTemplate AddTempCertToDBRequestTemplate[];
typedef struct MatchUserCertRequest {
CMInt32 certType;
CMInt32 numCANames;
char **caNames;
} MatchUserCertRequest;
extern CMTMessageTemplate MatchUserCertRequestTemplate[];
typedef struct MatchUserCertReply {
CMInt32 numCerts;
CMInt32 *certs;
} MatchUserCertReply;
extern CMTMessageTemplate MatchUserCertReplyTemplate[];
typedef struct EncodeCRMFReqRequest {
CMInt32 numRequests;
CMInt32 * reqIDs;
} EncodeCRMFReqRequest;
extern CMTMessageTemplate EncodeCRMFReqRequestTemplate[];
typedef struct CMMFCertResponseRequest {
char *nickname;
char *base64Der;
CMBool doBackup;
CMTItem clientContext;
} CMMFCertResponseRequest;
extern CMTMessageTemplate CMMFCertResponseRequestTemplate[];
typedef struct PasswordRequest {
CMInt32 tokenKey;
char *prompt;
CMTItem clientContext;
} PasswordRequest;
extern CMTMessageTemplate PasswordRequestTemplate[];
typedef struct PasswordReply {
CMInt32 result;
CMInt32 tokenID;
char * passwd;
} PasswordReply;
extern CMTMessageTemplate PasswordReplyTemplate[];
typedef struct KeyPairGenRequest {
CMInt32 keyGenCtxtID;
CMInt32 genMechanism;
CMInt32 keySize;
CMTItem params;
} KeyPairGenRequest;
extern CMTMessageTemplate KeyPairGenRequestTemplate[];
typedef struct DecodeAndCreateTempCertRequest {
CMInt32 type;
CMTItem cert;
} DecodeAndCreateTempCertRequest;
extern CMTMessageTemplate DecodeAndCreateTempCertRequestTemplate[];
typedef struct GenKeyOldStyleRequest {
char *choiceString;
char *challenge;
char *typeString;
char *pqgString;
} GenKeyOldStyleRequest;
extern CMTMessageTemplate GenKeyOldStyleRequestTemplate[];
typedef struct GenKeyOldStyleTokenRequest {
CMInt32 rid;
CMInt32 numtokens;
char ** tokenNames;
} GenKeyOldStyleTokenRequest;
extern CMTMessageTemplate GenKeyOldStyleTokenRequestTemplate[];
typedef struct GenKeyOldStyleTokenReply {
CMInt32 rid;
CMBool cancel;
char * tokenName;
} GenKeyOldStyleTokenReply;
extern CMTMessageTemplate GenKeyOldStyleTokenReplyTemplate[];
typedef struct GenKeyOldStylePasswordRequest {
CMInt32 rid;
char * tokenName;
CMBool internal;
CMInt32 minpwdlen;
CMInt32 maxpwdlen;
} GenKeyOldStylePasswordRequest;
extern CMTMessageTemplate GenKeyOldStylePasswordRequestTemplate[];
typedef struct GenKeyOldStylePasswordReply {
CMInt32 rid;
CMBool cancel;
char * password;
} GenKeyOldStylePasswordReply;
extern CMTMessageTemplate GenKeyOldStylePasswordReplyTemplate[];
typedef struct GetKeyChoiceListRequest {
char *type;
char *pqgString;
} GetKeyChoiceListRequest;
extern CMTMessageTemplate GetKeyChoiceListRequestTemplate[];
typedef struct GetKeyChoiceListReply {
CMInt32 nchoices;
char **choices;
} GetKeyChoiceListReply;
extern CMTMessageTemplate GetKeyChoiceListReplyTemplate[];
typedef struct AddNewSecurityModuleRequest {
char *moduleName;
char *libraryPath;
CMInt32 pubMechFlags;
CMInt32 pubCipherFlags;
} AddNewSecurityModuleRequest;
extern CMTMessageTemplate AddNewSecurityModuleRequestTemplate[];
typedef struct FilePathRequest {
CMInt32 resID;
char *prompt;
CMBool getExistingFile;
char *fileRegEx;
} FilePathRequest;
extern CMTMessageTemplate FilePathRequestTemplate[];
typedef struct FilePathReply {
CMInt32 resID;
char *filePath;
} FilePathReply;
extern CMTMessageTemplate FilePathReplyTemplate[];
typedef struct PasswordPromptReply {
CMInt32 resID;
char *promptReply;
} PasswordPromptReply;
extern CMTMessageTemplate PasswordPromptReplyTemplate[];
typedef struct SignTextRequest {
CMInt32 resID;
char *stringToSign;
char *hostName;
char *caOption;
CMInt32 numCAs;
char** caNames;
} SignTextRequest;
extern CMTMessageTemplate SignTextRequestTemplate[];
typedef struct GetLocalizedTextReply {
CMInt32 whichString;
char *localizedString;
} GetLocalizedTextReply;
extern CMTMessageTemplate GetLocalizedTextReplyTemplate[];
typedef struct ImportCertReply {
CMInt32 result;
CMInt32 resID;
} ImportCertReply;
extern CMTMessageTemplate ImportCertReplyTemplate[];
typedef struct PromptRequest {
CMInt32 resID;
char *prompt;
CMTItem clientContext;
} PromptRequest;
extern CMTMessageTemplate PromptRequestTemplate[];
typedef struct PromptReply {
CMInt32 resID;
CMBool cancel;
char *promptReply;
} PromptReply;
extern CMTMessageTemplate PromptReplyTemplate[];
typedef struct RedirectCompareReqeust {
CMTItem socketStatus1Data;
CMTItem socketStatus2Data;
} RedirectCompareRequest;
extern CMTMessageTemplate RedirectCompareRequestTemplate[];
typedef struct DecodeAndAddCRLRequest {
CMTItem derCrl;
CMUint32 type;
char *url;
} DecodeAndAddCRLRequest;
extern CMTMessageTemplate DecodeAndAddCRLRequestTemplate[];
typedef struct SecurityAdvisorRequest {
CMInt32 infoContext;
CMInt32 resID;
char * hostname;
char * senderAddr;
CMUint32 encryptedP7CInfo;
CMUint32 signedP7CInfo;
CMInt32 decodeError;
CMInt32 verifyError;
CMBool encryptthis;
CMBool signthis;
CMInt32 numRecipients;
char ** recipients;
} SecurityAdvisorRequest;
extern CMTMessageTemplate SecurityAdvisorRequestTemplate[];
/* "SecurityConfig" javascript related message templates */
typedef struct SCAddTempCertToPermDBRequest {
CMTItem certKey;
char* trustStr;
char* nickname;
} SCAddTempCertToPermDBRequest;
extern CMTMessageTemplate SCAddTempCertToPermDBRequestTemplate[];
typedef struct SCDeletePermCertsRequest {
CMTItem certKey;
CMBool deleteAll;
} SCDeletePermCertsRequest;
extern CMTMessageTemplate SCDeletePermCertsRequestTemplate[];
typedef struct TimeMessage {
CMInt32 year;
CMInt32 month;
CMInt32 day;
CMInt32 hour;
CMInt32 minute;
CMInt32 second;
} TimeMessage;
extern CMTMessageTemplate TimeMessageTemplate[];
typedef struct CertEnumElement {
char* name;
CMTItem certKey;
} CertEnumElement;
typedef struct SCCertIndexEnumReply {
int length;
CertEnumElement* list;
} SCCertIndexEnumReply;
extern CMTMessageTemplate SCCertIndexEnumReplyTemplate[];
/* Test message */
typedef struct TestListElement {
char * name;
char * value;
} TestListElement;
typedef struct TestList {
char *listName;
int numElements;
TestListElement *elements;
} TestList;
extern CMTMessageTemplate TestListTemplate[];
/* Preference-related structs */
typedef struct SetPrefElement {
char* key;
char* value;
CMInt32 type;
} SetPrefElement;
typedef struct SetPrefListMessage {
int length;
SetPrefElement* list;
} SetPrefListMessage;
extern CMTMessageTemplate SetPrefListMessageTemplate[];
typedef struct GetPrefElement {
char* key;
CMInt32 type;
} GetPrefElement;
typedef struct GetPrefListRequest {
int length;
GetPrefElement* list;
} GetPrefListRequest;
extern CMTMessageTemplate GetPrefListRequestTemplate[];
typedef struct GetCertExtension {
CMUint32 resID;
CMUint32 extension;
} GetCertExtension;
extern CMTMessageTemplate GetCertExtensionTemplate[];
typedef struct HTMLCertInfoRequest {
CMUint32 certID;
CMUint32 showImages;
CMUint32 showIssuer;
} HTMLCertInfoRequest;
extern CMTMessageTemplate HTMLCertInfoRequestTemplate[];
typedef struct EncryptRequestMessage
{
CMTItem keyid; /* May have length 0 for default */
CMTItem data;
CMTItem ctx; /* serialized void* ptr */
} EncryptRequestMessage;
extern CMTMessageTemplate EncryptRequestTemplate[];
typedef struct SingleItemMessage EncryptReplyMessage;
#define EncryptReplyTemplate SingleItemMessageTemplate
typedef struct DecryptRequestMessage
{
CMTItem data;
CMTItem ctx; /* serialized void* ptr */
} DecryptRequestMessage;
extern CMTMessageTemplate DecryptRequestTemplate[];
typedef struct SingleItemMessage DecryptReplyMessage;
#define DecryptReplyTemplate SingleItemMessageTemplate
#endif /* __MESSAGES_H__ */

View File

@@ -1,602 +0,0 @@
/* -*- 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.
*/
#include <string.h>
#include <assert.h>
#ifdef WIN32
#include <winsock.h>
#endif
#ifdef XP_MAC
#include "macsocket.h"
#endif
#include "newproto.h"
char SSMVersionString[] = "1.1";
CMT_Alloc_fn cmt_alloc = malloc;
CMT_Free_fn cmt_free = free;
#define ASSERT(x) assert(x)
#define CM_ntohl ntohl
#define CM_htonl htonl
/*************************************************************
*
* CMT_Init
*
*
************************************************************/
void
CMT_Init(CMT_Alloc_fn allocfn, CMT_Free_fn freefn)
{
cmt_alloc = allocfn;
cmt_free = freefn;
}
static CMTStatus
decode_int(unsigned char **curptr, void *dest, CMInt32 *remaining)
{
CMInt32 datalen = sizeof(CMInt32);
if (*remaining < datalen)
return CMTFailure;
*(CMInt32 *)dest = ntohl(**(CMInt32 **)curptr);
*remaining -= datalen;
*curptr += datalen;
return CMTSuccess;
}
static CMTStatus
decode_string(unsigned char **curptr, CMInt32 *len,
unsigned char **data, CMInt32 *remaining)
{
CMTStatus rv;
CMInt32 datalen;
rv = decode_int(curptr, len, remaining);
if (rv != CMTSuccess)
return CMTFailure;
/* NULL string */
if (*len == 0) {
*data = NULL;
goto done;
}
datalen = (*len + 3) & ~3;
if (*remaining < datalen)
return CMTFailure;
*data = (unsigned char *) cmt_alloc(*len + 1);
if (*data == NULL)
return CMTFailure;
memcpy(*data, *curptr, *len);
(*data)[*len] = 0;
*remaining -= datalen;
*curptr += datalen;
done:
return CMTSuccess;
}
/*************************************************************
* CMT_DecodeMessage
*
* Decode msg into dest as specified by tmpl.
*
************************************************************/
CMTStatus
CMT_DecodeMessage(CMTMessageTemplate *tmpl, void *dest, CMTItem *msg)
{
unsigned char *curptr, *destptr, *list;
void ** ptr;
CMInt32 remaining, len, choiceID = 0, listSize, listCount = 0;
CMBool inChoice = CM_FALSE, foundChoice = CM_FALSE, inList = CM_FALSE;
CMInt32 listItemSize = 0;
CMTStatus rv = CMTSuccess;
CMTMessageTemplate *startOfList, *p;
CMBool inStructList = CM_FALSE;
curptr = msg->data;
remaining = msg->len;
while(tmpl->type != CMT_DT_END) {
/* XXX Maybe this should be a more formal state machine? */
if (inChoice) {
if (tmpl->type == CMT_DT_END_CHOICE) {
if (!foundChoice)
goto loser;
inChoice = CM_FALSE;
foundChoice = CM_FALSE;
tmpl++;
continue;
}
if (choiceID != tmpl->choiceID) {
tmpl++;
continue; /* Not this option */
} else {
foundChoice = CM_TRUE;
}
}
if (inList) {
destptr = &list[listCount * listItemSize];
listCount++;
} else {
if (inStructList) {
destptr = tmpl->offset + list;
} else {
destptr = tmpl->offset + (unsigned char *)dest;
}
}
switch (tmpl->type) {
case CMT_DT_RID:
case CMT_DT_INT:
case CMT_DT_BOOL:
rv = decode_int(&curptr, destptr, &remaining);
if (rv != CMTSuccess)
goto loser;
break;
case CMT_DT_STRING:
rv = decode_string(&curptr, &len, (unsigned char **)destptr,
&remaining);
if (rv != CMTSuccess)
goto loser;
break;
case CMT_DT_ITEM:
rv = decode_string(&curptr, (long *) &((CMTItem *)destptr)->len,
&((CMTItem *)destptr)->data, &remaining);
if (rv != CMTSuccess)
goto loser;
break;
case CMT_DT_LIST:
/* XXX This is too complicated */
rv = decode_int(&curptr, destptr, &remaining);
if (rv != CMTSuccess)
goto loser;
listSize = *(CMInt32 *)destptr;
tmpl++;
if (tmpl->type == CMT_DT_STRING) {
listItemSize = sizeof(unsigned char *);
} else if (tmpl->type == CMT_DT_ITEM) {
listItemSize = sizeof(CMTItem);
} else {
listItemSize = sizeof(CMInt32);
}
if (listSize == 0) {
list = NULL;
} else {
list = (unsigned char *) cmt_alloc(listSize * listItemSize);
}
*(void **)(tmpl->offset + (unsigned char *)dest) = list;
inList = CM_TRUE;
listCount = 0;
break;
case CMT_DT_STRUCT_LIST:
/* XXX This is too complicated */
rv = decode_int(&curptr, destptr, &remaining);
if (rv != CMTSuccess)
goto loser;
listSize = *(CMInt32 *)destptr;
tmpl++;
if (tmpl->type != CMT_DT_STRUCT_PTR) {
goto loser;
}
ptr = (void**)(tmpl->offset + (unsigned char *)dest);
startOfList = tmpl;
p = tmpl;
listItemSize = 0;
while (p->type != CMT_DT_END_STRUCT_LIST) {
if (p->type == CMT_DT_STRING) {
listItemSize += sizeof(unsigned char *);
} else if (p->type == CMT_DT_ITEM) {
listItemSize += sizeof(CMTItem);
} else if (p->type == CMT_DT_INT) {
listItemSize += sizeof(CMInt32);
}
p++;
}
if (listSize == 0) {
list = NULL;
} else {
list = (unsigned char *) cmt_alloc(listSize * listItemSize);
}
*ptr = list;
inStructList = CM_TRUE;
listCount = 0;
break;
case CMT_DT_END_STRUCT_LIST:
listCount++;
if (listCount == listSize) {
inStructList = CM_FALSE;
} else {
list += listItemSize;
tmpl = startOfList;
}
break;
case CMT_DT_CHOICE:
rv = decode_int(&curptr, destptr, &remaining);
if (rv != CMTSuccess)
goto loser;
choiceID = *(CMInt32 *)destptr;
inChoice = CM_TRUE;
foundChoice = CM_FALSE;
break;
case CMT_DT_END_CHOICE: /* Loop should exit before we see these. */
case CMT_DT_END:
default:
ASSERT(0);
break;
}
if (inList) {
if (listCount == listSize) {
inList = CM_FALSE;
tmpl++;
}
} else {
tmpl++;
}
}
loser:
/* Free the data buffer */
if (msg->data) {
cmt_free(msg->data);
msg->data = NULL;
}
return rv;
}
static CMTStatus
calc_msg_len(CMTMessageTemplate *tmpl, void *src, CMInt32 *len_out)
{
CMInt32 len = 0, choiceID = 0, listSize, listItemSize, listCount;
unsigned char *srcptr, *list;
CMBool inChoice = CM_FALSE, inList = CM_FALSE, foundChoice = CM_FALSE;
CMTMessageTemplate *startOfList, *p;
CMBool inStructList = CM_FALSE;
while(tmpl->type != CMT_DT_END) {
if (inChoice) {
if (tmpl->type == CMT_DT_END_CHOICE) {
if (!foundChoice)
goto loser;
inChoice = CM_FALSE;
foundChoice = CM_FALSE;
tmpl++;
continue;
}
if (choiceID != tmpl->choiceID) {
tmpl++;
continue; /* Not this option */
} else {
foundChoice = CM_TRUE;
}
}
if (inList) {
srcptr = &list[listCount * listItemSize];
listCount++;
} else if (inStructList) {
srcptr = tmpl->offset + list;
} else {
srcptr = tmpl->offset + (unsigned char *)src;
}
switch(tmpl->type) {
case CMT_DT_RID:
case CMT_DT_INT:
case CMT_DT_BOOL:
len += sizeof(CMInt32);
break;
case CMT_DT_STRING:
len += sizeof(CMInt32);
/* Non NULL string */
if (*(char**)srcptr) {
len += (strlen(*(char**)srcptr) + 4) & ~3;
}
break;
case CMT_DT_ITEM:
len += sizeof(CMInt32);
len += (((CMTItem *)srcptr)->len + 3) & ~3;
break;
case CMT_DT_LIST:
len += sizeof(CMInt32);
listSize = *(CMInt32 *)srcptr;
tmpl++;
if (tmpl->type == CMT_DT_STRING) {
listItemSize = sizeof(unsigned char *);
} else if (tmpl->type == CMT_DT_ITEM) {
listItemSize = sizeof(CMTItem);
} else {
listItemSize = sizeof(CMInt32);
}
list = *(unsigned char **)(tmpl->offset + (unsigned char *)src);
listCount = 0;
inList = CM_TRUE;
break;
case CMT_DT_STRUCT_LIST:
len += sizeof(CMInt32);
listSize = *(CMInt32 *)srcptr;
tmpl++;
if (tmpl->type != CMT_DT_STRUCT_PTR) {
goto loser;
}
list = *(unsigned char**)(tmpl->offset + (unsigned char*)src);
startOfList = tmpl;
p = tmpl;
listItemSize = 0;
while (p->type != CMT_DT_END_STRUCT_LIST) {
if (p->type == CMT_DT_STRING) {
listItemSize += sizeof(unsigned char *);
} else if (p->type == CMT_DT_ITEM) {
listItemSize += sizeof(CMTItem);
} else if (p->type == CMT_DT_INT) {
listItemSize += sizeof(CMInt32);
}
p++;
}
listCount = 0;
inStructList = CM_TRUE;
break;
case CMT_DT_END_STRUCT_LIST:
listCount++;
if (listCount == listSize) {
inStructList = CM_FALSE;
} else {
list += listItemSize;
tmpl = startOfList;
}
break;
case CMT_DT_CHOICE:
len += sizeof(CMInt32);
choiceID = *(CMInt32 *)srcptr;
inChoice = CM_TRUE;
foundChoice = CM_FALSE;
break;
case CMT_DT_END_CHOICE: /* Loop should exit before we see these. */
case CMT_DT_END:
default:
ASSERT(0);
break;
}
if (inList) {
if (listCount == listSize) {
inList = CM_FALSE;
tmpl++;
}
} else {
tmpl++;
}
}
*len_out = len;
return CMTSuccess;
loser:
return CMTFailure;
}
static CMTStatus
encode_int(unsigned char **curptr, void *src, CMInt32 *remaining)
{
CMInt32 datalen = sizeof(CMInt32);
if (*remaining < datalen)
return CMTFailure;
**(CMInt32 **)curptr = CM_htonl(*(CMInt32 *)src);
*remaining -= datalen;
*curptr += datalen;
return CMTSuccess;
}
static CMTStatus
encode_string(unsigned char **curptr, CMInt32 len,
unsigned char *data, CMInt32 *remaining)
{
CMTStatus rv;
CMInt32 datalen;
rv = encode_int(curptr, &len, remaining);
if (rv != CMTSuccess)
return CMTFailure;
/* NULL string */
if (len == 0) {
goto done;
}
datalen = (len + 3) & ~3;
if (*remaining < datalen)
return CMTFailure;
memcpy(*curptr, data, len);
*remaining -= datalen;
*curptr += datalen;
done:
return CMTSuccess;
}
/*************************************************************
* CMT_EncodeMessage
*
* Encode src into msg as specified by tmpl.
*
************************************************************/
CMTStatus
CMT_EncodeMessage(CMTMessageTemplate *tmpl, CMTItem *msg, void *src)
{
CMInt32 choiceID = 0, listSize, listItemSize, listCount, remaining;
unsigned char *srcptr, *curptr, *list;
CMBool inChoice = CM_FALSE, inList = CM_FALSE, foundChoice = CM_FALSE;
CMTStatus rv = CMTSuccess;
CMTMessageTemplate *startOfList, *p;
CMBool inStructList = CM_FALSE;
rv = calc_msg_len(tmpl, src, (long *) &msg->len);
if (rv != CMTSuccess)
goto loser;
curptr = msg->data = (unsigned char *) cmt_alloc(msg->len);
if(msg->data == NULL)
goto loser;
remaining = msg->len;
while(tmpl->type != CMT_DT_END) {
if (inChoice) {
if (tmpl->type == CMT_DT_END_CHOICE) {
if (!foundChoice)
goto loser;
inChoice = CM_FALSE;
foundChoice = CM_FALSE;
tmpl++;
continue;
}
if (choiceID != tmpl->choiceID) {
tmpl++;
continue; /* Not this option */
} else {
foundChoice = CM_TRUE;
}
}
if (inList) {
srcptr = &list[listCount * listItemSize];
listCount++;
} else {
if (inStructList) {
srcptr = tmpl->offset + list;
} else {
srcptr = tmpl->offset + (unsigned char *)src;
}
}
switch(tmpl->type) {
case CMT_DT_RID:
case CMT_DT_INT:
case CMT_DT_BOOL:
rv = encode_int(&curptr, srcptr, &remaining);
if (rv != CMTSuccess)
goto loser;
break;
case CMT_DT_STRING:
if (*(char**)srcptr) {
/* Non NULL string */
rv = encode_string(&curptr, (long) strlen(*(char**)srcptr),
*(unsigned char**)srcptr, &remaining);
} else {
/* NULL string */
rv = encode_string(&curptr, 0L, *(unsigned char**)srcptr, &remaining);
}
if (rv != CMTSuccess)
goto loser;
break;
case CMT_DT_ITEM:
rv = encode_string(&curptr, ((CMTItem *)srcptr)->len,
((CMTItem *)srcptr)->data, &remaining);
if (rv != CMTSuccess)
goto loser;
break;
case CMT_DT_LIST:
rv = encode_int(&curptr, srcptr, &remaining);
if (rv != CMTSuccess)
goto loser;
listSize = *(CMInt32 *)srcptr;
tmpl++;
if (tmpl->type == CMT_DT_STRING) {
listItemSize = sizeof(unsigned char *);
} else if (tmpl->type == CMT_DT_ITEM) {
listItemSize = sizeof(CMTItem);
} else {
listItemSize = sizeof(CMInt32);
}
list = *(unsigned char **)(tmpl->offset + (unsigned char *)src);
listCount = 0;
inList = CM_TRUE;
break;
case CMT_DT_STRUCT_LIST:
rv = encode_int(&curptr, srcptr, &remaining);
if (rv != CMTSuccess)
goto loser;
listSize = *(CMInt32 *)srcptr;
tmpl++;
if (tmpl->type != CMT_DT_STRUCT_PTR) {
goto loser;
}
list = *(unsigned char**)(tmpl->offset + (unsigned char*)src);
startOfList = tmpl;
p = tmpl;
listItemSize = 0;
while (p->type != CMT_DT_END_STRUCT_LIST) {
if (p->type == CMT_DT_STRING) {
listItemSize += sizeof(unsigned char *);
} else if (p->type == CMT_DT_ITEM) {
listItemSize += sizeof(CMTItem);
} else if (p->type == CMT_DT_INT) {
listItemSize += sizeof(CMInt32);
}
p++;
}
listCount = 0;
inStructList = CM_TRUE;
break;
case CMT_DT_END_STRUCT_LIST:
listCount++;
if (listCount == listSize) {
inStructList = CM_FALSE;
} else {
list += listItemSize;
tmpl = startOfList;
}
break;
case CMT_DT_CHOICE:
rv = encode_int(&curptr, srcptr, &remaining);
if (rv != CMTSuccess)
goto loser;
choiceID = *(CMInt32 *)srcptr;
inChoice = CM_TRUE;
foundChoice = CM_FALSE;
break;
case CMT_DT_END_CHOICE: /* Loop should exit before we see these. */
case CMT_DT_END:
default:
ASSERT(0);
break;
}
if (inList) {
if (listCount == listSize) {
inList = CM_FALSE;
tmpl++;
}
} else {
tmpl++;
}
}
return CMTSuccess;
loser:
return CMTFailure;
}

View File

@@ -1,102 +0,0 @@
/* -*- 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.
*/
#ifndef __NEWPROTO_H__
#define __NEWPROTO_H__
#include <stdlib.h>
#include "ssmdefs.h"
typedef enum CMTDataType {
CMT_DT_END,
CMT_DT_RID,
CMT_DT_INT,
CMT_DT_BOOL,
CMT_DT_STRING,
CMT_DT_ITEM,
CMT_DT_LIST,
CMT_DT_CHOICE,
CMT_DT_END_CHOICE,
CMT_DT_STRUCT_LIST,
CMT_DT_END_STRUCT_LIST,
CMT_DT_STRUCT_PTR
} CMTDataType;
typedef struct CMTMessageTemplate {
CMTDataType type;
CMUint32 offset;
CMInt32 validator;
CMInt32 choiceID;
} CMTMessageTemplate;
typedef struct CMTMessageHeader {
CMInt32 type;
CMInt32 len;
} CMTMessageHeader;
typedef void *(* CMT_Alloc_fn) (size_t size);
typedef void (* CMT_Free_fn)(void * ptr);
extern CMT_Alloc_fn cmt_alloc;
extern CMT_Free_fn cmt_free;
/*************************************************************
*
* CMT_Init
*
*
************************************************************/
void
CMT_Init(CMT_Alloc_fn allocfn, CMT_Free_fn freefn);
/*************************************************************
* CMT_DecodeMessage
*
* Decode msg into dest as specified by tmpl.
*
************************************************************/
CMTStatus
CMT_DecodeMessage(CMTMessageTemplate *tmpl, void *dest, CMTItem *msg);
/*************************************************************
* CMT_EncodeMessage
*
* Encode src into msg as specified by tmpl.
*
************************************************************/
CMTStatus
CMT_EncodeMessage(CMTMessageTemplate *tmpl, CMTItem *msg, void *src);
#endif /* __NEWPROTO_H__ */

View File

@@ -1,187 +0,0 @@
/*
* 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.
*/
/* SAMPLE CODE
** Illustrates use of SSMObscure object methods.
**
** Author: Nelson Bolyard June 1999
*/
#include <stdio.h>
#include "obscure.h"
/* On error, returns -1.
** On success, returns non-negative number of unobscured bytes in buf
int
RecvInitObscureData(int fd, SSMObscureObject * obj, void * buf, int bufSize )
{
SSMObscureBool done = 0;
do {
int cc;
int rv;
cc = read(fd, buf, bufSize);
if (cc <= 0)
return -1;
rv = SSMObscure_RecvInit(obj, buf, cc, &done);
} while (!done);
return rv;
}
/* returns -1 on error, 0 on success. */
int
SendInitObscureData(int fd, SSMObscureObject * obj)
{
unsigned char * initBuf = NULL;
int rv = -1;
do {
int bufLen;
int len;
int cc;
bufLen = SSMObscure_SendInit(obj, NULL);
if (bufLen <= 0)
break;
initBuf = malloc(bufLen);
if (!initBuf)
break;
len = SSMObscure_SendInit(obj, initBuf);
if (len != bufLen)
break;
cc = write(fd, initBuf, len);
/* Note, this code assumes a blocking socket,
** and hence doesn't deal with short writes.
*/
if (cc < len)
break;
rv = 0;
} while (0);
if (initBuf) {
free(initBuf);
initBuf = NULL;
}
return rv;
}
/* This is like write, but it obscures the data first. */
/* This code assumes a blocking socket, and so it doesn't handle short
** writes.
*/
int
obscuredWrite(SSMObscureObject * obj, int fd, void * buf, int len)
{
int rv;
int cc;
cc = SSMObscure_Send(obj, buf, len);
if (cc <= 0)
return cc;
rv = write(fd, buf, cc);
ASSERT(rv == cc || rv < 0);
return rv;
}
/* This is like read, but it unobscures the data after reading it. */
int
obscuredRead(SSMObscureObject * obj, int fd, void * buf, int len)
{
int rv;
int cc;
do {
cc = read(fd, buf, len);
if (cc <= 0)
return cc;
rv = SSMObscure_Recv(obj, buf, len);
} while (rv == 0);
return rv;
}
SSMObscureObject * sobj;
unsigned char buf[8192];
/* Call this with fd for socket that has just been accepted.
** returns -1 on error,
** On success, returns non-negative number of bytes received in buf.
*/
int
InitClientObscureObject(int fd)
{
int rv;
sobj = SSMObscure_Create(0);
if (!sobj)
return -1;
rv = SendInitObscureData(fd, sobj);
if (rv < 0)
return rv;
rv = RecvInitObscureData(fd, sobj, buf, sizeof buf);
return rv;
}
/* Call this with fd for socket that has just been connected.
** returns -1 on error,
** On success, returns non-negative number of bytes received in buf.
*/
int
InitServerObscureObject(int fd)
{
int cc;
sobj = SSMObscure_Create(1);
if (!sobj)
return -1;
cc = RecvInitObscureData(fd, sobj, buf, sizeof buf);
if (cc < 0)
return cc;
rv = SendInitObscureData(fd, sobj);
if (rv < 0)
return rv;
return cc;
}

View File

@@ -1,136 +0,0 @@
/*
* 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.
*/
#include <stdlib.h>
#include "obspriv.h"
#include "newproto.h"
/*
** Create a new Obscuring object
*/
SSMObscureObject *
SSMObscure_Create(SSMObscureBool IsServer)
{
SSMObscureObject * obj;
void * priv;
obj = (SSMObscureObject *) cmt_alloc(sizeof *obj);
if (!obj)
return obj;
/* This needs to be a little more elegant */
priv = SSMObscure_InitPrivate(obj, IsServer);
if (!priv) {
cmt_free(obj);
return NULL;
}
obj->privData = priv;
return obj;
}
/* Prepare initial buffer with initial message to send to other side to
** establish cryptographic * synchronization.
**
** If buf is NULL, function returns the size of the buffer that
** the caller needs to allocate for sending the initial message.
**
** If buf is non-null, function returns the number of bytes of data filled
** into buf, the amount that the caller should then send to the other side.
**
*/
int
SSMObscure_SendInit( SSMObscureObject * obj, void * buf)
{
int rv;
rv = obj->sendInit(obj->privData, buf);
return rv;
}
/*
** Obscure "len" bytes in "buf" before sending it.
*/
int
SSMObscure_Send( SSMObscureObject * obj,
void * buf,
unsigned int len)
{
int rv;
rv = obj->send(obj->privData, buf, len);
return rv;
}
/*
** UnObscure "len" bytes in "buf" after receiving it.
** This function may absorb some or all of the received bytes, leaving
** fewer bytes (possibly none) in the buffer for the application to use
** than were in the buffer when the function was called.
** Function returns the number of bytes of unobscured data remaining in
** buf. Zero means all data was used internally and no data remains
** for application use. Negative number means error occurred.
*/
int
SSMObscure_Recv( SSMObscureObject * obj,
void * buf,
unsigned int len)
{
int rv;
rv = obj->recv(obj->privData, buf, len);
return rv;
}
/* like _Recv, but returns a flag telling when all initialization info has
** been received.
*/
int
SSMObscure_RecvInit( SSMObscureObject * obj,
void * buf,
unsigned int len,
SSMObscureBool * done)
{
int rv;
rv = obj->recvInit(obj->privData, buf, len, done);
return rv;
}
/*
** Destroy the Obscure Object
*/
int
SSMObscure_Destroy(SSMObscureObject * obj)
{
int rv;
rv = obj->destroy(obj->privData);
cmt_free(obj);
return rv;
}

View File

@@ -1,98 +0,0 @@
/*
* 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 __obscure_h__
#define __obscure_h__ 1
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned char SSMObscureBool;
typedef struct SSMObscureObjectStr SSMObscureObject;
/*
** Create a new Obscuring object
*/
extern SSMObscureObject * SSMObscure_Create(SSMObscureBool IsServer);
/* Prepare initial buffer with initial message to send to other side to
** establish cryptographic * synchronization.
**
** If buf is NULL, function returns the size of the buffer that
** the caller needs to allocate for sending the initial message.
**
** If buf is non-null, function returns the number of bytes of data filled
** into buf, the amount that the caller should then send to the other side.
**
*/
extern int SSMObscure_SendInit( SSMObscureObject * obj,
void * buf);
/*
** Obscure "len" bytes in "buf" before sending it.
*/
extern int SSMObscure_Send( SSMObscureObject * obj,
void * buf,
unsigned int len);
/*
** UnObscure "len" bytes in "buf" after receiving it.
** This function may absorb some or all of the received bytes, leaving
** fewer bytes (possibly none) in the buffer for the application to use
** than were in the buffer when the function was called.
** Function returns the number of bytes of unobscured data remaining in
** buf. Zero means all data was used internally and no data remains
** for application use. Negative number means error occurred.
*/
extern int SSMObscure_Recv( SSMObscureObject * obj,
void * buf,
unsigned int len);
/* like _Recv, but returns a flag telling when all initialization info has
** been received.
*/
extern int SSMObscure_RecvInit( SSMObscureObject * obj,
void * buf,
unsigned int len,
SSMObscureBool * done);
/*
** Destroy the Obscure Object
*/
extern int SSMObscure_Destroy(SSMObscureObject * obj);
#ifdef __cplusplus
}
#endif
#endif /* __obscure_h__ */

View File

@@ -1,115 +0,0 @@
/*
* 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.
*/
#include "obspriv.h"
#include "newproto.h"
#include <string.h>
#include <assert.h>
#include <time.h>
/*
Originally this code was used to obscure the control messages
traveling between processes. With the relaxation of export rules,
this whole step is no longer necessary, and is included for
informational purposes only. (We need to finish removing the
obscuring code.)
*/
struct obscureNOPStr {
SSMObscureObject * obj;
};
typedef struct obscureNOPStr obscureV1;
static int
ssmObscure_Destroy(void * privData)
{
obscureV1 * priv = (obscureV1 *)privData;
memset(priv, 0, sizeof *priv);
cmt_free(priv);
return 0;
}
static int
ssmObscure_Send(void * privData, void * buf, unsigned int len)
{
/* obscureV1 * priv = (obscureV1 *)privData;*/
/* NOP */
return len;
}
static int
ssmObscure_Recv(void * privData, void * buf, unsigned int len)
{
/*obscureV1 * priv = (obscureV1 *)privData;*/
/* NOP */
return len;
}
static int
ssmObscure_SendInit(void * privData, void * buf)
{
/*obscureV1 * priv = (obscureV1 *)privData;*/
return 0;
}
static int
ssmObscure_RecvInit(void * privData, void * buf, unsigned int len,
SSMObscureBool * pDone)
{
return 0;
}
static void *
ssmObscure_InitPrivate(SSMObscureObject * obj, SSMObscureBool IsServer)
{
obscureV1 * priv = (obscureV1 *) cmt_alloc(sizeof (obscureV1));
if (!priv)
return NULL;
priv->obj = obj;
obj->privData = (void *)priv;
obj->destroy = ssmObscure_Destroy;
obj->send = ssmObscure_Send;
obj->recv = ssmObscure_Recv;
obj->sendInit = ssmObscure_SendInit;
obj->recvInit = ssmObscure_RecvInit;
return priv;
}
obsInitFn SSMObscure_InitPrivate = ssmObscure_InitPrivate;

View File

@@ -1,63 +0,0 @@
/*
* 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.
*/
#include "obscure.h"
typedef void * (* obsInitFn) (SSMObscureObject * instance,
SSMObscureBool IsServer);
typedef int (* obsDestroyFn) (void * priv);
typedef int (* obsSendFn) (void * priv, void * buf, unsigned int len);
typedef int (* obsRecvFn) (void * priv, void * buf, unsigned int len);
typedef int (* obsSendInitFn)(void * priv, void * buf);
typedef int (* obsRecvInitFn)(void * priv, void * buf, unsigned int len,
SSMObscureBool * done);
struct SSMObscureObjectStr {
void * privData;
obsDestroyFn destroy;
obsSendFn send;
obsRecvFn recv;
obsSendInitFn sendInit;
obsRecvInitFn recvInit;
};
/* This is common to the beginning of all versions of the obscuring protocol */
struct SSMInitMsgHdrStr {
short version;
short length;
};
typedef struct SSMInitMsgHdrStr SSMInitMsgHdr;
extern obsInitFn SSMObscure_InitPrivate;

View File

@@ -1,141 +0,0 @@
/*
* 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.
*/
/*
protocol.h - Definitions of various items to support the PSM protocol.
*/
#ifndef __PROTOCOL_H__
#define __PROTOCOL_H__
#include "rsrcids.h"
#define SSMPRStatus SSMStatus
#define SSMPR_SUCCESS SSM_SUCCESS
#define SSMPR_FAILURE SSM_FAILURE
#define SSMPR_INVALID_ARGUMENT_ERROR PR_INVALID_ARGUMENT_ERROR
#define SSMPR_OUT_OF_MEMORY_ERROR PR_OUT_OF_MEMORY_ERROR
#define SSMPRInt32 PRInt32
#define SSMPRUint32 PRUint32
#define SSMPR_ntohl PR_ntohl
#define SSMPR_htonl PR_htonl
#define SSMPORT_Free PORT_Free
#define SSMPORT_ZAlloc PORT_ZAlloc
#define SSMPR_SetError PR_SetError
#define SSMPR_GetError PR_GetError
#define SSMPORT_SetError PORT_SetError
#define SSMPORT_GetError PORT_GetError
/*
Current version of PSM protocol.
Increment this value when the protocol changes.
*/
#define SSMSTRING_PADDED_LENGTH(x) ((((x)+3)/4)*4)
#define SSMPORT_ZNEW(type) (type*)SSMPORT_ZAlloc(sizeof(type))
#define SSMPORT_ZNewArray(type,size) (type*)SSMPORT_ZAlloc(sizeof(type)*(size))
/* Various message structs */
struct _SSMHelloRequest {
CMUint32 m_version; /* Protocol version supported by client */
struct _SSMString m_profileName; /* Name of user profile (where to find
certs etc) */
};
struct _SSMHelloReply {
CMInt32 m_result; /* Error, if any, which occurred
(0 == success) */
CMUint32 m_version; /* Protocol version supported by PSM */
struct _SSMString m_nonce; /* Session nonce -- must be written to data channels */
};
struct _SSMRequestSSLDataConnection
{
CMUint32 m_flags; /* Flags to indicate to SSM what to do with
the connection */
CMUint32 m_port; /* Port number to connect to */
struct _SSMString m_hostIP; /* IP address of final target machine (not proxy) */
/* struct _SSMString m_hostName; Host name of target machine (for server auth) -- not accessed directly */
};
struct _SSMReplySSLDataConnection {
CMInt32 m_result; /* Error, if any, which occurred (0 == success) */
CMUint32 m_connectionID; /* Connection ID of newly opened channel */
CMUint32 m_port; /* Port number to which to connect on PSM */
};
struct _SSMRequestSecurityStatus {
CMUint32 m_connectionID; /* ID of connection of which to stat */
};
struct _SSMReplySecurityStatus {
CMInt32 m_result; /* Error, if any, which occurred (0 == success) */
CMUint32 m_keySize; /* Key size */
CMUint32 m_secretKeySize; /* Secret key size */
struct _SSMString m_cipherName; /* Name of cipher in use */
/* SSMString m_certificate; -- DER encoded cert
We do not access this as a field, we have to skip over m_cipherName */
};
/*
Use this macro to jump over strings.
For example, if you wanted to access m_certificate above,
use a line like the following:
char *ptr = &(reply->m_cipherName) + SSM_SIZEOF_STRING(reply->m_cipherName);
*/
#define SSM_SIZEOF_STRING(str) (SSMSTRING_PADDED_LENGTH(PR_ntohl((str).m_length)) + sizeof(CMUint32))
typedef struct _SSMHelloRequest SSMHelloRequest;
typedef struct _SSMHelloReply SSMHelloReply;
typedef struct _SSMRequestSSLDataConnection SSMRequestSSLDataConnection;
typedef struct _SSMReplySSLDataConnection SSMReplySSLDataConnection;
typedef struct _SSMRequestSecurityStatus SSMRequestSecurityStatus;
typedef struct _SSMReplySecurityStatus SSMReplySecurityStatus;
/*
Functions to convert between an SSMString and a C string.
Return values are allocated using PR_Malloc (which means that
SSMPR_Free must be used to free up the memory after use).
*/
CMTStatus SSM_StringToSSMString(SSMString ** ssmString, int len, char * string);
CMTStatus SSM_SSMStringToString(char ** string,int *len, SSMString * ssmString);
#endif /* __PROTOCOL_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,359 +0,0 @@
/*
* 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 __PROTOCOLF_H__
#define __PROTOCOLF_H__
/*************************************************************************
* For each type of message, parse and pack function is provided.
*
* Parse functions accept a ptr to the "blob" of data received from the
* network and fill in fields of the message, numbers in host-order, strings
* as C-style NULL-terminated strings. Return SSMPRStatus.
*
* Pack functions take all the info to construct a message and fill in a
* ptr to the "blob" of data to be sent. Return length of the data blob, or
* a zero in case of an error
*
* All functions set NSPR errors when necessary.
************************************************************************/
#include "protocol.h"
#include "cert.h"
SSMPRStatus SSM_ParseHelloRequest(void * helloRequest,
SSMPRUint32 * version,
PRBool * doesUI,
PRInt32 * policyType,
SSMPRUint32 * profileLen,
char ** profile);
SSMPRInt32 SSM_PackHelloReply(void ** helloReply, SSMPRInt32 result,
SSMPRUint32 sessionID, SSMPRUint32 version,
SSMPRUint32 httpPort, SSMPRUint32 nonceLen,
char * nonce, SSMPolicyType policy);
/* Parse data connections requests */
SSMPRStatus SSM_ParseSSLDataConnectionRequest(void *sslRequest,
SSMPRUint32 * flags,
SSMPRUint32 * port,
SSMPRUint32 * hostIPLen,
char ** hostIP,
SSMPRUint32 * hostNameLen,
char ** hostName);
SSMPRStatus SSM_ParseHashStreamRequest(void * hashStreamRequest,
SSMPRUint32 * type);
SSMPRStatus SSM_ParseP7EncodeConnectionRequest(void *request,
SSMPRUint32 *ciRID);
/* Messages to initiate PKCS7 data connection */
/* PKCS7DecodeRequest message has no data */
/* Single data connection reply */
SSMPRInt32 SSM_PackDataConnectionReply(void ** sslReply,
SSMPRInt32 result,
SSMPRUint32 connID,
SSMPRUint32 port);
SSMPRStatus SSM_ParseSSLSocketStatusRequest(void * statusRequest,
SSMPRUint32 * connID);
SSMPRInt32 SSM_PackSSLSocketStatusReply(void ** statusReply,
SSMPRInt32 result,
SSMPRUint32 resourceID);
/*
* UI event is an asynchroneous message sent from PSM server to the client
* NOTE: (context) is the actual context pointer, it is NOT a ptr-to-ptr.
* The value of (context) is copied into the packet.
*/
SSMPRInt32 SSM_PackUIEvent(void ** eventRequest, SSMPRUint32 resourceID,
SSMPRUint32 width, SSMPRUint32 height,
SSMPRUint32 urlLen, char * url);
SSMPRInt32 SSM_PackTaskCompletedEvent(void **event, SSMPRUint32 resourceID,
SSMPRUint32 numTasks, SSMPRUint32 result);
/* Verify raw signature */
SSMPRStatus SSM_ParseVerifyRawSigRequest(void * verifyRawSigRequest,
SSMPRUint32 * algorithmID,
SSMPRUint32 * paramsLen,
unsigned char ** params,
SSMPRUint32 * pubKeyLen,
unsigned char ** pubKey,
SSMPRUint32 * hashLen,
unsigned char ** hash,
SSMPRUint32 * signatureLen,
unsigned char ** signature);
SSMPRInt32 SSM_PackVerifyRawSigReply(void ** verifyRawSigReply,
SSMPRInt32 result);
/* Verify detached signature */
SSMPRStatus SSM_ParseVerifyDetachedSigRequest(void * request,
SSMPRInt32 * pkcs7ContentID,
SSMPRInt32 * certUsage,
SSMPRInt32 * hashAlgID,
SSMPRUint32 * keepCert,
SSMPRUint32 * digestLen,
unsigned char ** hash);
SSMPRInt32 SSM_PackVerifyDetachedSigReply(void ** verifyDetachedSigReply,
SSMPRInt32 result);
/* PKCS#7 functions */
SSMPRStatus SSM_ParseCreateSignedRequest(void *request,
SSMPRInt32 *scertRID,
SSMPRInt32 *ecertRID,
SSMPRUint32 *dig_alg,
SECItem **digest);
SSMPRInt32 SSM_PackCreateSignedReply(void **reply, SSMPRInt32 ciRID,
SSMPRUint32 result);
SSMPRStatus SSM_ParseCreateEncryptedRequest(void *request,
SSMPRInt32 *scertRID,
SSMPRInt32 *nrcerts,
SSMPRInt32 **rcertRIDs);
SSMPRInt32 SSM_PackCreateEncryptedReply(void **reply, SSMPRInt32 ciRID,
SSMPRUint32 result);
/* Resource functions */
SSMPRStatus SSM_ParseCreateResourceRequest(void *request,
SSMPRUint32 *type,
unsigned char **params,
SSMPRUint32 *paramLen);
SSMPRStatus SSM_PackCreateResourceReply(void **reply, SSMPRStatus rv,
SSMPRUint32 resID);
SSMPRStatus SSM_ParseGetAttribRequest(void * getAttribRequest,
SSMPRUint32 * resourceID,
SSMPRUint32 * fieldID);
void SSM_DestroyAttrValue(SSMAttributeValue *value, PRBool freeit);
SSMPRInt32 SSM_PackGetAttribReply(void **getAttribReply,
SSMPRInt32 result,
SSMAttributeValue *value);
SSMPRStatus SSM_ParseSetAttribRequest(SECItem *msg,
SSMPRInt32 *resourceID,
SSMPRInt32 *fieldID,
SSMAttributeValue *value);
/* Currently, there is no need for a pack version. There is nothing to send
* back except for the notice that the operation was successful.
*/
/* Pickle and unpickle resources. */
SSMPRStatus SSM_ParsePickleResourceRequest(void * pickleResourceRequest,
SSMPRUint32 * resourceID);
SSMPRInt32 SSM_PackPickleResourceReply(void ** pickleResourceReply,
SSMPRInt32 result,
SSMPRUint32 resourceLen,
void * resource);
SSMPRStatus SSM_ParseUnpickleResourceRequest(void * unpickleResourceRequest,
SSMPRUint32 blobSize,
SSMPRUint32 * resourceType,
SSMPRUint32 * resourceLen,
void ** resource);
SSMPRInt32 SSM_PackUnpickleResourceReply(void ** unpickleResourceReply,
SSMPRInt32 result,
SSMPRUint32 resourceID);
/* Destroy resource */
SSMPRStatus SSM_ParseDestroyResourceRequest(void * destroyResourceRequest,
SSMPRUint32 * resourceID,
SSMPRUint32 * resourceType);
SSMPRInt32 SSM_PackDestroyResourceReply(void ** destroyResourceReply,
SSMPRInt32 result);
/* Duplicate resource */
SSMPRStatus SSM_ParseDuplicateResourceRequest(void * request,
SSMPRUint32 * resourceID);
SSMPRInt32 SSM_PackDuplicateResourceReply(void ** reply, SSMPRInt32 result,
SSMPRUint32 resID);
/* Cert actions */
typedef struct MatchUserCertRequestData {
PRUint32 certType;
PRInt32 numCANames;
char ** caNames;
} MatchUserCertRequestData;
typedef struct SSMCertList {
PRCList certs;
PRInt32 count;
} SSMCertList;
typedef struct SSMCertListElement {
PRCList links;
PRUint32 certResID;
} SSMCertListElement;
#define SSM_CERT_LIST_ELEMENT_PTR(_q) (SSMCertListElement*)(_q);
SSMPRStatus SSM_ParseVerifyCertRequest(void * verifyCertRequest,
SSMPRUint32 * resourceID,
SSMPRInt32 * certUsage);
SSMPRInt32 SSM_PackVerifyCertReply(void ** verifyCertReply,
SSMPRInt32 result);
SSMPRStatus SSM_ParseImportCertRequest(void * importCertRequest,
SSMPRUint32 * blobLen,
void ** certBlob);
SSMPRInt32 SSM_PackImportCertReply(void ** importCertReply, SSMPRInt32 result,
SSMPRUint32 resourceID);
PRStatus SSM_ParseFindCertByNicknameRequest(void *request, char ** nickname);
PRInt32 SSM_PackFindCertByNicknameReply(void ** reply, PRUint32 resourceID);
PRStatus SSM_ParseFindCertByKeyRequest(void *request, SECItem ** key);
PRInt32 SSM_PackFindCertByKeyReply(void ** reply, PRUint32 resourceID);
PRStatus SSM_ParseFindCertByEmailAddrRequest(void *request, char ** emailAddr);
PRInt32 SSM_PackFindCertByEmailAddrReply(void ** reply, PRUint32 resourceID);
PRStatus SSM_ParseAddTempCertToDBRequest(void *request, PRUint32 *resourceID, char ** nickname, PRInt32 *ssl, PRInt32 *email, PRInt32 *objectSigning);
PRInt32 SSM_PackAddTempCertToDBReply(void ** reply);
PRStatus SSM_ParseMatchUserCertRequest(void *request, MatchUserCertRequestData** data);
PRInt32 SSM_PackMatchUserCertReply(void **reply, SSMCertList * certList);
SSMPRInt32 SSM_PackErrorMessage(void ** errorReply, SSMPRInt32 result);
/* PKCS11 actions */
SSMPRStatus SSM_ParseKeyPairGenRequest(void *keyPairGenRequest,
SSMPRInt32 requestLen,
SSMPRUint32 *keyPairCtxtID,
SSMPRUint32 *genMechanism,
SSMPRUint32 *keySize,
unsigned char **params,
SSMPRUint32 *paramLen);
SSMPRInt32 SSM_PackKeyPairGenResponse(void ** keyPairGenResponse,
SSMPRUint32 keyPairId);
PRStatus
SSM_ParseFinishKeyGenRequest(void *finishKeyGenRequest,
PRInt32 requestLen,
PRInt32 *keyGenContext);
/* CMMF/CRMF Actions */
SSMPRStatus SSM_ParseCreateCRMFReqRequest(void *crmfReqRequest,
SSMPRInt32 requestLen,
SSMPRUint32 *keyPairId);
SSMPRInt32 SSM_PackCreateCRMFReqReply(void **crmfReqReply,
SSMPRUint32 crmfReqId);
SSMPRStatus SSM_ParseEncodeCRMFReqRequest(void *encodeReq,
SSMPRInt32 requestLen,
SSMPRUint32 **crmfReqId,
SSMPRInt32 *numRequests);
SSMPRInt32 SSM_PackEncodeCRMFReqReply(void **encodeReply,
char *crmfDER,
SSMPRUint32 derLen);
SSMPRStatus SSM_ParseCMMFCertResponse(void *encodedRes,
SSMPRInt32 encodeLen,
char **nickname,
char **base64Der,
PRBool *doBackup);
PRStatus SSM_ParsePOPChallengeRequest(void *challenge,
PRInt32 len,
char **responseString);
PRInt32 SSM_PackPOPChallengeResponse(void **response,
char *responseString,
PRInt32 responseStringLen);
PRInt32 SSM_PackPasswdRequest(void ** passwdRequest, PRInt32 tokenID,
char * prompt, PRInt32 promptLen);
PRStatus SSM_ParsePasswordReply(void * passwdReply, PRInt32 * result,
PRInt32 * tokenID,
char ** passwd, PRInt32 * passwdLen);
/* Sign Text Actions */
typedef struct {
char *stringToSign;
char *hostName;
char *caOption;
PRInt32 numCAs;
char **caNames;
} signTextRequestData;
PRStatus SSM_ParseSignTextRequest(void* signTextRequest, PRInt32 len, PRUint32* resID, signTextRequestData ** data);
PRStatus SSM_ParseGetLocalizedTextRequest(void *data,
SSMLocalizedString *whichString);
PRInt32 SSM_PackGetLocalizedTextResponse(void **data,
SSMLocalizedString whichString,
char *retString);
PRStatus SSM_ParseAddNewSecurityModuleRequest(void *data,
char **moduleName,
char **libraryPath,
unsigned long *pubMechFlags,
unsigned long *pubCipherFlags);
PRInt32 SSM_PackAddNewModuleResponse(void **data, PRInt32 rv);
PRStatus SSM_ParseDeleteSecurityModuleRequest(void *data, char **moduleName);
PRInt32 SSM_PackDeleteModuleResponse(void **data, PRInt32 moduleType);
PRInt32 SSM_PackFilePathRequest(void **data, PRInt32 resID, char *prompt,
PRBool shouldFileExist, char *fileSuffix);
PRStatus SSM_ParseFilePathReply(void *message, char **filePath,
PRInt32 *rid);
PRInt32 SSM_PackPromptRequestEvent(void **data, PRInt32 resID, char *prompt);
PRStatus SSM_ParsePasswordPromptReply(void *data, PRInt32 *resID,
char **reply);
/* messages for importing certs *the traditional way* */
PRInt32 SSM_PackDecodeCertReply(void ** data, PRInt32 certID);
PRStatus SSM_ParseDecodeCertRequest(void * data, PRInt32 * len,
char ** buffer);
PRStatus SSM_ParseGetKeyChoiceListRequest(void * data, PRUint32 dataLen,
char ** type, PRUint32 *typeLen,
char ** pqgString, PRUint32 *pqgLen);
PRInt32 SSM_PackGetKeyChoiceListReply(void **data, char ** list);
PRStatus SSM_ParseGenKeyOldStyleRequest(void * data, PRUint32 datalen,
char ** choiceString,
char ** challenge,
char ** typeString,
char ** pqgString);
PRInt32 SSM_PackGenKeyOldStyleReply(void ** data, char * keydata);
PRStatus SSM_ParseDecodeAndCreateTempCertRequest(void * data,
char ** certbuf, PRUint32 * certlen, int * certClass);
#endif /*PROTOCOLF_H_*/

View File

@@ -1,74 +0,0 @@
/*
* 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 NULL
#define NULL 0x00000000
#endif
#define SSMPR_BYTES_PER_INT 4
#define SSMPR_BYTES_PER_LONG 4
/******************************************************************
* No NSPR - define all the SSMPR values and functions here
******************************************************************
*/
#define SSMPRStatus PRStatus
#define SSMPR_SUCCESS PR_SUCCESS
#define SSMPR_FAILURE PR_FAILURE
#define SSMPR_INVALID_ARGUMENT_ERROR PR_INVALID_ARGUMENT_ERROR
#define SSMPR_OUT_OF_MEMORY_ERROR PR_OUT_OF_MEMORY_ERROR
#define SSMPRInt32 PRInt32
#define SSMPRUint32 PRUint32
#define SSMPR_ntohl PR_ntohl
#define SSMPR_htonl PR_htonl
#define SSMPORT_Free PORT_Free
#define SSMPORT_ZAlloc PORT_ZAlloc
#define SSMPR_SetError PR_SetError
#define SSMPR_GetError PR_GetError
#define SSMPORT_SetError PORT_SetError
#define SSMPORT_GetError PORT_GetError

View File

@@ -1,49 +0,0 @@
/*
* 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.
*/
/*************************************************************************
*
* PSM portable run-time. (Used when NSPR20 is not available.)
*
*************************************************************************
*/
SSMPRInt32 ssmprErrno;
void SSMPORT_SetError(SSMPRInt32 errorcode)
{ ssmprErrno = errorcode; }
SSMPRInt32 SSMPORT_GetError(void)
{ return ssmprErrno; }

View File

@@ -1,93 +0,0 @@
/*
* 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 NULL
#define NULL 0x00000000
#endif
#define SSMPR_BYTES_PER_INT 4
#define SSMPR_BYTES_PER_LONG 4
/******************************************************************
* No NSPR - define all the SSMPR values and functions here
******************************************************************
*/
typedef enum { SSMPR_SUCCESS = 0, SSMPR_FAILURE = -1 } SSMPRStatus;
enum {
SSMPR_INVALID_ARGUMENT_ERROR = -6000,
SSMPR_OUT_OF_MEMORY_ERROR = -5987
};
#if SSMPR_BYTES_PER_INT == 4
typedef unsigned int SSMPRUint32;
typedef int SSMPRInt32;
#elif SSMPR_BYTES_PER_LONG == 4
typedef unsigned long SSMPRUint32;
typedef long SSMPRInt32;
#else
#error No suitable type for SSMPRInt32/SSMPRUint32
#endif
/*******************************************************************
* Use libc functions instead
*******************************************************************
*/
#include <sys/types.h>
#ifdef WIN32
#include <winsock.h>
#else
#include <netinet/in.h>
#endif
#define SSMPR_ntohl ntohl
#define SSMPR_htonl htonl
#include <stdlib.h>
#define SSMPORT_Free free
#define SSMPR_sprint printf
#define SSMPORT_ZAlloc malloc
extern SSMPRInt32 ssmprErrno;
#define SSMPR_SetError(x, y) SSMPORT_SetError(x)
#define SSMPR_GetError SSMPORT_GetError
void SSMPORT_SetError(SSMPRInt32 errorcode);

View File

@@ -1,169 +0,0 @@
/*
* 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.
*/
#include "string.h"
#include "protocol.h"
#include "protocolshr.h"
#include "messages.h"
/* Forward ref */
static void encrypt(CMTItem *data);
static void decrypt(CMTItem *data);
const char *kPrefix = "Encrypted";
/* encryption request */
CMTStatus
CMT_DoEncryptionRequest(CMTItem *message)
{
CMTStatus rv = CMTSuccess;
EncryptRequestMessage request;
EncryptReplyMessage reply;
CMUint32 pLen = strlen(kPrefix);
/* Initialize */
request.keyid.data = 0;
request.data.data = 0;
reply.item.data = 0;
/* Decode incoming message */
rv = CMT_DecodeMessage(EncryptRequestTemplate, &request, message);
if (rv != CMTSuccess) goto loser; /* Protocol error */
/* Free incoming message */
free(message->data);
message->data = NULL;
/* "Encrypt" by prefixing the data */
reply.item.len = request.data.len + pLen;
reply.item.data = calloc(reply.item.len, 1);
if (!reply.item.data) {
rv = CMTFailure;
goto loser;
}
if (pLen) memcpy(reply.item.data, kPrefix, pLen);
encrypt(&request.data);
memcpy(&reply.item.data[pLen], request.data.data, request.data.len);
/* Generate response */
message->type = SSM_SDR_ENCRYPT_REPLY;
rv = CMT_EncodeMessage(EncryptReplyTemplate, message, &reply);
if (rv != CMTSuccess) goto loser; /* Unknown error */
loser:
if (request.keyid.data) free(request.keyid.data);
if (request.data.data) free(request.data.data);
if (request.ctx.data) free(request.ctx.data);
if (reply.item.data) free(reply.item.data);
return rv;
}
/* decryption request */
CMTStatus
CMT_DoDecryptionRequest(CMTItem *message)
{
CMTStatus rv = CMTSuccess;
DecryptRequestMessage request;
DecryptReplyMessage reply;
CMUint32 pLen = strlen(kPrefix);
/* Initialize */
request.data.data = 0;
request.ctx.data = 0;
reply.item.data = 0;
/* Decode the message */
rv = CMT_DecodeMessage(DecryptRequestTemplate, &request, message);
if (rv != CMTSuccess) goto loser;
/* Free incoming message */
free(message->data);
message->data = NULL;
/* "Decrypt" the message by removing the key */
if (pLen && memcmp(request.data.data, kPrefix, pLen) != 0) {
rv = CMTFailure; /* Invalid format */
goto loser;
}
reply.item.len = request.data.len - pLen;
reply.item.data = calloc(reply.item.len, 1);
if (!reply.item.data) { rv = CMTFailure; goto loser; }
memcpy(reply.item.data, &request.data.data[pLen], reply.item.len);
decrypt(&reply.item);
/* Create reply message */
message->type = SSM_SDR_DECRYPT_REPLY;
rv = CMT_EncodeMessage(DecryptReplyTemplate, message, &reply);
if (rv != CMTSuccess) goto loser;
loser:
if (request.data.data) free(request.data.data);
if (request.ctx.data) free(request.ctx.data);
if (reply.item.data) free(reply.item.data);
return rv;
}
/* "encrypt" */
static unsigned char mask[64] = {
0x73, 0x46, 0x1a, 0x05, 0x24, 0x65, 0x43, 0xb4, 0x24, 0xee, 0x79, 0xc1, 0xcc,
0x49, 0xc7, 0x27, 0x11, 0x91, 0x2e, 0x8f, 0xaa, 0xf7, 0x62, 0x75, 0x41, 0x7e,
0xb2, 0x42, 0xde, 0x1b, 0x42, 0x7b, 0x1f, 0x33, 0x49, 0xca, 0xd1, 0x6a, 0x85,
0x05, 0x6c, 0xf9, 0x0e, 0x3e, 0x72, 0x02, 0xf2, 0xd8, 0x9d, 0xa1, 0xb8, 0x6e,
0x03, 0x18, 0x3e, 0x82, 0x86, 0x34, 0x1a, 0x61, 0xd9, 0x65, 0xb6, 0x7f
};
static void
encrypt(CMTItem *data)
{
unsigned int i, j;
j = 0;
for(i = 0;i < data->len;i++)
{
data->data[i] ^= mask[j];
if (++j >= 64) j = 0;
}
}
static void
decrypt(CMTItem *data)
{
encrypt(data);
}

View File

@@ -1,48 +0,0 @@
/*
* 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.
*/
/*
protocolshr.h - Definitions of shared routines for both client and server
These are mostly for testing.
*/
#ifndef __PROTOCOLSHR_H__
#define __PROTOCOLSHR_H__
CMTStatus
CMT_DoEncryptionRequest(CMTItem *message);
CMTStatus
CMT_DoDecryptionRequest(CMTItem *meessage);
#endif /* __PROTOCOLSHR_H__ */

View File

@@ -1,207 +0,0 @@
/*
* 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.
*/
#include "protocolf.h"
#include <stdio.h>
int main()
{
void * blob, * recvd;
int blobSize;
SSMPRUint32 version, flags, port, connID, keySize, secretKeySize;
SSMPRUint32 sessionID, httpPort;
SSMPRInt32 result;
char *profile, * nonce, * hostIP, * hostName, * cipher, * CA;
SSMPRStatus rv;
/*
* Test functions to pack and parse HelloRequest message
*/
version = 3;
profile = (char *)SSMPORT_ZAlloc(strlen("profile"));
sprintf(profile, "profile");
printf("HelloRequest, packing version #%d, profile %s\n",
version, profile);
blobSize = SSM_PackHelloRequest(&blob, version, profile);
if (!blobSize)
printf("Error in PackHelloRequest: %d\n", SSMPR_GetError());
SSMPORT_Free(profile);
version = 0;
recvd = (void *)SSMPORT_ZAlloc(blobSize);
if (!recvd) printf("Can't allocate %d bytes of memory!\n", blobSize);
memcpy(recvd, blob, blobSize);
SSMPORT_Free(blob);
rv = SSM_ParseHelloRequest(recvd, &version, &profile);
if (rv != SSMPR_SUCCESS)
printf("Error in ParseHelloRequest: %d\n", SSMPR_GetError());
printf("HelloRequest, parsing version #%d, profile %s\n",
version, profile);
/*
* Test functions to parse and pack HelloReply message
*/
version = 5;
result = 2;
sessionID = 34567;
httpPort = 87654;
nonce = (char *)SSMPORT_ZAlloc(strlen("some secret nonce"));
sprintf(nonce, "some secret nonce");
printf("HelloReply, packing result %d, sessionID %d, version #%d, httpPort %d,\n nonce %s\n",
result, sessionID, version, httpPort, nonce);
blobSize = SSM_PackHelloReply(&blob, result, sessionID, version, httpPort,
nonce);
if (!blobSize)
printf("Error in PackHelloReply: %d\n", SSMPR_GetError());
memset(nonce, 0, strlen(nonce));
SSMPORT_Free(nonce);
version = result = sessionID = httpPort = 0;
recvd = (void *)SSMPORT_ZAlloc(blobSize);
if (!recvd) printf("Can't allocate %d bytes of memory!\n", blobSize);
memcpy(recvd, blob, blobSize);
SSMPORT_Free(blob);
rv = SSM_ParseHelloReply(recvd, &result, &sessionID, &version, &httpPort,
&nonce);
if (rv != SSMPR_SUCCESS)
printf("Error in ParseHelloReply: %d\n", SSMPR_GetError());
printf("HelloReply, parsing result %d, sessionID %d, version #%d, httpPort %d, \n nonce %s\n",
result, sessionID, version, httpPort, nonce);
/*
* Test functions to parse and pack SSLDataConnectionRequest message
*/
flags = 0x00044000;
port = 34567;
hostIP = (char *)SSMPORT_ZAlloc(strlen("somehostIP"));
sprintf(hostIP, "somehostIP");
hostName = (char *)SSMPORT_ZAlloc(strlen("somehostName"));
sprintf(hostName, "somehostName");
printf("SSLDataConnRequest, packing flags %x, port %d, hostIP %s, hostName %s\n",
flags, port, hostIP, hostName);
blobSize = SSM_PackSSLDataConnectionRequest(&blob, flags, port, hostIP,
hostName);
if (!blobSize)
printf("Error in PackSSLDataConnectionRequest: %d\n", SSMPR_GetError());
SSMPORT_Free(hostIP);
SSMPORT_Free(hostName);
flags = port = 0;
recvd = (void *)SSMPORT_ZAlloc(blobSize);
if (!recvd) printf("Can't allocate %d bytes of memory!\n", blobSize);
memcpy(recvd, blob, blobSize);
SSMPORT_Free(blob);
rv = SSM_ParseSSLDataConnectionRequest(recvd, &flags, &port, &hostIP,
&hostName);
if (rv != SSMPR_SUCCESS)
printf("Error in ParseSSLDataConnectionRequest: %d\n", SSMPR_GetError());
printf(
"SSLDataConnRequest, parsing flags %x, port %d, hostIP %s, hostName %s\n",
flags, port, hostIP, hostName);
SSMPORT_Free(hostIP);
SSMPORT_Free(hostName);
/*
* Test functions to parse and pack SSLDataConnectionReply message
*/
result = 2;
connID = 713259;
port = 57402;
printf("SSLDataConnReply, packing result %d, connectionID %d, port %d\n",
result, connID, port);
blobSize = SSM_PackSSLDataConnectionReply(&blob, result, connID, port);
if (!blobSize)
printf("Error in PackSSLDataConnReply: %d\n", SSMPR_GetError());
result = connID = port = 0;
recvd = (void *)SSMPORT_ZAlloc(blobSize);
if (!recvd) printf("Can't allocate %d bytes of memory!\n", blobSize);
memcpy(recvd, blob, blobSize);
SSMPORT_Free(blob);
rv = SSM_ParseSSLDataConnectionReply(recvd, &result, &connID, &port);
if (rv != SSMPR_SUCCESS)
printf("Error in ParseSSLDataConnectionReply: %d\n", SSMPR_GetError());
printf("SSLDataConnReply, parsing result %d, connectionID %d, port %d\n",
result, connID, port);
/*
* Test functions to parse and pack SecurityStatusRequest message
*/
connID = 45375;
printf("SecurityStatusRequest, packing connection ID %d\n", connID);
blobSize = SSM_PackSecurityStatusRequest(&blob, connID);
if (!blobSize)
printf("Error in PackSecurityStatusRequest: %d\n", SSMPR_GetError());
connID = 0;
recvd = (void *)SSMPORT_ZAlloc(blobSize);
if (!recvd) printf("Can't allocate %d bytes of memory!\n", blobSize);
memcpy(recvd, blob, blobSize);
SSMPORT_Free(blob);
rv = SSM_ParseSecurityStatusRequest(recvd, &connID);
if (rv != SSMPR_SUCCESS)
printf("Error in ParseSecurityStatusRequest: %d\n", SSMPR_GetError());
printf("SecurityStatusRequest, parsing connection ID %d\n", connID);
/*
* Test functions to parse and pack SecurityStatusReply message
*/
result = 2;
keySize = 256;
secretKeySize = 511;
cipher = (char *)SSMPORT_ZAlloc(strlen("My Cipher"));
sprintf(cipher, "My Cipher");
CA = (char *)SSMPORT_ZAlloc(strlen("My CA issuer"));
sprintf(CA, "My CA issuer");
printf("SecurityStatusReply, packing result %d, keysize %d, secretKeySize %d, cipher %s, CA %s\n", result, keySize, secretKeySize, cipher, CA);
blobSize = SSM_PackSecurityStatusReply(&blob, result, keySize, secretKeySize, cipher, CA);
if (!blobSize)
printf("Error in PackSecurityStatusReply: %d\n", SSMPR_GetError());
result = keySize = secretKeySize = 0;
SSMPORT_Free(cipher);
SSMPORT_Free(CA);
recvd = (void *)SSMPORT_ZAlloc(blobSize);
if (!recvd) printf("Can't allocate %d bytes of memory!\n", blobSize);
memcpy(recvd, blob, blobSize);
SSMPORT_Free(blob);
rv = SSM_ParseSecurityStatusReply(recvd, &result, &keySize, &secretKeySize,
&cipher, &CA);
if (rv != SSMPR_SUCCESS)
printf("Error in ParseSecurityStatusReply: %d\n", SSMPR_GetError());
printf("SecurityStatusReply, parsing result %d, keysize %d, secretKeySize %d, cipher %s, CA %s\n", result, keySize, secretKeySize, cipher, CA);
}

View File

@@ -1,130 +0,0 @@
/*
* 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.
*/
#include "protocol.h"
#include "prmem.h"
#include "prnetdb.h"
#include <string.h>
#ifndef NSPR20
#include "protocolport.c"
#endif
CMStatus SSM_SSMStringToString(char ** string,
int *len,
SSMString * ssmString)
{
char * str = NULL;
int realLen;
PRStatus rv =PR_SUCCESS;
if (!ssmString || !string ) {
rv = PR_INVALID_ARGUMENT_ERROR;
goto loser;
}
/* in case we fail */
*string = NULL;
if (len) *len = 0;
/* Convert from net byte order */
realLen = SSMPR_ntohl(ssmString->m_length);
str = (char *)PR_CALLOC(realLen+1); /* add 1 byte for end 0 */
if (!str) {
rv = PR_OUT_OF_MEMORY_ERROR;
goto loser;
}
memcpy(str, (char *) &(ssmString->m_data), realLen);
/* str[realLen]=0; */
if (len) *len = realLen;
*string = str;
return rv;
loser:
if (str)
PR_Free(str);
if (string && *string) {
PR_Free(*string);
*string = NULL;
}
if (rv == PR_SUCCESS)
rv = PR_FAILURE;
return rv;
}
CMStatus SSM_StringToSSMString(SSMString ** ssmString, int length,
char * string)
{
SSMPRUint32 len;
SSMString *result = NULL;
PRStatus rv = PR_SUCCESS;
if (!string || !ssmString) {
rv = PR_INVALID_ARGUMENT_ERROR;
goto loser;
}
*ssmString = NULL; /* in case we fail */
if (length) len = length;
else len = strlen(string);
if (len <= 0) {
rv = PR_INVALID_ARGUMENT_ERROR;
goto loser;
}
result = (SSMString *) PR_CALLOC(sizeof(PRUint32) +
SSMSTRING_PADDED_LENGTH(len));
if (!result) {
rv = PR_OUT_OF_MEMORY_ERROR;
goto loser;
}
result->m_length = SSMPR_htonl(len);
memcpy((char *) (&(result->m_data)), string, len);
*ssmString = result;
goto done;
loser:
if (result)
PR_Free(result);
*ssmString = NULL;
if (rv == PR_SUCCESS)
rv = PR_FAILURE;
done:
return rv;
}

View File

@@ -1,165 +0,0 @@
/* -*- 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.
*/
#ifndef __SSM_RSRCIDS_H__
#define __SSM_RSRCIDS_H__
#include "ssmdefs.h"
/*
* IMPORTANT:
*
* To preserve backward compatibility as much as possible, always add new
* values to either one of the enumeration tables at the end of the table.
*/
typedef enum
{
SSM_RESTYPE_NULL = 0L,
SSM_RESTYPE_RESOURCE,
SSM_RESTYPE_CONNECTION,
SSM_RESTYPE_CONTROL_CONNECTION,
SSM_RESTYPE_DATA_CONNECTION,
SSM_RESTYPE_SSL_DATA_CONNECTION,
SSM_RESTYPE_PKCS7_DECODE_CONNECTION,
SSM_RESTYPE_PKCS7_ENCODE_CONNECTION,
SSM_RESTYPE_HASH_CONNECTION,
SSM_RESTYPE_CERTIFICATE,
SSM_RESTYPE_SSL_SOCKET_STATUS,
SSM_RESTYPE_PKCS7_CONTENT_INFO,
SSM_RESTYPE_KEY_PAIR,
SSM_RESTYPE_CRMF_REQUEST,
SSM_RESTYPE_KEYGEN_CONTEXT,
SSM_RESTYPE_SECADVISOR_CONTEXT,
SSM_RESTYPE_SIGNTEXT,
SSM_RESTYPE_PKCS12_CONTEXT,
SSM_RESTYPE_MAX
} SSMResourceType;
/* Attribute/resource types */
/* Attribute IDs */
typedef enum
{
SSM_FID_NULL = (CMUint32) 0, /* placeholder */
/* Connection attributes */
SSM_FID_CONN_ALIVE,
SSM_FID_CONN_PARENT,
/* Data connection attributes */
SSM_FID_CONN_DATA_PENDING,
/* SSL data connection attributes */
SSM_FID_SSLDATA_SOCKET_STATUS,
SSM_FID_SSLDATA_ERROR_VALUE,
/* PKCS7 decode connection attributes */
SSM_FID_P7CONN_CONTENT_INFO,
SSM_FID_P7CONN_RETURN_VALUE,
SSM_FID_P7CONN_ERROR_VALUE,
/* Hash connection attributes */
SSM_FID_HASHCONN_RESULT,
/* Certificate attributes */
SSM_FID_CERT_SUBJECT_NAME,
SSM_FID_CERT_ISSUER_NAME,
SSM_FID_CERT_SERIAL_NUMBER,
SSM_FID_CERT_EXP_DATE,
SSM_FID_CERT_FINGERPRINT,
SSM_FID_CERT_COMMON_NAME,
SSM_FID_CERT_NICKNAME,
SSM_FID_CERT_ORG_NAME,
SSM_FID_CERT_HTML_CERT,
SSM_FID_CERT_PICKLE_CERT,
SSM_FID_CERT_CERTKEY,
SSM_FID_CERT_FIND_CERT_ISSUER,
SSM_FID_CERT_EMAIL_ADDRESS,
SSM_FID_CERT_ISPERM,
/* SSL socket status attributes */
SSM_FID_SSS_KEYSIZE,
SSM_FID_SSS_SECRET_KEYSIZE,
SSM_FID_SSS_CERT_ID,
SSM_FID_SSS_CIPHER_NAME,
SSM_FID_SSS_SECURITY_LEVEL,
SSM_FID_SSS_HTML_STATUS,
/* PKCS7 content info attributes */
SSM_FID_P7CINFO_IS_SIGNED,
SSM_FID_P7CINFO_IS_ENCRYPTED,
SSM_FID_P7CINFO_SIGNER_CERT,
/* CRMF ID's */
SSM_FID_CRMFREQ_REGTOKEN,
SSM_FID_CRMFREQ_AUTHENTICATOR,
SSM_FID_CRMFREQ_EXTENSIONS,
SSM_FID_CRMFREQ_KEY_TYPE,
SSM_FID_CRMFREQ_DN,
/* Security advisor context */
SSM_FID_SECADVISOR_URL,
SSM_FID_SECADVISOR_WIDTH,
SSM_FID_SECADVISOR_HEIGHT,
/* Sign Text */
SSM_FID_SIGNTEXT_RESULT,
/* Key Gen ID's */
SSM_FID_KEYGEN_ESCROW_AUTHORITY,
/* Key Pair ID's */
SSM_FID_KEYPAIR_KEY_GEN_TYPE,
/* Session Attributes */
SSM_FID_DEFAULT_EMAIL_RECIPIENT_CERT,
SSM_FID_DEFAULT_EMAIL_SIGNER_CERT,
/* Client Context Attribute */
SSM_FID_CLIENT_CONTEXT,
/* Resource Error */
SSM_FID_RESOURCE_ERROR,
SSM_FID_KEYGEN_SLOT_NAME,
SSM_FID_DISABLE_ESCROW_WARN,
SSM_FID_KEYGEN_TOKEN_NAME,
SSM_FID_SSLDATA_DISCARD_SOCKET_STATUS,
SSM_FID_MAX /* placeholder */
} SSMAttributeID;
#endif

View File

@@ -1,324 +0,0 @@
/* -*- 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.
*/
#ifndef __SSMDEFS_H__
#define __SSMDEFS_H__
/* Basic type definitions for both client and server. */
typedef long CMInt32;
typedef unsigned long CMUint32;
typedef long SSMResourceID;
typedef int SSMStatus;
#define PSM_PORT 11111
#define PSM_DATA_PORT 11113 /* needs to be removed */
typedef enum _CMTStatus {
CMTFailure = -1,
CMTSuccess = 0
} CMTStatus;
typedef enum {
CM_FALSE = 0,
CM_TRUE = 1
} CMBool;
typedef struct CMTItemStr {
CMUint32 type;
unsigned char *data;
unsigned int len;
} CMTItem;
/* A length-encoded string. */
struct _SSMString {
CMUint32 m_length;
char m_data;
};
typedef struct _SSMString SSMString;
#define SSM_PROTOCOL_VERSION 0x00000051
#define SSM_INVALID_RESOURCE 0x00000000
#define SSM_GLOBAL_RESOURCE 0x00000001
#define SSM_SESSION_RESOURCE 0x00000002
/* Message category flags */
#define SSM_REQUEST_MESSAGE 0x10000000
#define SSM_REPLY_OK_MESSAGE 0x20000000
#define SSM_REPLY_ERR_MESSAGE 0x30000000
#define SSM_EVENT_MESSAGE 0x40000000
/* Message types */
#define SSM_DATA_CONNECTION 0x00001000
#define SSM_OBJECT_SIGNING 0x00002000
#define SSM_RESOURCE_ACTION 0x00003000
#define SSM_CERT_ACTION 0x00004000
#define SSM_PKCS11_ACTION 0x00005000
#define SSM_CRMF_ACTION 0x00006000
#define SSM_FORMSIGN_ACTION 0x00007000
#define SSM_LOCALIZED_TEXT 0x00008000
#define SSM_HELLO_MESSAGE 0x00009000
#define SSM_SECURITY_ADVISOR 0x0000a000
#define SSM_SEC_CFG_ACTION 0x0000b000
#define SSM_KEYGEN_TAG 0x0000c000
#define SSM_PREF_ACTION 0x0000d000
#define SSM_MISC_ACTION 0x0000f000
/* Data connection messages subtypes */
#define SSM_SSL_CONNECTION 0x00000100
#define SSM_PKCS7DECODE_STREAM 0x00000200
#define SSM_PKCS7ENCODE_STREAM 0x00000300
#define SSM_HASH_STREAM 0x00000400
#define SSM_TLS_CONNECTION 0x00000500
#define SSM_PROXY_CONNECTION 0x00000600
/* Object signing message subtypes */
#define SSM_VERIFY_RAW_SIG 0x00000100
#define SSM_VERIFY_DETACHED_SIG 0x00000200
#define SSM_CREATE_SIGNED 0x00000300
#define SSM_CREATE_ENCRYPTED 0x00000400
/* Resource access messages subtypes */
#define SSM_CREATE_RESOURCE 0x00000100
#define SSM_DESTROY_RESOURCE 0x00000200
#define SSM_GET_ATTRIBUTE 0x00000300
#define SSM_CONSERVE_RESOURCE 0x00000400
#define SSM_DUPLICATE_RESOURCE 0x00000500
#define SSM_SET_ATTRIBUTE 0x00000600
#define SSM_TLS_STEPUP 0x00000700
#define SSM_PROXY_STEPUP 0x00000800
/* Further specification for resource access messages */
#define SSM_SSLSocket_Status 0x00000010
#define SSM_NO_ATTRIBUTE 0x00000000
#define SSM_NUMERIC_ATTRIBUTE 0x00000010
#define SSM_STRING_ATTRIBUTE 0x00000020
#define SSM_RID_ATTRIBUTE 0x00000030
#define SSM_PICKLE_RESOURCE 0x00000010
#define SSM_UNPICKLE_RESOURCE 0x00000020
#define SSM_PICKLE_SECURITY_STATUS 0x00000030
/* Certificate access message subtypes */
#define SSM_IMPORT_CERT 0x00000100
#define SSM_VERIFY_CERT 0x00000200
#define SSM_FIND_BY_NICKNAME 0x00000300
#define SSM_FIND_BY_KEY 0x00000400
#define SSM_FIND_BY_EMAILADDR 0x00000500
#define SSM_ADD_TO_DB 0x00000600
#define SSM_DECODE_CERT 0x00000700
#define SSM_MATCH_USER_CERT 0x00000800
#define SSM_DESTROY_CERT 0x00000900
#define SSM_DECODE_TEMP_CERT 0x00000a00
#define SSM_REDIRECT_COMPARE 0x00000b00
#define SSM_DECODE_CRL 0x00000c00
#define SSM_EXTENSION_VALUE 0x00000d00
#define SSM_HTML_INFO 0x00000e00
/* message subtypes used for KEYGEN form tag */
#define SSM_GET_KEY_CHOICE 0x00000100
#define SSM_KEYGEN_START 0x00000200
#define SSM_KEYGEN_TOKEN 0x00000300
#define SSM_KEYGEN_PASSWORD 0x00000400
#define SSM_KEYGEN_DONE 0x00000500
#define SSM_CREATE_KEY_PAIR 0x00000100
#define SSM_FINISH_KEY_GEN 0x00000200
#define SSM_ADD_NEW_MODULE 0x00000300
#define SSM_DEL_MODULE 0x00000400
#define SSM_LOGOUT_ALL 0x00000500
#define SSM_ENABLED_CIPHERS 0x00000600
#define SSM_CREATE_CRMF_REQ 0x00000100
#define SSM_DER_ENCODE_REQ 0x00000200
#define SSM_PROCESS_CMMF_RESP 0x00000300
#define SSM_CHALLENGE 0x00000400
#define SSM_SIGN_TEXT 0x00000100
/* Security Config subtypes */
#define SSM_ADD_CERT_TO_TEMP_DB 0x00000100
#define SSM_ADD_TEMP_CERT_TO_DB 0x00000200
#define SSM_DELETE_PERM_CERTS 0x00000300
#define SSM_FIND_CERT_KEY 0x00000400
#define SSM_GET_CERT_PROP_BY_KEY 0x00000500
#define SSM_CERT_INDEX_ENUM 0x00000600
/* subcategories for SSM_FIND_CERT_KEY and SSM_CERT_INDEX_ENUM */
#define SSM_FIND_KEY_BY_NICKNAME 0x00000010
#define SSM_FIND_KEY_BY_EMAIL_ADDR 0x00000020
#define SSM_FIND_KEY_BY_DN 0x00000030
/* subcategories for SSM_GET_CERT_PROP_BY_KEY */
#define SSM_SECCFG_GET_NICKNAME 0x00000010
#define SSM_SECCFG_GET_EMAIL_ADDR 0x00000020
#define SSM_SECCFG_GET_DN 0x00000030
#define SSM_SECCFG_GET_TRUST 0x00000040
#define SSM_SECCFG_CERT_IS_PERM 0x00000050
#define SSM_SECCFG_GET_NOT_BEFORE 0x00000060
#define SSM_SECCFG_GET_NOT_AFTER 0x00000070
#define SSM_SECCFG_GET_SERIAL_NO 0x00000080
#define SSM_SECCFG_GET_ISSUER 0x00000090
#define SSM_SECCFG_GET_ISSUER_KEY 0x000000a0
#define SSM_SECCFG_GET_SUBJECT_NEXT 0x000000b0
#define SSM_SECCFG_GET_SUBJECT_PREV 0x000000c0
/* Misc requests */
#define SSM_MISC_GET_RNG_DATA 0x00000100
#define SSM_MISC_PUT_RNG_DATA 0x00000200
#define SSM_MISC_SDR_ENCRYPT 0x00000300
#define SSM_MISC_SDR_DECRYPT 0x00000400
#define SSM_MISC_UI 0x00000500
/* specific UI requests */
#define SSM_UI_CHANGE_PASSWORD 0x00000010
#define SSM_SDR_ENCRYPT_REQUEST \
(SSM_REQUEST_MESSAGE|SSM_MISC_ACTION|SSM_MISC_SDR_ENCRYPT)
#define SSM_SDR_ENCRYPT_REPLY \
(SSM_REPLY_OK_MESSAGE|SSM_MISC_ACTION|SSM_MISC_SDR_ENCRYPT)
#define SSM_SDR_DECRYPT_REQUEST \
(SSM_REQUEST_MESSAGE|SSM_MISC_ACTION|SSM_MISC_SDR_DECRYPT)
#define SSM_SDR_DECRYPT_REPLY \
(SSM_REPLY_OK_MESSAGE|SSM_MISC_ACTION|SSM_MISC_SDR_DECRYPT)
/* Type masks for message types */
#define SSM_CATEGORY_MASK 0xF0000000
#define SSM_TYPE_MASK 0x0000F000
#define SSM_SUBTYPE_MASK 0x00000F00
#define SSM_SPECIFIC_MASK 0x000000F0
typedef struct SSMAttributeValue {
CMUint32 type;
union {
SSMResourceID rid;
CMTItem string;
CMInt32 numeric;
} u;
} SSMAttributeValue;
typedef enum {
rsaEnc, rsaDualUse, rsaSign, rsaNonrepudiation, rsaSignNonrepudiation,
dhEx, dsaSignNonrepudiation, dsaSign, dsaNonrepudiation, invalidKeyGen
} SSMKeyGenType;
typedef enum {
ssmUnknownPolicy= -1,ssmDomestic=0, ssmExport=1, ssmFrance=2
} SSMPolicyType;
/* These are the localized strings that PSM can feed back to
* the plug-in. These will initially be used by the plug-in for
* JavaScript purposes to pop up alert/confirm dialogs that would
* cause nightmares to do if we sent UI events.
*/
typedef enum {
SSM_STRING_BAD_PK11_LIB_PARAM,
SSM_STRING_BAD_PK11_LIB_PATH,
SSM_STRING_ADD_MOD_SUCCESS,
SSM_STRING_DUP_MOD_FAILURE,
SSM_STRING_ADD_MOD_FAILURE,
SSM_STRING_BAD_MOD_NAME,
SSM_STRING_EXT_MOD_DEL,
SSM_STRING_INT_MOD_DEL,
SSM_STRING_MOD_DEL_FAIL,
SSM_STRING_ADD_MOD_WARN,
SSM_STRING_MOD_PROMPT,
SSM_STRING_DLL_PROMPT,
SSM_STRING_DEL_MOD_WARN,
SSM_STRING_INVALID_CRL,
SSM_STRING_INVALID_CKL,
SSM_STRING_ROOT_CKL_CERT_NOT_FOUND,
SSM_STRING_BAD_CRL_SIGNATURE,
SSM_STRING_BAD_CKL_SIGNATURE,
SSM_STRING_ERR_ADD_CRL,
SSM_STRING_ERR_ADD_CKL,
SSM_STRING_JAVASCRIPT_DISABLED
} SSMLocalizedString;
/* Event types */
#define SSM_UI_EVENT 0x00001000
#define SSM_TASK_COMPLETED_EVENT 0x00002000
#define SSM_FILE_PATH_EVENT 0x00003000
#define SSM_PROMPT_EVENT 0x00004000
#define SSM_AUTH_EVENT 0x00007000
#define SSM_SAVE_PREF_EVENT 0x00008000
#define SSM_MISC_EVENT 0x0000f000
/* Flags used in Create SSL Data request */
#define SSM_REQUEST_SSL_DATA_SSL 0x00000001
#define SSM_REQUEST_SSL_DATA_PROXY 0x00000002
#define SSM_REQUEST_SSL_CONNECTION_MASK 0x00000003
/* Create typedefs for the various #defines */
typedef CMUint32 SSMMessageCategory;
typedef CMUint32 SSMMessageType;
typedef CMUint32 SSMDataConnectionSType;
typedef CMUint32 SSMObjSignSType;
typedef CMUint32 SSMResourceAccessSType;
typedef CMUint32 SSMCreateResource;
typedef CMUint32 SSMResourceAttrType;
typedef CMUint32 SSMResourceConsv;
typedef CMUint32 SSMCertAccessSType;
typedef CMUint32 SSMKeyGenTagProcessType;
typedef CMUint32 SSMPKCS11Actions;
typedef CMUint32 SSMCRMFAction;
typedef CMUint32 SSMFormSignAction;
typedef CMUint32 SSMSecCfgAction;
typedef CMUint32 SSMSecCfgFindByType;
typedef CMUint32 SSMSecCfgGetCertPropType;
typedef CMUint32 SSMMiscRequestType;
typedef CMUint32 SSMMessageMaskType;
typedef CMUint32 SSMEventType;
typedef CMUint32 SSMSSLConnectionRequestType;
/*
* This string is version that can be used to assemble any
* version information by the apllication using the protocol
* library.
*/
extern char SSMVersionString[];
/* What type of client */
typedef enum
{
SSM_NOINFO,
SSM_COMPOSE,
SSM_MAIL_MESSAGE,
SSM_NEWS_MESSAGE,
SSM_SNEWS_MESSAGE,
SSM_BROWSER
} SSMClientType;
#endif /* __SSMDEFS_H__ */

View File

@@ -1,628 +0,0 @@
/* -*- 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.
*/
#include "stddef.h"
#include "messages.h"
CMTMessageTemplate SingleNumMessageTemplate[] =
{
{ CMT_DT_INT, offsetof(SingleNumMessage, value) },
{ CMT_DT_END }
};
CMTMessageTemplate SingleStringMessageTemplate[] =
{
{ CMT_DT_STRING, offsetof(SingleStringMessage, string) },
{ CMT_DT_END }
};
CMTMessageTemplate SingleItemMessageTemplate[] =
{
{ CMT_DT_ITEM, offsetof(SingleItemMessage, item) },
{ CMT_DT_END }
};
CMTMessageTemplate HelloRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(HelloRequest, version) },
{ CMT_DT_INT, offsetof(HelloRequest, policy) },
{ CMT_DT_BOOL, offsetof(HelloRequest, doesUI) },
{ CMT_DT_STRING, offsetof(HelloRequest, profile) },
{ CMT_DT_STRING, offsetof(HelloRequest, profileDir) },
{ CMT_DT_END }
};
CMTMessageTemplate HelloReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(HelloReply, result) },
{ CMT_DT_INT, offsetof(HelloReply, sessionID) },
{ CMT_DT_INT, offsetof(HelloReply, version) },
{ CMT_DT_STRING, offsetof(HelloReply, stringVersion) },
{ CMT_DT_INT, offsetof(HelloReply, httpPort) },
{ CMT_DT_INT, offsetof(HelloReply, policy) },
{ CMT_DT_ITEM, offsetof(HelloReply, nonce) },
{ CMT_DT_END }
};
CMTMessageTemplate SSLDataConnectionRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(SSLDataConnectionRequest, flags) },
{ CMT_DT_INT, offsetof(SSLDataConnectionRequest, port) },
{ CMT_DT_STRING, offsetof(SSLDataConnectionRequest, hostIP) },
{ CMT_DT_STRING, offsetof(SSLDataConnectionRequest, hostName) },
{ CMT_DT_BOOL, offsetof(SSLDataConnectionRequest, forceHandshake) },
{ CMT_DT_ITEM, offsetof(SSLDataConnectionRequest, clientContext) },
{ CMT_DT_END }
};
CMTMessageTemplate TLSDataConnectionRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(TLSDataConnectionRequest, port) },
{ CMT_DT_STRING, offsetof(TLSDataConnectionRequest, hostIP) },
{ CMT_DT_STRING, offsetof(TLSDataConnectionRequest, hostName) },
{ CMT_DT_END }
};
CMTMessageTemplate TLSStepUpRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(TLSStepUpRequest, connID) },
{ CMT_DT_ITEM, offsetof(TLSStepUpRequest, clientContext) },
{ CMT_DT_END }
};
CMTMessageTemplate ProxyStepUpRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(ProxyStepUpRequest, connID) },
{ CMT_DT_ITEM, offsetof(ProxyStepUpRequest, clientContext) },
{ CMT_DT_STRING, offsetof(ProxyStepUpRequest, url) },
{ CMT_DT_END }
};
CMTMessageTemplate PKCS7DataConnectionRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(PKCS7DataConnectionRequest, resID) },
{ CMT_DT_ITEM, offsetof(PKCS7DataConnectionRequest, clientContext) },
{ CMT_DT_END }
};
CMTMessageTemplate DataConnectionReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(DataConnectionReply, result) },
{ CMT_DT_INT, offsetof(DataConnectionReply, connID) },
{ CMT_DT_INT, offsetof(DataConnectionReply, port) },
{ CMT_DT_END }
};
CMTMessageTemplate UIEventTemplate[] =
{
{ CMT_DT_INT, offsetof(UIEvent, resourceID) },
{ CMT_DT_INT, offsetof(UIEvent, width) },
{ CMT_DT_INT, offsetof(UIEvent, height) },
{ CMT_DT_BOOL, offsetof(UIEvent, isModal) },
{ CMT_DT_STRING, offsetof(UIEvent, url) },
{ CMT_DT_ITEM, offsetof(UIEvent, clientContext) },
{ CMT_DT_END }
};
/*
* The old UI Event was missing the modal indication.
* As a transition aid, we use the old template if the
* "modern" version doesn't work. Model is true in that case
*/
CMTMessageTemplate OldUIEventTemplate[] =
{
{ CMT_DT_INT, offsetof(UIEvent, resourceID) },
{ CMT_DT_INT, offsetof(UIEvent, width) },
{ CMT_DT_INT, offsetof(UIEvent, height) },
{ CMT_DT_STRING, offsetof(UIEvent, url) },
{ CMT_DT_ITEM, offsetof(UIEvent, clientContext) },
{ CMT_DT_END }
};
CMTMessageTemplate TaskCompletedEventTemplate[] =
{
{ CMT_DT_INT, offsetof(TaskCompletedEvent, resourceID) },
{ CMT_DT_INT, offsetof(TaskCompletedEvent, numTasks) },
{ CMT_DT_INT, offsetof(TaskCompletedEvent, result) },
{ CMT_DT_END }
};
CMTMessageTemplate VerifyDetachedSigRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(VerifyDetachedSigRequest, pkcs7ContentID) },
{ CMT_DT_INT, offsetof(VerifyDetachedSigRequest, certUsage) },
{ CMT_DT_INT, offsetof(VerifyDetachedSigRequest, hashAlgID) },
{ CMT_DT_BOOL, offsetof(VerifyDetachedSigRequest, keepCert) },
{ CMT_DT_ITEM, offsetof(VerifyDetachedSigRequest, hash) },
{ CMT_DT_END }
};
CMTMessageTemplate CreateSignedRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(CreateSignedRequest, scertRID) },
{ CMT_DT_INT, offsetof(CreateSignedRequest, ecertRID) },
{ CMT_DT_INT, offsetof(CreateSignedRequest, dig_alg) },
{ CMT_DT_ITEM, offsetof(CreateSignedRequest, digest) },
{ CMT_DT_END }
};
CMTMessageTemplate CreateContentInfoReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(CreateContentInfoReply, ciRID) },
{ CMT_DT_INT, offsetof(CreateContentInfoReply, result) },
{ CMT_DT_INT, offsetof(CreateContentInfoReply, errorCode) },
{ CMT_DT_END }
};
CMTMessageTemplate CreateEncryptedRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(CreateEncryptedRequest, scertRID) },
{ CMT_DT_LIST, offsetof(CreateEncryptedRequest, nrcerts) },
{ CMT_DT_INT, offsetof(CreateEncryptedRequest, rcertRIDs) },
{ CMT_DT_END }
};
CMTMessageTemplate CreateResourceRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(CreateResourceRequest, type) },
{ CMT_DT_ITEM, offsetof(CreateResourceRequest, params) },
{ CMT_DT_END }
};
CMTMessageTemplate CreateResourceReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(CreateResourceReply, result) },
{ CMT_DT_INT, offsetof(CreateResourceReply, resID) },
{ CMT_DT_END }
};
CMTMessageTemplate GetAttribRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(GetAttribRequest, resID) },
{ CMT_DT_INT, offsetof(GetAttribRequest, fieldID) },
{ CMT_DT_END }
};
CMTMessageTemplate GetAttribReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(GetAttribReply, result) },
{ CMT_DT_CHOICE, offsetof(GetAttribReply, value.type) },
{ CMT_DT_RID, offsetof(GetAttribReply, value.u.rid), 0, SSM_RID_ATTRIBUTE },
{ CMT_DT_INT, offsetof(GetAttribReply, value.u.numeric), 0,
SSM_NUMERIC_ATTRIBUTE },
{ CMT_DT_ITEM, offsetof(GetAttribReply, value.u.string), 0,
SSM_STRING_ATTRIBUTE},
{ CMT_DT_END_CHOICE },
{ CMT_DT_END }
};
CMTMessageTemplate SetAttribRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(SetAttribRequest, resID) },
{ CMT_DT_INT, offsetof(SetAttribRequest, fieldID) },
{ CMT_DT_CHOICE, offsetof(SetAttribRequest, value.type) },
{ CMT_DT_RID, offsetof(SetAttribRequest, value.u.rid), 0, SSM_RID_ATTRIBUTE },
{ CMT_DT_INT, offsetof(SetAttribRequest, value.u.numeric), 0,
SSM_NUMERIC_ATTRIBUTE },
{ CMT_DT_ITEM, offsetof(SetAttribRequest, value.u.string), 0,
SSM_STRING_ATTRIBUTE},
{ CMT_DT_END_CHOICE },
{ CMT_DT_END }
};
CMTMessageTemplate PickleResourceReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(PickleResourceReply, result) },
{ CMT_DT_ITEM, offsetof(PickleResourceReply, blob) },
{ CMT_DT_END }
};
CMTMessageTemplate UnpickleResourceRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(UnpickleResourceRequest, resourceType) },
{ CMT_DT_ITEM, offsetof(UnpickleResourceRequest, resourceData) },
{ CMT_DT_END }
};
CMTMessageTemplate UnpickleResourceReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(UnpickleResourceReply, result) },
{ CMT_DT_INT, offsetof(UnpickleResourceReply, resID) },
{ CMT_DT_END }
};
CMTMessageTemplate PickleSecurityStatusReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(PickleSecurityStatusReply, result) },
{ CMT_DT_INT, offsetof(PickleSecurityStatusReply, securityLevel) },
{ CMT_DT_ITEM, offsetof(PickleSecurityStatusReply, blob) },
{ CMT_DT_END }
};
CMTMessageTemplate DupResourceReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(DupResourceReply, result) },
{ CMT_DT_RID, offsetof(DupResourceReply, resID), 0, SSM_RID_ATTRIBUTE },
{ CMT_DT_END }
};
CMTMessageTemplate DestroyResourceRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(DestroyResourceRequest, resID) },
{ CMT_DT_INT, offsetof(DestroyResourceRequest, resType) },
{ CMT_DT_END }
};
CMTMessageTemplate VerifyCertRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(VerifyCertRequest, resID) },
{ CMT_DT_INT, offsetof(VerifyCertRequest, certUsage) },
{ CMT_DT_END }
};
CMTMessageTemplate AddTempCertToDBRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(AddTempCertToDBRequest, resID) },
{ CMT_DT_STRING, offsetof(AddTempCertToDBRequest, nickname) },
{ CMT_DT_INT, offsetof(AddTempCertToDBRequest, sslFlags) },
{ CMT_DT_INT, offsetof(AddTempCertToDBRequest, emailFlags) },
{ CMT_DT_INT, offsetof(AddTempCertToDBRequest, objSignFlags) },
{ CMT_DT_END }
};
CMTMessageTemplate MatchUserCertRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(MatchUserCertRequest, certType) },
{ CMT_DT_LIST, offsetof(MatchUserCertRequest, numCANames) },
{ CMT_DT_STRING, offsetof(MatchUserCertRequest, caNames) },
{ CMT_DT_END }
};
CMTMessageTemplate MatchUserCertReplyTemplate[] =
{
{ CMT_DT_LIST, offsetof(MatchUserCertReply, numCerts) },
{ CMT_DT_INT, offsetof(MatchUserCertReply, certs) },
{ CMT_DT_END }
};
CMTMessageTemplate EncodeCRMFReqRequestTemplate[] =
{
{ CMT_DT_LIST, offsetof(EncodeCRMFReqRequest, numRequests) },
{ CMT_DT_INT, offsetof(EncodeCRMFReqRequest, reqIDs) },
{ CMT_DT_END }
};
CMTMessageTemplate CMMFCertResponseRequestTemplate[] =
{
{ CMT_DT_STRING, offsetof(CMMFCertResponseRequest, nickname) },
{ CMT_DT_STRING, offsetof(CMMFCertResponseRequest, base64Der) },
{ CMT_DT_INT, offsetof(CMMFCertResponseRequest, doBackup) },
{ CMT_DT_ITEM, offsetof(CMMFCertResponseRequest, clientContext) },
{ CMT_DT_END }
};
CMTMessageTemplate PasswordRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(PasswordRequest, tokenKey) },
{ CMT_DT_STRING, offsetof(PasswordRequest, prompt) },
{ CMT_DT_ITEM, offsetof(PasswordRequest, clientContext) },
{ CMT_DT_END }
};
CMTMessageTemplate PasswordReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(PasswordReply, result) },
{ CMT_DT_INT, offsetof(PasswordReply, tokenID) },
{ CMT_DT_STRING, offsetof(PasswordReply, passwd) },
{ CMT_DT_END }
};
CMTMessageTemplate KeyPairGenRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(KeyPairGenRequest, keyGenCtxtID) },
{ CMT_DT_INT, offsetof(KeyPairGenRequest, genMechanism) },
{ CMT_DT_INT, offsetof(KeyPairGenRequest, keySize) },
{ CMT_DT_ITEM, offsetof(KeyPairGenRequest, params) },
{ CMT_DT_END }
};
CMTMessageTemplate DecodeAndCreateTempCertRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(DecodeAndCreateTempCertRequest, type) },
{ CMT_DT_ITEM, offsetof(DecodeAndCreateTempCertRequest, cert) },
{ CMT_DT_END }
};
CMTMessageTemplate GenKeyOldStyleRequestTemplate[] =
{
{ CMT_DT_STRING, offsetof(GenKeyOldStyleRequest, choiceString) },
{ CMT_DT_STRING, offsetof(GenKeyOldStyleRequest, challenge) },
{ CMT_DT_STRING, offsetof(GenKeyOldStyleRequest, typeString) },
{ CMT_DT_STRING, offsetof(GenKeyOldStyleRequest, pqgString) },
{ CMT_DT_END }
};
CMTMessageTemplate GenKeyOldStyleTokenRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(GenKeyOldStyleTokenRequest, rid) },
{ CMT_DT_LIST, offsetof(GenKeyOldStyleTokenRequest, numtokens) },
{ CMT_DT_STRING,offsetof(GenKeyOldStyleTokenRequest, tokenNames)},
{ CMT_DT_END }
};
CMTMessageTemplate GenKeyOldStyleTokenReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(GenKeyOldStyleTokenReply, rid) },
{ CMT_DT_BOOL, offsetof(GenKeyOldStyleTokenReply, cancel) },
{ CMT_DT_STRING, offsetof(GenKeyOldStyleTokenReply, tokenName) },
{ CMT_DT_END }
};
CMTMessageTemplate GenKeyOldStylePasswordRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(GenKeyOldStylePasswordRequest, rid) },
{ CMT_DT_STRING, offsetof(GenKeyOldStylePasswordRequest, tokenName) },
{ CMT_DT_BOOL, offsetof(GenKeyOldStylePasswordRequest, internal) },
{ CMT_DT_INT, offsetof(GenKeyOldStylePasswordRequest, minpwdlen) },
{ CMT_DT_INT, offsetof(GenKeyOldStylePasswordRequest, maxpwdlen) },
{ CMT_DT_END }
};
CMTMessageTemplate GenKeyOldStylePasswordReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(GenKeyOldStylePasswordReply, rid) },
{ CMT_DT_BOOL, offsetof(GenKeyOldStylePasswordReply, cancel) },
{ CMT_DT_STRING, offsetof(GenKeyOldStylePasswordReply, password) },
{ CMT_DT_END }
};
CMTMessageTemplate GetKeyChoiceListRequestTemplate[] =
{
{ CMT_DT_STRING, offsetof(GetKeyChoiceListRequest, type) },
{ CMT_DT_STRING, offsetof(GetKeyChoiceListRequest, pqgString) },
{ CMT_DT_END }
};
CMTMessageTemplate GetKeyChoiceListReplyTemplate[] =
{
{ CMT_DT_LIST, offsetof(GetKeyChoiceListReply, nchoices) },
{ CMT_DT_STRING, offsetof(GetKeyChoiceListReply, choices) },
{ CMT_DT_END }
};
CMTMessageTemplate AddNewSecurityModuleRequestTemplate[] =
{
{ CMT_DT_STRING, offsetof(AddNewSecurityModuleRequest, moduleName) },
{ CMT_DT_STRING, offsetof(AddNewSecurityModuleRequest, libraryPath) },
{ CMT_DT_INT, offsetof(AddNewSecurityModuleRequest, pubMechFlags) },
{ CMT_DT_INT, offsetof(AddNewSecurityModuleRequest, pubCipherFlags) },
{ CMT_DT_END }
};
CMTMessageTemplate FilePathRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(FilePathRequest, resID) },
{ CMT_DT_STRING, offsetof(FilePathRequest, prompt) },
{ CMT_DT_BOOL, offsetof(FilePathRequest, getExistingFile) },
{ CMT_DT_STRING, offsetof(FilePathRequest, fileRegEx) },
{ CMT_DT_END }
};
CMTMessageTemplate FilePathReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(FilePathReply, resID) },
{ CMT_DT_STRING, offsetof(FilePathReply, filePath) },
{ CMT_DT_END }
};
CMTMessageTemplate PasswordPromptReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(PasswordPromptReply, resID) },
{ CMT_DT_STRING, offsetof(PasswordPromptReply, promptReply) },
{ CMT_DT_END }
};
CMTMessageTemplate SignTextRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(SignTextRequest, resID) },
{ CMT_DT_STRING, offsetof(SignTextRequest, stringToSign) },
{ CMT_DT_STRING, offsetof(SignTextRequest, hostName) },
{ CMT_DT_STRING, offsetof(SignTextRequest, caOption) },
{ CMT_DT_LIST, offsetof(SignTextRequest, numCAs) },
{ CMT_DT_STRING, offsetof(SignTextRequest, caNames) },
{ CMT_DT_END }
};
CMTMessageTemplate GetLocalizedTextReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(GetLocalizedTextReply, whichString) },
{ CMT_DT_STRING, offsetof(GetLocalizedTextReply, localizedString) },
{ CMT_DT_END }
};
CMTMessageTemplate ImportCertReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(ImportCertReply, result) },
{ CMT_DT_INT, offsetof(ImportCertReply, resID) },
{ CMT_DT_END }
};
CMTMessageTemplate PromptRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(PromptRequest, resID) },
{ CMT_DT_STRING, offsetof(PromptRequest, prompt) },
{ CMT_DT_ITEM, offsetof(PromptRequest, clientContext) },
{ CMT_DT_END }
};
CMTMessageTemplate PromptReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(PromptReply, resID) },
{ CMT_DT_BOOL, offsetof(PromptReply, cancel) },
{ CMT_DT_STRING, offsetof(PromptReply, promptReply) },
{ CMT_DT_END }
};
CMTMessageTemplate RedirectCompareRequestTemplate[] =
{
{ CMT_DT_ITEM, offsetof(RedirectCompareRequest, socketStatus1Data) },
{ CMT_DT_ITEM, offsetof(RedirectCompareRequest, socketStatus2Data) },
{ CMT_DT_END }
};
CMTMessageTemplate DecodeAndAddCRLRequestTemplate[] =
{
{ CMT_DT_ITEM, offsetof(DecodeAndAddCRLRequest, derCrl) },
{ CMT_DT_INT, offsetof(DecodeAndAddCRLRequest, type) },
{ CMT_DT_STRING, offsetof(DecodeAndAddCRLRequest, url) },
{ CMT_DT_END }
};
CMTMessageTemplate SecurityAdvisorRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(SecurityAdvisorRequest, infoContext) },
{ CMT_DT_INT, offsetof(SecurityAdvisorRequest, resID) },
{ CMT_DT_STRING, offsetof(SecurityAdvisorRequest, hostname) },
{ CMT_DT_STRING, offsetof(SecurityAdvisorRequest, senderAddr) },
{ CMT_DT_INT, offsetof(SecurityAdvisorRequest, encryptedP7CInfo) },
{ CMT_DT_INT, offsetof(SecurityAdvisorRequest, signedP7CInfo) },
{ CMT_DT_INT, offsetof(SecurityAdvisorRequest, decodeError) },
{ CMT_DT_INT, offsetof(SecurityAdvisorRequest, verifyError) },
{ CMT_DT_BOOL, offsetof(SecurityAdvisorRequest, encryptthis) },
{ CMT_DT_BOOL, offsetof(SecurityAdvisorRequest, signthis) },
{ CMT_DT_LIST, offsetof(SecurityAdvisorRequest, numRecipients) },
{ CMT_DT_STRING, offsetof(SecurityAdvisorRequest, recipients) },
{ CMT_DT_END }
};
CMTMessageTemplate SCAddTempCertToPermDBRequestTemplate[] =
{
{ CMT_DT_ITEM, offsetof(SCAddTempCertToPermDBRequest, certKey) },
{ CMT_DT_STRING, offsetof(SCAddTempCertToPermDBRequest, trustStr) },
{ CMT_DT_STRING, offsetof(SCAddTempCertToPermDBRequest, nickname) },
{ CMT_DT_END }
};
CMTMessageTemplate SCDeletePermCertsRequestTemplate[] =
{
{ CMT_DT_ITEM, offsetof(SCDeletePermCertsRequest, certKey) },
{ CMT_DT_BOOL, offsetof(SCDeletePermCertsRequest, deleteAll) },
{ CMT_DT_END }
};
CMTMessageTemplate TimeMessageTemplate[] =
{
{ CMT_DT_INT, offsetof(TimeMessage, year) },
{ CMT_DT_INT, offsetof(TimeMessage, month) },
{ CMT_DT_INT, offsetof(TimeMessage, day) },
{ CMT_DT_INT, offsetof(TimeMessage, hour) },
{ CMT_DT_INT, offsetof(TimeMessage, minute) },
{ CMT_DT_INT, offsetof(TimeMessage, second) },
{ CMT_DT_END }
};
CMTMessageTemplate SCCertIndexEnumReplyTemplate[] =
{
{ CMT_DT_INT, offsetof(SCCertIndexEnumReply, length) },
{ CMT_DT_STRUCT_PTR, offsetof(SCCertIndexEnumReply, list) },
{ CMT_DT_STRING, offsetof(CertEnumElement, name) },
{ CMT_DT_ITEM, offsetof(CertEnumElement, certKey) },
{ CMT_DT_END_STRUCT_LIST },
{ CMT_DT_END }
};
/* Test template */
CMTMessageTemplate TestListTemplate[] =
{
{ CMT_DT_STRING, offsetof(TestList, listName) },
{ CMT_DT_STRUCT_LIST, offsetof(TestList, numElements) },
{ CMT_DT_STRUCT_PTR, offsetof(TestList, elements) },
{ CMT_DT_STRING, offsetof(TestListElement, name) },
{ CMT_DT_STRING, offsetof(TestListElement, value) },
{ CMT_DT_END_STRUCT_LIST},
{ CMT_DT_END}
};
CMTMessageTemplate SetPrefListMessageTemplate[] =
{
{ CMT_DT_STRUCT_LIST, offsetof(SetPrefListMessage, length) },
{ CMT_DT_STRUCT_PTR, offsetof(SetPrefListMessage, list) },
{ CMT_DT_STRING, offsetof(SetPrefElement, key) },
{ CMT_DT_STRING, offsetof(SetPrefElement, value) },
{ CMT_DT_INT, offsetof(SetPrefElement, type) },
{ CMT_DT_END_STRUCT_LIST },
{ CMT_DT_END }
};
CMTMessageTemplate GetPrefListRequestTemplate[] =
{
{ CMT_DT_STRUCT_LIST, offsetof(GetPrefListRequest, length) },
{ CMT_DT_STRUCT_PTR, offsetof(GetPrefListRequest, list) },
{ CMT_DT_STRING, offsetof(GetPrefElement, key) },
{ CMT_DT_INT, offsetof(GetPrefElement, type) },
{ CMT_DT_END_STRUCT_LIST },
{ CMT_DT_END }
};
CMTMessageTemplate GetCertExtensionTemplate[] =
{
{ CMT_DT_INT, offsetof(GetCertExtension, resID) },
{ CMT_DT_INT, offsetof(GetCertExtension, extension) },
{ CMT_DT_END }
};
CMTMessageTemplate HTMLCertInfoRequestTemplate[] =
{
{ CMT_DT_INT, offsetof(HTMLCertInfoRequest, certID) },
{ CMT_DT_INT, offsetof(HTMLCertInfoRequest, showImages) },
{ CMT_DT_INT, offsetof(HTMLCertInfoRequest, showIssuer) },
{ CMT_DT_END }
};
CMTMessageTemplate EncryptRequestTemplate[] =
{
{ CMT_DT_ITEM, offsetof(EncryptRequestMessage, keyid) },
{ CMT_DT_ITEM, offsetof(EncryptRequestMessage, data) },
{ CMT_DT_ITEM, offsetof(EncryptRequestMessage, ctx) },
{ CMT_DT_END }
};
CMTMessageTemplate DecryptRequestTemplate[] =
{
{ CMT_DT_ITEM, offsetof(DecryptRequestMessage, data) },
{ CMT_DT_ITEM, offsetof(DecryptRequestMessage, ctx) },
{ CMT_DT_END }
};

View File

@@ -0,0 +1,28 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

21
mozilla/widget/build.bat Executable file
View File

@@ -0,0 +1,21 @@
rem -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
rem
rem The contents of this file are subject to the Netscape Public License
rem Version 1.0 (the "NPL"); you may not use this file except in
rem compliance with the NPL. You may obtain a copy of the NPL at
rem http://www.mozilla.org/NPL/
rem
rem Software distributed under the NPL is distributed on an "AS IS" basis,
rem WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
rem for the specific language governing rights and limitations under the
rem NPL.
rem
rem The Initial Developer of this code under the NPL is Netscape
rem Communications Corporation. Portions created by Netscape are
rem Copyright (C) 1998 Netscape Communications Corporation. All Rights
rem Reserved.
rem
del s:\ns\raptor\ui\src\windows\win32_d.obj\%1.obj
del s:\ns\raptor\ui\tests\windows\win32_d.obj\winmain.obj
nmake -f makefile.win

View File

@@ -0,0 +1,11 @@
//
// Widget.Prefix
//
// Global prefix file for the Widget project.
//
#include "MacPrefix.h"
#include <Quickdraw.h>
#include <Events.h>
#include <MacWindows.h>

View File

@@ -0,0 +1,11 @@
//
// WidgetDebug.Prefix
//
// Global prefix file for the debug Widget project.
//
#include "MacPrefix_debug.h"
#include <Quickdraw.h>
#include <Events.h>
#include <MacWindows.h>

View File

@@ -0,0 +1,22 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define MAC_SHARED 1
#define _IMPL_NS_WIDGET 1
#include "WidgetDebug.prefix"

View File

@@ -0,0 +1,22 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define MAC_SHARED 1
#define _IMPL_NS_WIDGET 1
#include "Widget.prefix"

View File

@@ -0,0 +1,21 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define MAC_STATIC 1
#include "WidgetDebug.prefix"

View File

@@ -0,0 +1,21 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define MAC_STATIC 1
#include "Widget.prefix"

Binary file not shown.

View File

@@ -0,0 +1,35 @@
# target: widgetDebug.shlb
mozilla/widget/src/mac/nsAppShell.cpp
mozilla/widget/src/mac/nsButton.cpp
mozilla/widget/src/mac/nsCheckButton.cpp
mozilla/widget/src/mac/nsFileWidget.cpp
mozilla/widget/src/mac/nsLookAndFeel.cpp
mozilla/widget/src/mac/nsMacControl.cpp
mozilla/widget/src/mac/nsMacEventHandler.cpp
mozilla/widget/src/mac/nsMacMessagePump.cpp
mozilla/widget/src/mac/nsMacMessageSink.cpp
mozilla/widget/src/mac/nsMacWindow.cpp
mozilla/widget/src/mac/nsMenu.cpp
mozilla/widget/src/mac/nsMenuBar.cpp
mozilla/widget/src/mac/nsMenuItem.cpp
mozilla/widget/src/mac/nsRadioButton.cpp
mozilla/widget/src/mac/nsScrollbar.cpp
mozilla/widget/src/mac/nsTextAreaWidget.cpp
mozilla/widget/src/mac/nsTextWidget.cpp
mozilla/widget/src/mac/nsToolkit.cpp
mozilla/widget/src/mac/nsWidgetFactory.cpp
mozilla/widget/src/mac/nsWidgetSupport.cpp
mozilla/widget/src/mac/nsWindow.cpp
mozilla/widget/src/xpwidgets/nsBaseWidget.cpp
mozilla/widget/src/xpwidgets/nsHTColumn.cpp
mozilla/widget/src/xpwidgets/nsHTControlStripItem.cpp
mozilla/widget/src/xpwidgets/nsHTDataModel.cpp
mozilla/widget/src/xpwidgets/nsHTItem.cpp
mozilla/widget/src/xpwidgets/nsHTTreeDataModel.cpp
mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp
mozilla/widget/src/xpwidgets/nsImageButton.cpp
mozilla/widget/src/xpwidgets/nsMenuButton.cpp
mozilla/widget/src/xpwidgets/nsToolbar.cpp
mozilla/widget/src/xpwidgets/nsToolbarItemHolder.cpp
mozilla/widget/src/xpwidgets/nsToolbarManager.cpp
mozilla/widget/src/xpwidgets/nsTreeView.cpp

Binary file not shown.

View File

@@ -0,0 +1,23 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..
DIRS=public timer src
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,33 @@
#
# This is a list of local files which get copied to the mozilla:dist:widget directory
#
nsIDragSessionMac.h
nsIWidget.h
nsIKBStateControl.h
nsIButton.h
nsICheckButton.h
nsIListWidget.h
nsIComboBox.h
nsITextWidget.h
nsITextAreaWidget.h
nsIComboBox.h
nsIListBox.h
nsIScrollbar.h
nsGUIEvent.h
nsIRadioButton.h
nsIMouseListener.h
nsIEventListener.h
nsIFileWidget.h
nsIMenuListener.h
nsWidgetsCID.h
nsILabel.h
nsILookAndFeel.h
nsWidgetSupport.h
nsIMenu.h
nsIMenuBar.h
nsIMenuItem.h
nsIPopUpMenu.h
nsIKeyBindMgr.h
nsStringUtil.h
nsIContextMenu.h

View File

@@ -0,0 +1,16 @@
#
# This is a list of local files which get copied to the mozilla:dist:idl directory
#
nsIAppShell.idl
nsIFilePicker.idl
nsIFileSpecWithUI.idl
nsISound.idl
nsIToolkit.idl
nsITransferable.idl
nsIDragSession.idl
nsIDragService.idl
nsIFormatConverter.idl
nsIClipboard.idl
nsIClipboardOwner.idl
nsIRollupListener.idl

View File

@@ -0,0 +1,92 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = raptor
XPIDL_MODULE = widget
EXPORTS = \
nsIFontSizeIterator.h \
nsIFontNameIterator.h \
nsIFontRetrieverService.h \
nsIMenuBar.h \
nsIMenu.h \
nsIMenuItem.h \
nsIPopUpMenu.h \
nsIFileWidget.h \
nsStringUtil.h \
nsIKBStateControl.h \
nsIButton.h \
nsICheckButton.h \
nsIListWidget.h \
nsIComboBox.h \
nsITextWidget.h \
nsITextAreaWidget.h \
nsIComboBox.h \
nsIListBox.h \
nsIScrollbar.h \
nsGUIEvent.h \
nsIRadioButton.h \
nsIMouseListener.h \
nsIEventListener.h \
nsIMenuListener.h \
nsWidgetsCID.h \
nsILookAndFeel.h \
nsILabel.h \
nsIMenuBar.h \
nsIMenu.h \
nsIMenuItem.h \
nsIPopUpMenu.h \
nsIFontNameIterator.h \
nsIFontSizeIterator.h \
nsIFontRetrieverService.h \
nsIContextMenu.h \
$(NULL)
XPIDLSRCS = \
nsIAppShell.idl \
nsIFilePicker.idl \
nsIFileSpecWithUI.idl \
nsIToolkit.idl \
nsISound.idl \
nsITransferable.idl \
nsIDragSession.idl \
nsIDragService.idl \
nsIFormatConverter.idl \
nsIClipboard.idl \
nsIClipboardOwner.idl \
nsIRollupListener.idl \
nsIWidget.idl \
nsIWindow.idl \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_UI

View File

@@ -0,0 +1,78 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..
DEFINES=-D_IMPL_NS_UI
MODULE=raptor
XPIDL_MODULE=widget
XPIDLSRCS = \
.\nsIAppShell.idl \
.\nsIFilePicker.idl \
.\nsIFileSpecWithUI.idl \
.\nsISound.idl \
.\nsIToolkit.idl \
.\nsITransferable.idl \
.\nsIDragSession.idl \
.\nsIDragService.idl \
.\nsIFormatConverter.idl \
.\nsIClipboard.idl \
.\nsIClipboardOwner.idl \
.\nsIRollupListener.idl \
$(NULL)
EXPORTS=\
nsIFontSizeIterator.h \
nsIFontNameIterator.h \
nsIFontRetrieverService.h \
nsIFileWidget.h \
nsIWidget.h \
nsIKBStateControl.h \
nsIButton.h \
nsICheckButton.h \
nsIListWidget.h \
nsIComboBox.h \
nsITextWidget.h \
nsITextAreaWidget.h \
nsIComboBox.h \
nsIListBox.h \
nsIScrollbar.h \
nsGUIEvent.h \
nsIRadioButton.h \
nsIMouseListener.h \
nsIEventListener.h \
nsIMenuListener.h \
nsWidgetsCID.h \
nsStringUtil.h \
nsILookAndFeel.h \
nsILabel.h \
nsIMenuBar.h \
nsIMenu.h \
nsIMenuItem.h \
nsIContextMenu.h \
nsIPopUpMenu.h \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,509 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsGUIEvent_h__
#define nsGUIEvent_h__
#include "nsPoint.h"
#include "nsRect.h"
class nsIRenderingContext;
class nsIRegion;
class nsIWidget;
class nsIMenuItem;
/**
* Return status for event processors.
*/
enum nsEventStatus {
/// The event is ignored, do default processing
nsEventStatus_eIgnore,
/// The event is consumed, don't do default processing
nsEventStatus_eConsumeNoDefault,
/// The event is consumed, but do default processing
nsEventStatus_eConsumeDoDefault
};
/**
* General event
*/
struct nsEvent {
/// See event struct types
PRUint8 eventStructType;
/// See GUI MESSAGES,
PRUint32 message;
/// in widget relative coordinates, modified to be relative to current view in layout.
nsPoint point;
// in widget relative coordinates, not modified by layout code.
nsPoint refPoint;
/// elapsed time, in milliseconds, from the time the system was started to the time the message was created
PRUint32 time;
// flags to hold event flow stage and capture/bubble cancellation status
PRUint32 flags;
};
/**
* General graphic user interface event
*/
struct nsGUIEvent : public nsEvent {
/// Originator of the event
nsIWidget* widget;
/// Internal platform specific message.
void* nativeMsg;
};
/**
* Window resize event
*/
struct nsSizeEvent : public nsGUIEvent {
/// x,y width, height in pixels (client area)
nsRect *windowSize;
/// width of entire window (in pixels)
PRInt32 mWinWidth;
/// height of entire window (in pixels)
PRInt32 mWinHeight;
};
/**
* Window repaint event
*/
struct nsPaintEvent : public nsGUIEvent {
/// Context to paint in.
nsIRenderingContext *renderingContext;
/// area to paint (should be used instead of rect)
nsIRegion *region;
/// x,y, width, height in pixels of area to paint
nsRect *rect;
};
/**
* Scrollbar event
*/
struct nsScrollbarEvent : public nsGUIEvent {
/// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
PRUint32 position;
};
struct nsInputEvent : public nsGUIEvent {
/// PR_TRUE indicates the shift key is down
PRBool isShift;
/// PR_TRUE indicates the control key is down
PRBool isControl;
/// PR_TRUE indicates the alt key is down
PRBool isAlt;
/// PR_TRUE indicates the meta key is down
/// (or, on Mac, the Command key)
PRBool isMeta;
};
/**
* Mouse event
*/
struct nsMouseEvent : public nsInputEvent {
/// The number of mouse clicks
PRUint32 clickCount;
/// Special return code for MOUSE_ACTIVATE to signal
/// if the target accepts activation (1), or denies it (0)
PRBool acceptActivation;
};
/**
* Keyboard event
*/
struct nsKeyEvent : public nsInputEvent {
/// see NS_VK codes
PRUint32 keyCode;
/// OS translated Unicode char
PRUint32 charCode;
// indicates whether the event signifies a printable character
PRBool isChar;
};
/**
* IME Related Events
*/
struct nsTextRange {
PRUint32 mStartOffset;
PRUint32 mEndOffset;
PRUint32 mRangeType;
};
typedef struct nsTextRange nsTextRange;
typedef nsTextRange* nsTextRangeArray;
struct nsTextEventReply {
nsPoint mCursorPosition;
PRBool mCursorIsCollapsed;
};
typedef struct nsTextEventReply nsTextEventReply;
struct nsTextEvent : public nsInputEvent {
PRUnichar* theText;
nsTextEventReply theReply;
PRUint32 rangeCount;
nsTextRangeArray rangeArray;
PRBool isChar;
};
struct nsCompositionEvent : public nsInputEvent {
PRUint32 compositionMessage;
nsTextEventReply theReply;
};
/**
* Tooltip event
*/
struct nsTooltipEvent : public nsGUIEvent {
/// Index of tooltip area which generated the event. @see SetTooltips in nsIWidget
PRUint32 tipIndex;
};
/**
* MenuItem event
*
* When this event occurs the widget field in nsGUIEvent holds the "target"
* for the event
*/
struct nsMenuEvent : public nsGUIEvent {
nsIMenuItem * mMenuItem;
PRUint32 mCommand;
};
/**
* Event status for D&D Event
*/
enum nsDragDropEventStatus {
/// The event is a enter
nsDragDropEventStatus_eDragEntered,
/// The event is exit
nsDragDropEventStatus_eDragExited,
/// The event is drop
nsDragDropEventStatus_eDrop
};
/**
* Event Struct Types
*/
#define NS_EVENT 1
#define NS_GUI_EVENT 2
#define NS_SIZE_EVENT 3
#define NS_PAINT_EVENT 4
#define NS_SCROLLBAR_EVENT 5
#define NS_INPUT_EVENT 6
#define NS_KEY_EVENT 7
#define NS_MOUSE_EVENT 8
#define NS_MENU_EVENT 10
#define NS_DRAGDROP_EVENT 11
#define NS_TEXT_EVENT 12
#define NS_COMPOSITION_START 13
#define NS_COMPOSITION_END 14
/**
* GUI MESSAGES
*/
//@{
#define NS_WINDOW_START 100
// Widget is being created
#define NS_CREATE (NS_WINDOW_START)
// Widget is being destroyed
#define NS_DESTROY (NS_WINDOW_START + 1)
// Widget was resized
#define NS_SIZE (NS_WINDOW_START + 2)
// Widget gained focus
#define NS_GOTFOCUS (NS_WINDOW_START + 3)
// Widget lost focus
#define NS_LOSTFOCUS (NS_WINDOW_START + 4)
// Widget got activated
#define NS_ACTIVATE (NS_WINDOW_START + 5)
// Widget got deactivated
#define NS_DEACTIVATE (NS_WINDOW_START + 6)
// Widget needs to be repainted
#define NS_PAINT (NS_WINDOW_START + 30)
// Key is pressed within a window
#define NS_KEY_PRESS (NS_WINDOW_START + 31)
// Key is released within a window
#define NS_KEY_UP (NS_WINDOW_START + 32)
// Key is pressed within a window
#define NS_KEY_DOWN (NS_WINDOW_START + 33)
// Window has been moved to a new location.
// The events point contains the x, y location in screen coordinates
#define NS_MOVE (NS_WINDOW_START + 34)
// Tab control's selected tab has changed
#define NS_TABCHANGE (NS_WINDOW_START + 35)
// Menu item selected
#define NS_MENU_SELECTED (NS_WINDOW_START + 38)
// Form control changed: currently == combo box selection changed
// but could be expanded to mean textbox, checkbox changed, etc.
// This is a GUI specific event that does not necessarily correspond
// directly to a mouse click or a key press.
#define NS_CONTROL_CHANGE (NS_WINDOW_START + 39)
// Indicates the display has changed depth
#define NS_DISPLAYCHANGED (NS_WINDOW_START + 40)
#define NS_MOUSE_MESSAGE_START 300
#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
#define NS_MOUSE_LEFT_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
#define NS_MOUSE_LEFT_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
#define NS_MOUSE_MIDDLE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 10)
#define NS_MOUSE_MIDDLE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 11)
#define NS_MOUSE_RIGHT_BUTTON_UP (NS_MOUSE_MESSAGE_START + 20)
#define NS_MOUSE_RIGHT_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 21)
#define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
#define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
#define NS_MOUSE_LEFT_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
#define NS_MOUSE_MIDDLE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 25)
#define NS_MOUSE_RIGHT_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 26)
#define NS_MOUSE_LEFT_CLICK (NS_MOUSE_MESSAGE_START + 27)
#define NS_MOUSE_MIDDLE_CLICK (NS_MOUSE_MESSAGE_START + 28)
#define NS_MOUSE_RIGHT_CLICK (NS_MOUSE_MESSAGE_START + 29)
#define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
#define NS_SCROLLBAR_MESSAGE_START 1000
#define NS_SCROLLBAR_POS (NS_SCROLLBAR_MESSAGE_START)
#define NS_SCROLLBAR_PAGE_NEXT (NS_SCROLLBAR_MESSAGE_START + 1)
#define NS_SCROLLBAR_PAGE_PREV (NS_SCROLLBAR_MESSAGE_START + 2)
#define NS_SCROLLBAR_LINE_NEXT (NS_SCROLLBAR_MESSAGE_START + 3)
#define NS_SCROLLBAR_LINE_PREV (NS_SCROLLBAR_MESSAGE_START + 4)
#define NS_STREAM_EVENT_START 1100
#define NS_PAGE_LOAD (NS_STREAM_EVENT_START)
#define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
#define NS_IMAGE_LOAD (NS_STREAM_EVENT_START + 2)
#define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
#define NS_IMAGE_ERROR (NS_STREAM_EVENT_START + 4)
#define NS_FORM_EVENT_START 1200
#define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
#define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
#define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
#define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
#define NS_FORM_INPUT (NS_FORM_EVENT_START + 4)
//Need separate focus/blur notifications for non-native widgets
#define NS_FOCUS_EVENT_START 1300
#define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
#define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
#define NS_DRAGDROP_EVENT_START 1400
#define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
#define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
#define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
#define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 3)
#define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
// Events for popups
#define NS_MENU_EVENT_START 1500
#define NS_MENU_CREATE (NS_MENU_EVENT_START)
#define NS_MENU_DESTROY (NS_MENU_EVENT_START+1)
#define NS_MENU_ACTION (NS_MENU_EVENT_START+2)
#define NS_XUL_BROADCAST (NS_MENU_EVENT_START+3)
#define NS_XUL_COMMAND_UPDATE (NS_MENU_EVENT_START+4)
//@}
#define NS_IS_MOUSE_EVENT(evnt) \
(((evnt)->message == NS_MOUSE_LEFT_BUTTON_DOWN) || \
((evnt)->message == NS_MOUSE_LEFT_BUTTON_UP) || \
((evnt)->message == NS_MOUSE_LEFT_CLICK) || \
((evnt)->message == NS_MOUSE_LEFT_DOUBLECLICK) || \
((evnt)->message == NS_MOUSE_MIDDLE_BUTTON_DOWN) || \
((evnt)->message == NS_MOUSE_MIDDLE_BUTTON_UP) || \
((evnt)->message == NS_MOUSE_MIDDLE_CLICK) || \
((evnt)->message == NS_MOUSE_MIDDLE_DOUBLECLICK) || \
((evnt)->message == NS_MOUSE_RIGHT_BUTTON_DOWN) || \
((evnt)->message == NS_MOUSE_RIGHT_BUTTON_UP) || \
((evnt)->message == NS_MOUSE_RIGHT_CLICK) || \
((evnt)->message == NS_MOUSE_RIGHT_DOUBLECLICK) || \
((evnt)->message == NS_MOUSE_ENTER) || \
((evnt)->message == NS_MOUSE_EXIT) || \
((evnt)->message == NS_MOUSE_MOVE))
#define NS_IS_KEY_EVENT(evnt) \
(((evnt)->message == NS_KEY_DOWN) || \
((evnt)->message == NS_KEY_PRESS) || \
((evnt)->message == NS_KEY_UP))
/*
* Virtual key bindings for keyboard events
* NOTE: These are repeated in nsIDOMEvent.h and must be kept in sync
*/
#define NS_VK_CANCEL 0x03
#define NS_VK_BACK 0x08
#define NS_VK_TAB 0x09
#define NS_VK_CLEAR 0x0C
#define NS_VK_RETURN 0x0D
#define NS_VK_ENTER 0x0E
#define NS_VK_SHIFT 0x10
#define NS_VK_CONTROL 0x11
#define NS_VK_ALT 0x12
#define NS_VK_PAUSE 0x13
#define NS_VK_CAPS_LOCK 0x14
#define NS_VK_ESCAPE 0x1B
#define NS_VK_SPACE 0x20
#define NS_VK_PAGE_UP 0x21
#define NS_VK_PAGE_DOWN 0x22
#define NS_VK_END 0x23
#define NS_VK_HOME 0x24
#define NS_VK_LEFT 0x25
#define NS_VK_UP 0x26
#define NS_VK_RIGHT 0x27
#define NS_VK_DOWN 0x28
#define NS_VK_PRINTSCREEN 0x2C
#define NS_VK_INSERT 0x2D
#define NS_VK_DELETE 0x2E
// NS_VK_0 - NS_VK_9 match their ascii values
#define NS_VK_0 0x30
#define NS_VK_1 0x31
#define NS_VK_2 0x32
#define NS_VK_3 0x33
#define NS_VK_4 0x34
#define NS_VK_5 0x35
#define NS_VK_6 0x36
#define NS_VK_7 0x37
#define NS_VK_8 0x38
#define NS_VK_9 0x39
#define NS_VK_SEMICOLON 0x3B
#define NS_VK_EQUALS 0x3D
// NS_VK_A - NS_VK_Z match their ascii values
#define NS_VK_A 0x41
#define NS_VK_B 0x42
#define NS_VK_C 0x43
#define NS_VK_D 0x44
#define NS_VK_E 0x45
#define NS_VK_F 0x46
#define NS_VK_G 0x47
#define NS_VK_H 0x48
#define NS_VK_I 0x49
#define NS_VK_J 0x4A
#define NS_VK_K 0x4B
#define NS_VK_L 0x4C
#define NS_VK_M 0x4D
#define NS_VK_N 0x4E
#define NS_VK_O 0x4F
#define NS_VK_P 0x50
#define NS_VK_Q 0x51
#define NS_VK_R 0x52
#define NS_VK_S 0x53
#define NS_VK_T 0x54
#define NS_VK_U 0x55
#define NS_VK_V 0x56
#define NS_VK_W 0x57
#define NS_VK_X 0x58
#define NS_VK_Y 0x59
#define NS_VK_Z 0x5A
#define NS_VK_NUMPAD0 0x60
#define NS_VK_NUMPAD1 0x61
#define NS_VK_NUMPAD2 0x62
#define NS_VK_NUMPAD3 0x63
#define NS_VK_NUMPAD4 0x64
#define NS_VK_NUMPAD5 0x65
#define NS_VK_NUMPAD6 0x66
#define NS_VK_NUMPAD7 0x67
#define NS_VK_NUMPAD8 0x68
#define NS_VK_NUMPAD9 0x69
#define NS_VK_MULTIPLY 0x6A
#define NS_VK_ADD 0x6B
#define NS_VK_SEPARATOR 0x6C
#define NS_VK_SUBTRACT 0x6D
#define NS_VK_DECIMAL 0x6E
#define NS_VK_DIVIDE 0x6F
#define NS_VK_F1 0x70
#define NS_VK_F2 0x71
#define NS_VK_F3 0x72
#define NS_VK_F4 0x73
#define NS_VK_F5 0x74
#define NS_VK_F6 0x75
#define NS_VK_F7 0x76
#define NS_VK_F8 0x77
#define NS_VK_F9 0x78
#define NS_VK_F10 0x79
#define NS_VK_F11 0x7A
#define NS_VK_F12 0x7B
#define NS_VK_F13 0x7C
#define NS_VK_F14 0x7D
#define NS_VK_F15 0x7E
#define NS_VK_F16 0x7F
#define NS_VK_F17 0x80
#define NS_VK_F18 0x81
#define NS_VK_F19 0x82
#define NS_VK_F20 0x83
#define NS_VK_F21 0x84
#define NS_VK_F22 0x85
#define NS_VK_F23 0x86
#define NS_VK_F24 0x87
#define NS_VK_NUM_LOCK 0x90
#define NS_VK_SCROLL_LOCK 0x91
#define NS_VK_COMMA 0xBC
#define NS_VK_PERIOD 0xBE
#define NS_VK_SLASH 0xBF
#define NS_VK_BACK_QUOTE 0xC0
#define NS_VK_OPEN_BRACKET 0xDB
#define NS_VK_BACK_SLASH 0xDC
#define NS_VK_CLOSE_BRACKET 0xDD
#define NS_VK_QUOTE 0xDE
#define NS_EVENT_FLAG_NONE 0x0000
#define NS_EVENT_FLAG_INIT 0x0001
#define NS_EVENT_FLAG_BUBBLE 0x0002
#define NS_EVENT_FLAG_CAPTURE 0x0004
#define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
#define NS_EVENT_FLAG_NO_DEFAULT 0x0010
// IME Constants -- keep in synch with nsIDOMTextRange.h
#define NS_TEXTRANGE_CARETPOSITION 0x01
#define NS_TEXTRANGE_RAWINPUT 0X02
#define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
#define NS_TEXTRANGE_CONVERTEDTEXT 0x04
#define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
#endif // nsGUIEvent_h__

View File

@@ -0,0 +1,122 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
#include "nsISupports.idl"
native int(int);
[ptr] native nsDispatchListener(nsDispatchListener);
[ptr] native nsIEventQueue(nsIEventQueue);
[ptr] native UndefinednsIWidget(nsIWidget);
[ref] native PRBoolRef(PRBool);
[ref] native voidStarRef(void *);
%{ C++
#include "nsIEventQueue.h"
/**
* Flags for the getNativeData function.
* See GetNativeData()
*/
#define NS_NATIVE_SHELL 0
/**
* During the nsIAppShell Run method notify this listener
* after each message dispatch.
* @see SetDispatchListener member function of nsIAppShell
*/
class nsDispatchListener {
public:
virtual void AfterDispatch() = 0;
};
class nsIWidget;
%}
[uuid(a0757c31-eeac-11d1-9ec1-00aa002fb821)]
interface nsIAppShell : nsISupports
{
/**
* Creates an application shell
*/
void Create(inout int argc, inout string argv);
/**
* Enter an event loop.
* Don't leave until application exits.
*/
void Run();
/**
* Prepare to process events.
*/
void Spinup();
/**
* Prepare to stop processing events.
*/
void Spindown();
/**
* An event queue has been created or destroyed. Hook or unhook it from
* your system, as necessary.
* @param aQueue the queue in question
* @param aListen PR_TRUE for a new queue wanting hooking up. PR_FALSE
* for a queue wanting to be unhooked.
*/
void ListenToEventQueue(in nsIEventQueue aQueue, in PRBool aListen);
/**
* After event dispatch execute app specific code
*/
void GetNativeEvent(in PRBoolRef aRealEvent, in voidStarRef aEvent);
/**
* After event dispatch execute app specific code
*/
void DispatchNativeEvent(in PRBool aRealEvent, in voidStar aEvent);
/**
* After event dispatch execute app specific code
*/
void SetDispatchListener(in nsDispatchListener aDispatchListener);
/**
* Exit the handle event loop
*/
void Exit();
};
#endif // nsIAppShell_h__

View File

@@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIButton_h__
#define nsIButton_h__
#include "nsIWidget.h"
#include "nsString.h"
// {18032AD0-B265-11d1-AA2A-000000000000}
#define NS_IBUTTON_IID \
{ 0x18032ad0, 0xb265, 0x11d1, \
{ 0xaa, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
/**
* Push button widget.
* Automatically shows itself as depressed when clicked on.
*/
class nsIButton : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IBUTTON_IID)
/**
* Set the label
*
* @param Set the label to aText
* @result NS_Ok if no errors
*/
NS_IMETHOD SetLabel(const nsString &aText) = 0;
/**
* Get the button label
*
* @param aBuffer contains label upon return
* @result NS_Ok if no errors
*/
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
};
#endif

View File

@@ -0,0 +1,81 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsICheckButton_h__
#define nsICheckButton_h__
// {961085F5-BD28-11d1-97EF-00609703C14E}
#define NS_ICHECKBUTTON_IID \
{ 0x961085f5, 0xbd28, 0x11d1, { 0x97, 0xef, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
#include "nsISupports.h"
#include "nsIWidget.h"
/**
* Checkbox widget.
* Can show itself in a checked or unchecked state.
* The checkbox widget does not automatically show itself checked or unchecked when clicked on.
*/
class nsICheckButton : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICHECKBUTTON_IID)
/**
* Set the button label
*
* @param aText button label
* @result set to NS_OK if method successful
*/
NS_IMETHOD SetLabel(const nsString &aText) = 0;
/**
* Get the button label
*
* @param aBuffer contains label upon return
* @result set to NS_OK if method successful
*/
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
/**
* Set the check state.
* @param aState PR_TRUE show as checked. PR_FALSE show unchecked.
* @result set to NS_OK if method successful
*/
NS_IMETHOD SetState(const PRBool aState) = 0;
/**
* Get the check state.
* @param aState PR_TRUE if checked. PR_FALSE if unchecked.
* @result set to NS_OK if method successful
*/
NS_IMETHOD GetState(PRBool& aState) = 0;
};
#endif // nsICheckButton_h__

View File

@@ -0,0 +1,88 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Mozilla Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
* Mike Pinkerton
*/
#include "nsISupports.idl"
#include "nsISupportsArray.idl"
#include "nsITransferable.idl"
#include "nsIClipboardOwner.idl"
[scriptable, uuid(8B5314BA-DB01-11d2-96CE-0060B0FB9956)]
interface nsIClipboard : nsISupports
{
/**
* Given a transferable, set the data on the native clipboard
*
* @param aTransferable The transferable
* @param anOwner The owner of the transferable
* @result NS_Ok if no errors
*/
void setData ( in nsITransferable aTransferable, in nsIClipboardOwner anOwner) ;
/**
* Given a transferable, get the clipboard data.
*
* @param aTransferable The transferable
* @result NS_Ok if no errors
*/
void getData ( in nsITransferable aTransferable ) ;
/**
* This empties the clipboard and notifies the clipboard owner.
* This empties the "logical" clipboard. It does not clear the native clipboard.
*
* @result NS_OK if successful.
*/
void emptyClipboard ( ) ;
/**
* Some platforms support deferred notification for putting data on the clipboard
* This method forces the data onto the clipboard in its various formats
* This may be used if the application going away.
*
* @result NS_OK if successful.
*/
void forceDataToClipboard ( ) ;
/**
* This provides a way to give correct UI feedback about, for instance, a paste
* should be allowed. It does _NOT_ actually retreive the data and should be a very
* inexpensive call. All it does is check if there is data on the clipboard matching
* any of the flavors in the given list.
*
* @aFlavorList - nsISupportsString's in a nsISupportsArray (for JavaScript).
* @outResult - if data is present matching one of
* @result NS_OK if successful.
*/
boolean hasDataMatchingFlavors ( in nsISupportsArray aFlavorList ) ;
};
%{ C++
%}

View File

@@ -0,0 +1,45 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Mozilla Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
* Mike Pinkerton
*/
#include "nsISupports.idl"
#include "nsITransferable.idl"
[scriptable, uuid(5A31C7A1-E122-11d2-9A57-000064657374)]
interface nsIClipboardOwner : nsISupports
{
/**
* Notifies the owner of the clipboard transferable that the
* transferable is being removed from the clipboard
*
* @param aTransferable The transferable
* @result NS_Ok if no errors
*/
void LosingOwnership ( in nsITransferable aTransferable ) ;
};
%{ C++
%}

View File

@@ -0,0 +1,141 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIComboBox_h__
#define nsIComboBox_h__
#include "nsIListWidget.h"
#include "nsString.h"
// {961085F6-BD28-11d1-97EF-00609703C14E}
#define NS_ICOMBOBOX_IID \
{ 0x961085f6, 0xbd28, 0x11d1, { 0x97, 0xef, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
/**
* Initialize combobox data
*/
struct nsComboBoxInitData : public nsWidgetInitData {
nsComboBoxInitData()
: mDropDownHeight(0)
{
}
PRUint32 mDropDownHeight; // in pixels
};
/**
* Single selection drop down list. See nsIListWidget for capabilities
*/
class nsIComboBox : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOMBOBOX_IID);
/**
* Set an item at the specific position
*
* @param aItem the item name. The item has to be null terminated
* @param aPosition the position the item should be inserted at
* 0 is at the top of the list
* -1 is at the end of the list
*/
NS_IMETHOD AddItemAt(nsString &aItem, PRInt32 aPosition) = 0;
/**
* Finds the first occurrence of the specified item
*
* @param aItem the string to be filled
* @param aStartPos the starting position (index)
* @return PR_TRUE if successful, PR_FALSE otherwise
*
*/
virtual PRInt32 FindItem(nsString &aItem, PRInt32 aStartPos) = 0;
/**
* Returns the number of items in the list
*
* @return the number of items
*
*/
virtual PRInt32 GetItemCount() = 0;
/**
* Remove the first occurrence of the specified item
*
* @param aPosition the item position
* 0 is at the top of the list
* -1 is at the end of the list
*
* @return PR_TRUE if successful, PR_FALSE otherwise
*
*/
virtual PRBool RemoveItemAt(PRInt32 aPosition) = 0;
/**
* Gets an item at a specific location
*
* @param anItem on return contains the string of the item at that position
* @param aPosition the Position of the item
*
*/
virtual PRBool GetItemAt(nsString& anItem, PRInt32 aPosition) = 0;
/**
* Gets the selected item for a single selection list
*
* @param aItem on return contains the string of the selected item
*
*/
NS_IMETHOD GetSelectedItem(nsString &aItem) = 0;
/**
* Returns with the index of the selected item
*
* @return PRInt32, index of selected item
*
*/
virtual PRInt32 GetSelectedIndex() = 0;
/**
* Select the item at the specified position
*
* @param PRInt32, the item position
* 0 is at the top of the list
* -1 is at the end of the list
*
*/
NS_IMETHOD SelectItem(PRInt32 aPosition) = 0;
/**
* Deselects all the items in the list
*
*/
NS_IMETHOD Deselect() = 0;
};
#endif // nsIComboBox_h__

View File

@@ -0,0 +1,148 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIContextMenu_h__
#define nsIContextMenu_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIWebShell.h"
class nsIMenuBar;
class nsIMenu;
class nsIMenuItem;
class nsIMenuListener;
//Generate this!
// {35A3DEC1-4992-11d2-8DBA-00609703C14E}
#define NS_ICONTEXTMENU_IID \
{ 0x35a3dec1, 0x4992, 0x11d2, \
{ 0x8d, 0xba, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
/**
* Menu widget
*/
class nsIContextMenu : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTEXTMENU_IID)
/**
* Creates the context menu
*
*/
NS_IMETHOD Create(nsISupports * aParent, const nsString& anAlignment, const nsString& anAnchorAlignment) = 0;
/**
* Get the context menu's Parent
*
*/
NS_IMETHOD GetParent(nsISupports *&aParent) = 0;
/**
* Adds a context menu Item
*
*/
NS_IMETHOD AddItem(nsISupports* aItem) = 0;
/**
* Adds a separator
*
*/
NS_IMETHOD AddSeparator() = 0;
/**
* Returns the number of context menu items
* This does count separators as items
*/
NS_IMETHOD GetItemCount(PRUint32 &aCount) = 0;
/**
* Returns a Menu or Menu Item at a specified Index
*
*/
NS_IMETHOD GetItemAt(const PRUint32 aPos, nsISupports *& aMenuItem) = 0;
/**
* Inserts a Menu Item at a specified Index
*
*/
NS_IMETHOD InsertItemAt(const PRUint32 aPos, nsISupports * aMenuItem) = 0;
/**
* Removes an Menu Item from a specified Index
*
*/
NS_IMETHOD RemoveItem(const PRUint32 aPos) = 0;
/**
* Removes all the Menu Items
*
*/
NS_IMETHOD RemoveAll() = 0;
/**
* Gets Native MenuHandle
*
*/
NS_IMETHOD GetNativeData(void** aData) = 0;
/**
* Adds menu listener for dynamic construction
*
*/
NS_IMETHOD AddMenuListener(nsIMenuListener * aMenuListener) = 0;
/**
* Removes menu listener for dynamic construction
*
*/
NS_IMETHOD RemoveMenuListener(nsIMenuListener * aMenuListener) = 0;
/**
* Set location
*
*/
NS_IMETHOD SetLocation(PRInt32 aX, PRInt32 aY) = 0;
/**
* Set DOMNode
*
*/
NS_IMETHOD SetDOMNode(nsIDOMNode * aMenuNode) = 0;
/**
* Set DOMElement
*
*/
NS_IMETHOD SetDOMElement(nsIDOMElement * aMenuElement) = 0;
/**
* Set WebShell
*
*/
NS_IMETHOD SetWebShell(nsIWebShell * aWebShell) = 0;
};
#endif

View File

@@ -0,0 +1,70 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Mozilla Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
* Mike Pinkerton
*/
#include "nsISupports.idl"
#include "nsISupportsArray.idl"
#include "nsIDragSession.idl"
#include "nsIScriptableRegion.idl"
[scriptable, uuid(8B5314BB-DB01-11d2-96CE-0060B0FB9956)]
interface nsIDragService : nsISupports
{
const long DRAGDROP_ACTION_NONE = 0;
const long DRAGDROP_ACTION_COPY = 1;
const long DRAGDROP_ACTION_MOVE = 2;
const long DRAGDROP_ACTION_LINK = 4;
/**
* Starts a modal drag session with an array of transaferables
*
* @param aTransferables - an array of transferables to be dragged
* @param aRegion - a region containing rectangles for cursor feedback,
* in window coordinates.
* @param aActionType - specified which of copy/move/link are allowed
*/
void invokeDragSession ( in nsISupportsArray aTransferables,
in nsIScriptableRegion aRegion, in unsigned long aActionType );
/**
* Returns the current Drag Session
*/
nsIDragSession getCurrentSession ( ) ;
/**
* Tells the Drag Service to start a drag session. This is called when
* an external drag occurs
*/
void startDragSession ( ) ;
/**
* Tells the Drag Service to end a drag session. This is called when
* an external drag occurs
*/
void endDragSession ( ) ;
};
%{ C++
%}

View File

@@ -0,0 +1,80 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Mozilla Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
* Mike Pinkerton
*/
#include "nsISupports.idl"
#include "nsISupportsArray.idl"
#include "nsITransferable.idl"
%{ C++
#include "nsSize.h"
%}
native nsSize (nsSize);
[scriptable, uuid(CBA22C53-FCCE-11d2-96D4-0060B0FB9956)]
interface nsIDragSession : nsISupports
{
/**
* Set the current state of the drag whether it can be dropped or not.
* usually the target "frame" sets this so the native system can render the correct feedback
*/
attribute boolean canDrop;
/**
* Sets the action (copy, move, link, et.c) for the current drag
*/
attribute unsigned long dragAction;
/**
* Sets the current width and height if the drag target area.
* It will contain the current size of the Frame that the drag is currently in
*/
attribute nsSize targetSize;
/**
* Get the number items that were dropped
*/
readonly attribute unsigned long numDropItems;
/**
* Get data from a Drag&Drop. Can be called while the drag is in process
* or after the drop has completed.
*
* @param aTransferable the transferable for the data to be put into
* @param aItemIndex which of multiple drag items, zero-based
*/
void getData ( in nsITransferable aTransferable, in unsigned long aItemIndex ) ;
/**
* Check to set if ant of the native data on the clipboard matches this data flavor
*
* @result NS_OK if if the data flavor is supported and, NS_ERROR_FAILURE is it is not
*/
boolean isDataFlavorSupported ( in string aDataFlavor ) ;
};
%{ C++
%}

View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIDragSessionMac_h__
#define nsIDragSessionMac_h__
#include "nsISupports.h"
#include <Drag.h>
#define NS_IDRAGSESSIONMAC_IID \
{ 0x36c4c380, 0x09e2, 0x11d3, { 0xb0, 0x33, 0xa4, 0x20, 0xf4, 0x2c, 0xfd, 0x7c } };
class nsIDragSessionMac : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAGSESSIONMAC_IID)
/**
* Since the drag may originate in an external application, we need some way of
* communicating the DragManager's DragRef to the session so it can use it
* when filling in data requests.
*
* @param aDragRef the MacOS DragManager's ref number for the current drag
*/
NS_IMETHOD SetDragReference ( DragReference aDragRef ) = 0;
};
#endif

View File

@@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIEventListener_h__
#define nsIEventListener_h__
#include "nsISupports.h"
#include "nsGUIEvent.h"
/**
* Event listener interface.
* Alternative to a callback for recieving events.
*/
// {c83f6b80-d7ce-11d2-8360-c4c894c4917c}
#define NS_IEVENTLISTENER_IID \
{ 0xc83f6b80, 0xd7ce, 0x11d2, { 0x83, 0x60, 0xc4, 0xc8, 0x94, 0xc4, 0x91, 0x7c } }
class nsIEventListener : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IEVENTLISTENER_IID)
/**
* Processes all events.
* If a mouse listener is registered this method will not process mouse events.
* @param anEvent the event to process. See nsGUIEvent.h for event types.
*/
virtual nsEventStatus ProcessEvent(const nsGUIEvent & anEvent) = 0;
};
#endif // nsIEventListener_h__

View File

@@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIFileDialogsMgr_h__
#define nsIFileDialogsMgr_h__
#include "nsISupports.h"
#include "nsFileSpec.h"
// {0ef98781-e34b-11d2-b345-00a0cc3c1cde}
#define NS_IFILEDIALOGSMGR_IID \
{ 0xef98781, 0xe34b, 0x11d2, { 0xb3, 0x45, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }
#define NS_FILEDIALOGSMGR_CID \
{ 0xef98784, 0xe34b, 0x11d2, { 0xb3, 0x45, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }
enum nsFileDlgResults {
nsFileDlgResults_Cancel, // User hit cancel, ignore selection
nsFileDlgResults_OK, // User hit Ok, process selection
nsFileDlgResults_Replace // User acknowledged file already exists so ok to replace, process selection
};
/**
* (native) File Dialogs utility.
* Provides an XP wrapper to platform native file dialogs:
* GetFile - Presents a file browser and returns an nsFileSpec for the selected file
* GetFolder - Presents a folder/path selection dialog and returns an nsFileSpec
* PutFile - Presents a file save dialog to the user and returns an nsFileSpec with
* the name and path to save the file
*
*/
class nsIFileDialogsMgr : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFILEDIALOGSMGR_IID)
NS_IMETHOD GetFile(
nsFileSpec & theFileSpec, // Populate with initial path for file dialog
nsFileDlgResults & theResult, // Result from the file selection dialog prompt
const nsString * promptString, // Window title for file selection dialog
void * filterList) = 0;
NS_IMETHOD GetFolder(
nsFileSpec & theFileSpec, // Populate with initial path for file dialog
nsFileDlgResults & theResult, // Result from the folder selection dialog prompt
const nsString * promptString) = 0; // Window title for folder selection dialog
NS_IMETHOD PutFile(
nsFileSpec & theFileSpec, // Populate with initial path for file dialog
nsFileDlgResults & theResult, // Result from the file save dialog prompt
const nsString * promptString) = 0; // Window title for file save dialog
};
#endif // nsIFileDialogsMgr_h__

View File

@@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
#include "nsISupports.idl"
#include "nsIFileSpec.idl"
interface nsIDOMWindow;
[scriptable, uuid(c47de916-1dd1-11b2-8141-82507fa02b21)]
interface nsIFilePicker : nsISupports
{
const short modeLoad = 0; // Load a file or directory
const short modeSave = 1; // Save a file or directory
const short modeGetFolder = 2; // Select a fodler/directory
const short returnOK = 0; // User hit cancel, ignore selection
const short returnCancel = 1; // User hit Ok, process selection
const short returnReplace = 2; // User acknowledged file already exists so ok to replace, process selection
/**
* Create the file widget.
*
* @param parent nsIDOMWindow parent. This dialog should be dependant on this parent.
* @param title The title for the file widget
* @param mode load, save, or get folder
*
*/
void create(in nsIDOMWindow parent, in wstring title, in short mode);
/**
* Set the list of file filters
*
* @param titles array of filter titles
* @param filters array of filters to associate with titles
* @param numberOfFilters number of filters.
*
*/
void setFilterList(in long numberOfFilters,
[array, size_is(numberOfFilters)] in wstring titles,
[array, size_is(numberOfFilters)] in wstring filters);
/**
* Get the index into the filter list for the type of file the user wants to save
*
* @param selectedFilter the index of the selected item in the filter list
*
*/
readonly attribute long selectedFilter;
/* what is this? */
attribute wstring defaultString;
/**
* Set the directory that the file open/save dialog initially displays
*
* @param displayDirectory the name of the directory
*
*/
attribute nsIFileSpec displayDirectory;
/**
* Get the nsFileSpec for the file or directory.
*
* @return Returns the file currently selected
*/
readonly attribute nsIFileSpec file;
/**
* Show File Dialog. The dialog is displayed modally.
*
* @return returnOK if the user selects OK, returnCancel if the user selects cancel
*
*/
short show();
};

View File

@@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
// This is the only correct cross-platform way to specify a file.
// Strings are not such a way. If you grew up on windows or unix, you
// may think they are. Welcome to reality.
#include "nsIFileSpec.idl"
%{C++
#include "nscore.h" // for NS_WIDGET
#include "nsIComponentManager.h"
%}
native StandardFilterMask(nsIFileSpecWithUI::StandardFilterMask);
[scriptable, uuid(8ddf7681-139a-11d3-915f-dc1f8c138b7c)]
interface nsIFileSpecWithUI : nsIFileSpec
{
%{C++
//
// The "choose" functions present the file picker UI in order to set the
// value of the file spec.
%}
%{C++
// The mask for standard filters is given as follows:
enum StandardFilterMask
{
eAllReadable = (1<<0)
, eHTMLFiles = (1<<1)
, eXMLFiles = (1<<2)
, eImageFiles = (1<<3)
, eMailFiles = (1<<4)
, eTextFiles = (1<<5)
, eAllFiles = (1<<6)
// Mask containing all the above default filters
, eAllStandardFilters = (
eAllReadable
| eHTMLFiles
| eXMLFiles
| eImageFiles
| eMailFiles
| eTextFiles
| eAllFiles)
, eAllMailOutputFilters = (
eHTMLFiles
| eMailFiles
| eTextFiles)
// The "extra filter" bit should be set if the "extra filter"
// is passed in to chooseInputFile.
, eExtraFilter = (1<<31)
};
enum { kNumStandardFilters = 7, kNumMailFilters = 3 };
%}
[noscript] void chooseInputFile(
in string title
, in StandardFilterMask standardFilterMask
, in string extraFilterTitle
, in string extraFilter
);
[noscript] void chooseOutputFile(in string windowTitle,
in string suggestedLeafName,
in StandardFilterMask standardFilterMask);
string chooseFile(in string title);
string chooseDirectory(in string title);
};
%{C++
// Define Progid and CID
// {e3326a80-2816-11d3-a7e5-98cb48c74f3c}
#define NS_FILESPECWITHUI_CID \
{ 0xe3326a80, 0x2816, 0x11d3, { 0xa7, 0xe5, 0x98, 0xcb, 0x48, 0xc7, 0x4f, 0x3c } }
#define NS_FILESPECWITHUI_PROGID "component://netscape/filespecwithui"
#define NS_FILESPECWITHUI_CLASSNAME "nsIFileSpecWithUI"
// Factory methods
inline nsIFileSpecWithUI* NS_CreateFileSpecWithUI()
{
nsIFileSpecWithUI* spec = nsnull;
nsresult rv = nsComponentManager::CreateInstance(
(const char*)NS_FILESPECWITHUI_PROGID,
(nsISupports*)nsnull,
(const nsID&)nsIFileSpecWithUI::GetIID(),
(void**)&spec);
NS_ASSERTION(NS_SUCCEEDED(rv), "ERROR: Could not make a file spec.");
return spec;
}
%}

View File

@@ -0,0 +1,178 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIFileWidget_h__
#define nsIFileWidget_h__
#include "nsString.h"
#include "nsFileSpec.h"
class nsIWidget;
class nsIDeviceContext;
class nsIAppShell;
class nsIToolkit;
// {F8030015-C342-11d1-97F0-00609703C14E}
#define NS_IFILEWIDGET_IID \
{ 0xf8030015, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
/**
* File selector mode
*/
enum nsFileDlgMode {
/// Load a file or directory
eMode_load,
/// Save a file or directory
eMode_save,
/// Select a fodler/directory
eMode_getfolder
};
enum nsFileDlgResults {
nsFileDlgResults_Cancel, // User hit cancel, ignore selection
nsFileDlgResults_OK, // User hit Ok, process selection
nsFileDlgResults_Replace // User acknowledged file already exists so ok to replace, process selection
};
/**
* File selector widget.
* Modally selects files for loading or saving from a list.
*/
class nsIFileWidget : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFILEWIDGET_IID)
/**
* Create the file filter. This differs from the standard
* widget Create method because it passes in the mode
*
* @param aParent the parent to place this widget into
* @param aTitle The title for the file widget
* @param aMode load or save
* @return void
*
*/
NS_IMETHOD Create(nsIWidget *aParent,
const nsString& aTitle,
nsFileDlgMode aMode,
nsIDeviceContext *aContext = nsnull,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
void *aInitData = nsnull) = 0;
/**
* Set the list of file filters
*
* @param aNumberOfFilter number of filters.
* @param aTitle array of filter titles
* @param aFilter array of filters to associate with titles
* @return void
*
*/
NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) = 0;
/**
* Get the index into the filter list for the type of file the user wants to save
*
* @param theType the index into the filter list
* @return void
*
*/
NS_IMETHOD GetSelectedType(PRInt16& theType) = 0;
/**
* Show File Dialog. The dialog is displayed modally.
*
* @return PR_TRUE if user selects OK, PR_FALSE if user selects CANCEL
*
*/
virtual PRBool Show() = 0;
/**
* Get the nsFileSpec for the file or directory.
*
* @param aFile on exit it contains the file or directory selected
*/
NS_IMETHOD GetFile(nsFileSpec& aFile) = 0;
/**
* Set the default string that appears in file open/save dialog
*
* @param aString the name of the file
* @return void
*
*/
NS_IMETHOD SetDefaultString(const nsString& aString) = 0;
/**
* Set the directory that the file open/save dialog initially displays
*
* @param aDirectory the name of the directory
* @return void
*
*/
NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory) = 0;
/**
* Get the directory that the file open/save dialog was last displaying
*
* @param aDirectory the name of the directory
* @return void
*
*/
NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory) = 0;
virtual nsFileDlgResults GetFile(
nsIWidget * aParent,
const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
virtual nsFileDlgResults GetFolder(
nsIWidget * aParent,
const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
virtual nsFileDlgResults PutFile(
nsIWidget * aParent,
const nsString & promptString, // Window title for the dialog
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
};
#endif // nsIFileWidget_h__

View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIFontNameIterator_h__
#define nsIFontNameIterator_h__
#include "nsISupports.h"
class nsString;
// {CEEB39D1-0949-11d3-9A87-0050046CDA96}
#define NS_IFONTNAMEITERATOR_IID \
{ 0xceeb39d1, 0x949, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } };
class nsIFontNameIterator : public nsISupports
// Fonts are identified by strings, |Get| and |Advance| are distinct to facility wrapping
// with C++ objects as standard iterators.
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONTNAMEITERATOR_IID)
NS_IMETHOD Reset() = 0;
// does not need to be called initially, returns iterator to initial state
NS_IMETHOD Get( nsString* aFontName ) = 0;
// returns an error when no more names are available
NS_IMETHOD Advance() = 0;
// returns an error when no more names are available
};
#endif

Some files were not shown because too many files have changed in this diff Show More