aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpow/POW-0.7/lib/pkix.py4
-rw-r--r--scripts/pkcs10.py34
-rw-r--r--scripts/rpki/up_down.py24
3 files changed, 22 insertions, 40 deletions
diff --git a/pow/POW-0.7/lib/pkix.py b/pow/POW-0.7/lib/pkix.py
index 7dd75322..744c4ccf 100755
--- a/pow/POW-0.7/lib/pkix.py
+++ b/pow/POW-0.7/lib/pkix.py
@@ -1226,12 +1226,12 @@ class CertificationRequest(Sequence):
def getExtensions(self):
oid = self.certificationRequestInfo.attributes.oid.get()
if oid is None:
- return None
+ return ()
if oid != (1, 2, 840, 113549, 1, 9, 14) or \
self.certificationRequestInfo.attributes.val.choice != "set" or \
len(self.certificationRequestInfo.attributes.val.choices["set"]) > 1:
raise DerError, "failed to understand X.501 Attribute encoding, sorry: %s" % self.get()
- return self.certificationRequestInfo.attributes.val.choices["set"][0]
+ return self.certificationRequestInfo.attributes.val.choices["set"][0].get()
#---------- PKCS10 ----------#
#---------- GeneralNames object support ----------#
diff --git a/scripts/pkcs10.py b/scripts/pkcs10.py
index 5636027b..3a88b779 100644
--- a/scripts/pkcs10.py
+++ b/scripts/pkcs10.py
@@ -3,11 +3,11 @@
import POW.pkix, rpki.x509, glob, rpki.resource_set
parse_extensions = True
-list_extensions = False
show_attributes = False
show_algorithm = False
do_verify = True
-show_signature = True
+show_signature = False
+show_publickey = False
def hexify(thing):
return ":".join(["%02X" % ord(i) for i in thing])
@@ -27,6 +27,12 @@ for name in glob.glob("resource-cert-samples/*.req") + glob.glob("biz-certs/*.re
print pkcs10.signatureValue, hexify(pkcs10.signatureValue.get())
print
+ if show_publickey:
+ print pkcs10.certificationRequestInfo.subjectPublicKeyInfo
+ print pkcs10.certificationRequestInfo.subjectPublicKeyInfo.get()
+ print hexify(pkcs10.certificationRequestInfo.subjectPublicKeyInfo.toString())
+ print
+
if show_attributes:
print pkcs10.certificationRequestInfo.attributes.oid, pkcs10.certificationRequestInfo.attributes.oid.get()
print
@@ -42,32 +48,16 @@ for name in glob.glob("resource-cert-samples/*.req") + glob.glob("biz-certs/*.re
print pkcs10.certificationRequestInfo.attributes.val.choices[pkcs10.certificationRequestInfo.attributes.val.choice][0]
print
- if False:
- extc = pkcs10.certificationRequestInfo.attributes.val
- exts = extc.choices[extc.choice][0]
- assert exts is pkcs10.getExtensions()
- else:
- exts = pkcs10.getExtensions()
-
- #print len(exts), exts[0].extnValue
-
- if list_extensions and exts is not None:
- for x in exts:
- oid = x.extnID.get()
- name = POW.pkix.oid2obj(oid)
- crit = x.critical.get()
- value = x.extnValue.get()
- assert isinstance(value, str)
- print [ name, oid, crit, hexify(value) ]
+ if parse_extensions:
- if parse_extensions and exts is not None:
+ exts = pkcs10.getExtensions()
- as, v4, v6 = rpki.resource_set.parse_extensions(exts.get())
+ as, v4, v6 = rpki.resource_set.parse_extensions(exts)
if as: print "ASN =", as
if v4: print "IPv4 =", v4
if v6: print "IPv6 =", v6
- for oid, crit, val in exts.get():
+ for oid, crit, val in exts:
if oid in ((1, 3, 6, 1, 5, 5, 7, 1, 7), (1, 3, 6, 1, 5, 5, 7, 1, 8)):
continue
if isinstance(val, str):
diff --git a/scripts/rpki/up_down.py b/scripts/rpki/up_down.py
index 814a8534..388ba21c 100644
--- a/scripts/rpki/up_down.py
+++ b/scripts/rpki/up_down.py
@@ -234,18 +234,14 @@ class issue_pdu(base_elt):
if oids.get(self.pkcs10.get_POWpkix().signatureAlgorithm) not in ("sha256WithRSAEncryption", "sha384WithRSAEncryption", "sha512WithRSAEncryption"):
raise rpki.exceptions.BadPKCS10, "Bad signature algorithm %s" % self.pkcs10.get_POWpkix().signatureAlgorithm
exts = self.pkcs10.getExtensions()
- if exts is None:
- exts = {}
- else:
- exts = exts.get()
- for oid, critical, value in exts:
- if oids.get(oid) not in ("basicConstraints", "keyUsage", "subjectInfoAccess"):
- raise rpki.exceptions.BadExtension, "Forbidden extension %s" % oid
- exts = dict((oids[oid], value) for (oid, critical, value) in exts)
+ for oid, critical, value in exts:
+ if oids.get(oid) not in ("basicConstraints", "keyUsage", "subjectInfoAccess"):
+ raise rpki.exceptions.BadExtension, "Forbidden extension %s" % oid
+ exts = dict((oids[oid], value) for (oid, critical, value) in exts)
if "basicConstraints" not in exts or not exts["basicConstraints"][0]:
raise rpki.exceptions.BadPKCS10, "request for EE cert not allowed here"
if exts["basicConstraints"][1] is not None:
- raise rpki.exceptions.BadPKCS10, "basicConstraints extension must not specify Path Length"
+ raise rpki.exceptions.BadPKCS10, "basicConstraints must not specify Path Length"
if "keyUsage" in exts and (not exts["keyUsage"][5] or not exts["keyUsage"][6]):
raise rpki.exceptions.BadPKCS10, "keyUsage doesn't match basicConstraints"
for method, location in exts.get("subjectInfoAccess", ()):
@@ -257,9 +253,9 @@ class issue_pdu(base_elt):
# resources (approximately the same algorithm used for
# list_response). Check:
#
- # 3a) that resources match exactly
+ # 3a) that public key matches exactly
#
- # 3b) that public key matches exactly
+ # 3b) that resources match exactly
#
# 3c) that any relevant extensions in the pkcs10 match exactly
#
@@ -275,12 +271,8 @@ class issue_pdu(base_elt):
else:
child_cert = None
if child_cert is not None:
- pass
+ pass # Fill in remaining tests here
- #
- # In theory the spec requires that that public keys here be
- # different, so at most one key should match. Sez here.
- # Anyway, need to perform remaining tests on the match if we got one.
raise NotImplementedError
config.py?id=4d7072bd10f807558dfd60c2a3e65fe6584bcdb3'>4d7072bd
24baff4d
4d7072bd
24baff4d
5e634230

d970a6e2
15591600


d970a6e2












ffe4a516
a780a780
ffe4a516
a780a780
4d7072bd

ffe4a516
15591600
ffe4a516

d970a6e2

ffe4a516
e73c9f21




ffe4a516






24baff4d




ffe4a516






e3f985e4
6d86b6d1
e3f985e4
6d86b6d1




e3f985e4

72e42a65
e3f985e4

94bad6e5
f67557c2
e3f985e4


94bad6e5
f67557c2
e3f985e4


94bad6e5
6d86b6d1



94bad6e5
6d86b6d1
f9cbaa90


94bad6e5
f9cbaa90



94bad6e5
f9cbaa90
6d86b6d1


e3f985e4
f67557c2
e3f985e4



f67557c2
e3f985e4



f67557c2
e3f985e4


f67557c2

e3f985e4
4e3b0fba

3466fa9e
4e3b0fba



3466fa9e
4e3b0fba

54f4de8a

4fcf2c4c
54f4de8a

72e42a65




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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268