Beispiel #1
0
def _verify_signature(content, signature, user=None, refresh=False):
    signature = Signature.fromBase64(signature)
    public_key = cache.get("starkbank-public-key")
    if public_key is None or refresh:
        pem = _get_public_key_pem(user)
        public_key = PublicKey.fromPem(pem)
        cache["starkbank-public-key"] = public_key
    return Ecdsa.verify(message=content, signature=signature, publicKey=public_key)
Beispiel #2
0
    def testBase64Conversion(self):
        privateKey = PrivateKey()
        message = "This is a text message"

        signature1 = Ecdsa.sign(message, privateKey)

        base64 = signature1.toBase64()

        signature2 = Signature.fromBase64(base64)

        self.assertEqual(signature1.r, signature2.r)
        self.assertEqual(signature1.s, signature2.s)
    def testBase64Conversion(self):
        privateKey = PrivateKey()
        message = "This is a text message"

        signature1 = Ecdsa.sign(message, privateKey)

        base64 = signature1.toBase64(withRecoveryId=True)

        signature2 = Signature.fromBase64(base64, recoveryByte=True)

        self.assertEqual(signature1.r, signature2.r)
        self.assertEqual(signature1.s, signature2.s)
        self.assertEqual(signature1.recid, signature2.recid)
Beispiel #4
0
    def verify_signature(self, payload, signature, timestamp, public_key=None):
        """
        Verify signed event webhook requests.

        :param payload: event payload in the request body
        :type payload: string
        :param signature: value obtained from the 'X-Twilio-Email-Event-Webhook-Signature' header
        :type signature: string
        :param timestamp: value obtained from the 'X-Twilio-Email-Event-Webhook-Timestamp' header
        :type timestamp: string
        :param public_key: elliptic curve public key
        :type public_key: PublicKey
        :return: true or false if signature is valid
        """
        timestamped_payload = timestamp + payload
        decoded_signature = Signature.fromBase64(signature)

        key = public_key or self.public_key
        return Ecdsa.verify(timestamped_payload, decoded_signature, key)
Beispiel #5
0
def verify_Signature(message, signature_input, publicKey_input):
    publicKey_input = '-----BEGIN PUBLIC KEY-----\n' + publicKey_input + '\n-----END PUBLIC KEY-----\n'
    signature = Signature.fromBase64(signature_input)
    publicKey = PublicKey.fromPem(publicKey_input)
    return (Ecdsa.verify(message, signature, publicKey))
Beispiel #6
0
def verify_Signature(message, sign64, str1):
    signature = Signature.fromBase64(sign64)
    publicKey = PublicKey.fromPem(str1)
    return (Ecdsa.verify(message, signature, publicKey))
def verify_Signature(message, sign64, publicKey_input):
    signature = Signature.fromBase64(sign64)
    a = publicKey_input.split(".")
    pt = Point(int(a[0]), int(a[1]), int(a[2]))
    publicKey = PublicKey(point = pt, curve = secp256k1)
    return (Ecdsa.verify(message, signature, publicKey))