def process_nonce(self, nonce):
     dci = self.ci.decryptData(nonce)
     #print "client's nonce: ", dci
     #sci = self.ci.signData(dci)
     #print "signed nonce: ", sci
     if self.pin is None:
         print "ERROR! Check the pin or the card!"
         reactor.stop()
     sci = cc.sign(dci, cc.KEY_LABEL, self.pin)
     #print "nonce signed w/ CC: ", sci
     enc = self.ci.encryptData(sci)
     #enc = b64encode(eci[0])
     # print "signed and encoded nonce: " + enc
     return enc
 def process_nonce(self, nonce):
     dci = self.ci.decryptData(nonce)
     #print "client's nonce: ", dci
     #sci = self.ci.signData(dci)
     #print "signed nonce: ", sci
     if self.pin is None:
         print "ERROR! Check the pin or the card!"
         reactor.stop()
     sci = cc.sign(dci, cc.KEY_LABEL, self.pin)
     #print "nonce signed w/ CC: ", sci
     enc = self.ci.encryptData(sci)
     #enc = b64encode(eci[0])
     # print "signed and encoded nonce: " + enc
     return enc
Exemplo n.º 3
0
        def register_cb((signedNonce, nonceid)):
            agent = CookieAgent(Agent(reactor), self.cookie_jar)
            dataq = []
            dataq.append(signedNonce)
            dataq.append(self.client_id.encryptData(self.client_id.password))
            # Sending the Certificate and the Sub CA to the server
            if self.pin is  None:
                print "ERROR! Check the pin!"
                reactor.stop()
            cert = cc.get_certificate(cc.CERT_LABEL, self.pin)
            #print type(cert.as_pem())
            #print cert.as_pem()
            if cert is None:
                print "ERROR! Check the pin"
                reactor.stop()
            subca = cc.get_certificate(cc.SUBCA_LABEL, self.pin)
            #print type(subca.as_pem())
            #print subca.as_pem()
            if subca is None:
                print "ERROR! Check the pin"
                reactor.stop()

            enc_cert = b64encode(cert.as_pem())
            #print "cert len: ", len(enc_cert)
            dataq.append(enc_cert)
            enc_subca = b64encode(subca.as_pem())
            #print "sub ca len: ", len(enc_subca)
            dataq.append(enc_subca)
            dataq.append(self.client_id.pub_key.exportKey('PEM'))
            ext_key = self.client_id.pub_key.exportKey('PEM')
            if self.pin is None:
				print "ERROR! Check the pin or the CC"
				reactor.stop()
            signed_ext_key = cc.sign(ext_key, cc.KEY_LABEL, self.pin)
            enc_sek = b64encode(signed_ext_key)
            #print "encoded ext key: ", enc_sek
            #print "len encoded: ", len(enc_sek)
            dataq.append(enc_sek)
            body = FileProducer2(dataq)
            headers = http_headers.Headers()
            #print "Password:"******"LEN:", len(self.client_id.encryptData(self.client_id.password))
            d = agent.request(
                'PUT',
                'http://localhost:8000/pboxes/?method=register'
                + '&nonceid=' + str(nonceid),
                headers,
                body)
            d.addCallback(procResponse_cb, checkClientReg_cb)
Exemplo n.º 4
0
        def register_cb((signedNonce, nonceid)):
            agent = CookieAgent(Agent(reactor), self.cookie_jar)
            dataq = []
            dataq.append(signedNonce)
            dataq.append(self.client_id.encryptData(self.client_id.password))
            # Sending the Certificate and the Sub CA to the server
            if self.pin is None:
                print "ERROR! Check the pin!"
                reactor.stop()
            cert = cc.get_certificate(cc.CERT_LABEL, self.pin)
            #print type(cert.as_pem())
            #print cert.as_pem()
            if cert is None:
                print "ERROR! Check the pin"
                reactor.stop()
            subca = cc.get_certificate(cc.SUBCA_LABEL, self.pin)
            #print type(subca.as_pem())
            #print subca.as_pem()
            if subca is None:
                print "ERROR! Check the pin"
                reactor.stop()

            enc_cert = b64encode(cert.as_pem())
            #print "cert len: ", len(enc_cert)
            dataq.append(enc_cert)
            enc_subca = b64encode(subca.as_pem())
            #print "sub ca len: ", len(enc_subca)
            dataq.append(enc_subca)
            dataq.append(self.client_id.pub_key.exportKey('PEM'))
            ext_key = self.client_id.pub_key.exportKey('PEM')
            if self.pin is None:
                print "ERROR! Check the pin or the CC"
                reactor.stop()
            signed_ext_key = cc.sign(ext_key, cc.KEY_LABEL, self.pin)
            enc_sek = b64encode(signed_ext_key)
            #print "encoded ext key: ", enc_sek
            #print "len encoded: ", len(enc_sek)
            dataq.append(enc_sek)
            body = FileProducer2(dataq)
            headers = http_headers.Headers()
            #print "Password:"******"LEN:", len(self.client_id.encryptData(self.client_id.password))
            d = agent.request(
                'PUT', 'http://localhost:8000/pboxes/?method=register' +
                '&nonceid=' + str(nonceid), headers, body)
            d.addCallback(procResponse_cb, checkClientReg_cb)