-
Notifications
You must be signed in to change notification settings - Fork 0
/
nss-735047.patch
150 lines (135 loc) · 5.19 KB
/
nss-735047.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
diff -up ./mozilla/security/nss/lib/ckfw/pem/pinst.c.735047 ./mozilla/security/nss/lib/ckfw/pem/pinst.c
--- ./mozilla/security/nss/lib/ckfw/pem/pinst.c.735047 2011-10-16 14:51:36.678593400 -0700
+++ ./mozilla/security/nss/lib/ckfw/pem/pinst.c 2011-10-16 15:26:16.759712879 -0700
@@ -213,7 +213,6 @@ CreateObject(CK_OBJECT_CLASS objClass,
case CKO_PRIVATE_KEY:
plog("Creating key id %d in slot %ld\n", objid, slotID);
memset(&o->u.key, 0, sizeof(o->u.key));
- nickname = filename;
break;
case CKO_NETSCAPE_TRUST:
plog("Creating trust nick %s id %d in slot %ld\n", nickname, objid, slotID);
@@ -319,7 +318,7 @@ AddObjectIfNeeded(CK_OBJECT_CLASS objCla
/* FIXME: copy-pasted from CreateObject */
const char *nickname = strrchr(filename, '/');
- if (nickname && CKO_PRIVATE_KEY != objClass)
+ if (nickname)
nickname++;
else
nickname = filename;
@@ -377,7 +376,6 @@ AddCertificate(char *certfile, char *key
CK_SLOT_ID slotID)
{
pemInternalObject *o;
- SECItem certDER;
CK_RV error = 0;
int objid, i;
int nobjs = 0;
@@ -385,7 +383,6 @@ AddCertificate(char *certfile, char *key
char *ivstring = NULL;
int cipher;
- certDER.data = NULL;
nobjs = ReadDERFromFile(&objs, certfile, PR_TRUE, &cipher, &ivstring, PR_TRUE /* certs only */);
if (nobjs <= 0) {
nss_ZFreeIf(objs);
@@ -469,32 +466,36 @@ pem_Initialize
)
{
CK_RV rv;
- /* parse the initialization string and initialize CRLInstances */
+ /* parse the initialization string */
char **certstrings = NULL;
+ char *modparms = NULL;
PRInt32 numcerts = 0;
PRBool status, error = PR_FALSE;
int i;
+ CK_C_INITIALIZE_ARGS_PTR modArgs = NULL;
+
+ if (!fwInstance) return CKR_ARGUMENTS_BAD;
+
+ modArgs = NSSCKFWInstance_GetInitArgs(fwInstance);
+ if (modArgs &&
+ ((modArgs->flags & CKF_OS_LOCKING_OK) || (modArgs->CreateMutex != 0))) {
+ return CKR_CANT_LOCK;
+ }
if (pemInitialized) {
return CKR_OK;
}
+
RNG_RNGInit();
open_log();
plog("pem_Initialize\n");
- unsigned char *modparms = NULL;
- if (!fwInstance) {
- return CKR_ARGUMENTS_BAD;
- }
-
- CK_C_INITIALIZE_ARGS_PTR modArgs =
- NSSCKFWInstance_GetInitArgs(fwInstance);
if (!modArgs || !modArgs->LibraryParameters) {
goto done;
}
- modparms = (unsigned char *) modArgs->LibraryParameters;
+ modparms = (char *) modArgs->LibraryParameters;
plog("Initialized with %s\n", modparms);
/*
@@ -510,7 +511,7 @@ pem_Initialize
*
*/
status =
- pem_ParseString((const char *) modparms, ' ', &numcerts,
+ pem_ParseString(modparms, ' ', &numcerts,
&certstrings);
if (status == PR_FALSE) {
return CKR_ARGUMENTS_BAD;
diff -up ./mozilla/security/nss/lib/ckfw/pem/pobject.c.735047 ./mozilla/security/nss/lib/ckfw/pem/pobject.c
--- ./mozilla/security/nss/lib/ckfw/pem/pobject.c.735047 2011-10-16 14:51:36.679593121 -0700
+++ ./mozilla/security/nss/lib/ckfw/pem/pobject.c 2011-10-16 15:26:46.231843596 -0700
@@ -1113,12 +1113,28 @@ pem_CreateObject
}
if (objClass == CKO_CERTIFICATE) {
+ int i;
+
nobjs = ReadDERFromFile(&derlist, filename, PR_TRUE, &cipher, &ivstring, PR_TRUE /* certs only */);
if (nobjs < 1)
- return (NSSCKMDObject *) NULL;
+ goto loser;
- /* We're just adding a cert, we'll assume the key is next */
- objid = pem_nobjs + 1;
+ objid = -1;
+ /* Brute force: find the id of the key, if any, in this slot */
+ for (i = 0; i < pem_nobjs; i++) {
+ if (NULL == gobj[i])
+ continue;
+
+ if ((slotID == gobj[i]->slotID)
+ && (gobj[i]->type == pemBareKey)) {
+ objid = atoi(gobj[i]->id.data);
+ }
+ }
+
+ if (objid == -1) {
+ /* We're just adding a cert, we'll assume the key is next */
+ objid = pem_nobjs + 1;
+ }
if (cacert) {
/* Add the certificate. There may be more than one */
@@ -1160,9 +1176,10 @@ pem_CreateObject
nobjs = ReadDERFromFile(&derlist, filename, PR_TRUE, &cipher, &ivstring, PR_FALSE /* keys only */);
if (nobjs < 1)
- return (NSSCKMDObject *) NULL;
+ goto loser;
certDER.len = 0; /* in case there is no equivalent cert */
+ certDER.data = NULL;
objid = -1;
for (i = 0; i < pem_nobjs; i++) {
diff -up ./mozilla/security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_infoaccess.c.735047 ./mozilla/security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_infoaccess.c
--- ./mozilla/security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_infoaccess.c.735047 2011-04-07 23:03:07.000000000 -0700
+++ ./mozilla/security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_infoaccess.c 2011-10-16 14:51:36.726625877 -0700
@@ -632,7 +632,7 @@ pkix_pl_InfoAccess_ParseTokens(
separator = terminator;
- if (endPos == '\0') {
+ if (*endPos == '\0') {
*startPos = endPos;
break;
} else {