Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(2)  |  Derive(0)  |  Import(1)

        def aes_wrap_key(kek, plaintext, iv=0xa6a6a6a6a6a6a6a6):
    n = len(plaintext) / 8
    r = [None] + [plaintext[i * 8:i * 8 + 8] for i in range(0, n)]
    a = iv
    encrypt = AES.new(kek).encrypt
    for j in range(6):
        #import binascii
        #print hex(a), binascii.hexlify(r[1]), binascii.hexlify(r[2])

        for i in range(1, n + 1):
            b = encrypt(QUAD.pack(a) + r[i])
            a = QUAD.unpack(b[:8])[0] ^ (n * j + i)
            r[i] = b[8:]
    return QUAD.pack(a) + "".join(r[1:])
        


src/p/y/pyjwkest-0.3.0/src/jwkest/jwe.py   pyjwkest(Download)
 
from cryptlib.aes_gcm import AES_GCM
from cryptlib.aes_key_wrap import aes_wrap_key, aes_unwrap_key
from cryptlib.ecc import NISTEllipticCurve
 
        # The iv for this function must be 64 bit
        # Which is certainly different from the one above
        jek = aes_wrap_key(kek, cek)
        auth_data = b64_header
 
            klen = int(_post[1:4])
            kek = ecdh_derive_key(curve, eprivk, key, apu, apv, _post, klen)
            encrypted_key = aes_wrap_key(kek, cek)
        else:
            raise Exception("Unsupported algorithm %s" % self.alg)