aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/rpki/up_down.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/scripts/rpki/up_down.py b/scripts/rpki/up_down.py
index 83b80cda..a23909ed 100644
--- a/scripts/rpki/up_down.py
+++ b/scripts/rpki/up_down.py
@@ -2,7 +2,7 @@
"""RPKI "up-down" protocol."""
-import base64, lxml.etree, time
+import base64, lxml.etree, time, POW.pkix
import rpki.sax_utils, rpki.resource_set, rpki.x509, rpki.exceptions
xmlns="http://www.apnic.net/specs/rescerts/up-down/"
@@ -228,9 +228,26 @@ class issue_pdu(base_elt):
if ca is None or ca_detail is None:
raise rpki.exceptions.NotInDatabase
- # 2) Check that PKCS#10 is legal according to the profile (has all
- # required fields, doesn't have any forbidden fields, fields
- # that it has don't conflict with anything we already know).
+ # 2) Check that PKCS#10 is legal according to the profile
+ # (signature validates, has all required fields, doesn't have
+ # any forbidden fields, fields that it has don't conflict with
+ # anything we already know).
+
+ if not self.pkcs10.get_POWpkix().verify():
+ raise rpki.exceptions.BadSignature
+ if self.pkcs10.get_POWpkix().certificationRequestInfo.version != 0:
+ raise rpki.exceptions.BadVersion
+ if POW.pkix.oid2obj(self.pkcs10.get_POWpkix().signatureAlgorithm) not in ("sha256WithRSAEncryption", "sha384WithRSAEncryption", "sha512WithRSAEncryption"):
+ raise rpki.exceptions.BadAlgorithm
+ for x in self.pkcs10.certificationRequestInfo.attributes.val.choices[self.pkcs10.certificationRequestInfo.attributes.val.choice][0]:
+
+ raise NotImplementedError
+
+ oid = x.extnID.get()
+ val = x.extnValue.get()
+ name = POW.pkix.oid2obj(oid)
+ crit = x.critical.get()
+
#
# 3) Find any certs already issued to this child for these
# resources (approximately the same algorithm used for
teral.String.Delimiter */ .highlight .sd { color: #D20; background-color: #FFF0F0 } /* Literal.String.Doc */ .highlight .s2 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Double */ .highlight .se { color: #04D; background-color: #FFF0F0 } /* Literal.String.Escape */ .highlight .sh { color: #D20; background-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
# $Id$

import socket, POW, time

key = POW.pemRead(POW.RSA_PRIVATE_KEY, open("Carol.key", "r").read())
cer = POW.pemRead(POW.X509_CERTIFICATE, open("Carol.cer", "r").read())
ta  = POW.pemRead(POW.X509_CERTIFICATE, open("Alice-TA.cer", "r").read())

s = socket.socket()
s.connect(('',6666))

ssl = POW.Ssl(POW.TLSV1_CLIENT_METHOD)

ssl.useCertificate(cer)
ssl.useKey(key)
ssl.setVerifyMode(POW.SSL_VERIFY_PEER | POW.SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
ssl.trustCertificate(ta)

ssl.setFd(s.fileno())
ssl.connect()

peer = ssl.peerCertificate()
if peer is not None:
  print peer.pprint()

print ssl.read(100)
ssl.write("Bye")