Ejemplo n.º 1
0
 def verify_chain_HMAC(self, key, start, chain, algo='sha1'):
     hmac = EVP.HMAC(key, algo)
     hmac.update( ` start `)
     digest = hmac.final()
     c = chain[0]
     if c[0] != digest or c[1] != start:
         return 0
     for d, v in chain[1:]:
         hmac.reset(digest)
         hmac.update( ` v `)
         digest = hmac.final()
         if digest != d:
             return 0
     return 1
Ejemplo n.º 2
0
 def verify_chain_HMAC(self, key, start, chain, algo='sha1'):
     hmac = EVP.HMAC(key, algo)
     hmac.update(`start`)
     digest = hmac.final()
     c = chain[0]
     if c[0] != digest or c[1] != start:
         return 0
     for d, v in chain[1:]:
         hmac.reset(digest)
         hmac.update(`v`)
         digest = hmac.final()
         if digest != d:
             return 0
     return 1
Ejemplo n.º 3
0
def verify_chain_HMAC(key, start, chain, algo="sha1"):
    hmac = EVP.HMAC(key, algo)
    hmac.update(` start `)
    digest = hmac.final()
    c = chain[0]
    if c[0] != digest or c[1] != start:
        print "verify failed"
        return 0
    for d, v in chain[1:]:
        hmac.reset(digest)
        hmac.update(` v `)
        digest = hmac.final()
        if digest != d:
            print "verify failed"
            return 0
    print "ok"
    return 1