Lines Matching refs:alg
82 def hash_init(alg): argument
83 if alg == 'poly1305':
87 if alg == 'polyval':
89 return hashlib.new(alg)
97 def compute_hash(alg, data): argument
98 ctx = hash_init(alg)
118 def alg_digest_size_const(alg): argument
119 if alg.startswith('blake2'):
123 def gen_unkeyed_testvecs(alg): argument
133 print_c_struct_u8_array_field('digest', compute_hash(alg, data))
138 ctx = hash_init(alg)
140 hash_update(ctx, compute_hash(alg, data[:data_len]))
148 for alg in ['shake128', 'shake256']:
152 out = hashlib.new(alg, data=in_data[:in_len]).digest(out_len)
157 def gen_hmac_testvecs(alg): argument
158 ctx = hmac.new(rand_bytes(32), digestmod=alg)
164 mac = hmac.digest(key, data[:data_len], alg)
170 def gen_additional_blake2_testvecs(alg): argument
171 if alg == 'blake2s':
173 elif alg == 'blake2b':
180 h = hashlib.new(alg, digest_size=out_len, key=rand_bytes(key_len))
185 compute_hash(alg, hashes))
214 alg = sys.argv[1] variable
217 if alg.startswith('blake2'):
218 gen_unkeyed_testvecs(alg)
219 gen_additional_blake2_testvecs(alg)
220 elif alg == 'poly1305':
221 gen_unkeyed_testvecs(alg)
223 elif alg == 'polyval':
224 gen_unkeyed_testvecs(alg)
226 elif alg == 'sha3':
234 gen_unkeyed_testvecs(alg)
235 gen_hmac_testvecs(alg)