def acquireSignature(self, nym, auth): if self.caKey is None: raise Exception('no public key') r, hashTwo, sigTime, blinded = blinding.blind(self.caKey, None, nym) data, result = self._sendRequest(auth, blinded.rep()) if data is None or result != 'ok': return None, result blindSig = OpenPGP.messages.fromRadix64(data) sig = blinding.unblind(self.caKey, sigTime, r, hashTwo, blindSig) return sig, result
def testCASign(self): caConfig = blindca.Config() caConfig.secretKey = 'testdata/foo-bar.com_secret_openpgp.txt' caConfig.publicKey = 'testdata/foo-bar.com_public_openpgp.txt' ca = blindca.BlindCA(caConfig) publicKey = messages.fromRadix64( open('testdata/foo-bar.com_public_openpgp.txt', 'r').read()) data = 'The quick brown fox jumps over the lazy dog\n' r, hashtwo, sigTime, blinded = blinding.blind(publicKey, None, data) blindSig = ca.sign(blinded) sig = blinding.unblind(publicKey, sigTime, r, hashtwo, blindSig) self.assertTrue(verifySignature(data, sig, publicKey)) self.assertTrue(sigTime.value >= publicKey.creationTime().value) self.assertTrue(sigTime.value <= publicKey.expirationTime().value)
def testBlinding(self): secretKey = messages.fromRadix64( open('testdata/foo-bar.com_secret_openpgp.txt', 'r').read()) publicKey = messages.fromRadix64( open('testdata/foo-bar.com_public_openpgp.txt', 'r').read()) data = 'The quick brown fox jumps over the lazy dog\n' sigTime = elements.TimeElement.now() r, hashTwo, newSigTime, blinded = blinding.blind(publicKey, sigTime, data) self.assertEqual(sigTime.value, newSigTime.value) blindSig = crypto.rsaSign(blinded.packets[TAG_BLINDMSG].m.value, secretKey.packets[TAG_SECKEY].d.value, publicKey.packets[TAG_PUBKEY].n.value) packet = packets.BlindSignaturePacket() packet.s = elements.MPIElement(blindSig) message = messages.BlindSignatureMessage.fromPackets((packet,)) s = blinding.unblind(publicKey, sigTime, r, hashTwo, message) self.assertTrue(verifySignature(data, s, publicKey))
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys import blinding from OpenPGP import * if len(sys.argv) != 3: print >>sys.stderr, 'usage: unblind.py <RANDOMFILE> <PUBKEYFILE>' sys.exit(2) blindSigRadix = sys.stdin.read().strip() blindSig = messages.fromRadix64(blindSigRadix) randfile = open(sys.argv[1], 'r') r = elements.ScalarElement(randfile.readline().strip().decode('hex')).value hashtwo = randfile.readline().strip().decode('hex') sigTime = elements.TimeElement(int(randfile.readline().strip())) randfile.close() publicKey = messages.fromRadix64(open(sys.argv[2], 'r').read()) sig = blinding.unblind(publicKey, sigTime, r, hashtwo, blindSig) #print >>sys.stderr, sig print sig.rep()