123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843typebigstring=(char,Bigarray_compat.int8_unsigned_elt,Bigarray_compat.c_layout)Bigarray_compat.Array1.ttype'aiter=('a->unit)->unittype'acompare='a->'a->inttype'aequal='a->'a->booltype'app=Format.formatter->'a->unitmoduleBy=Digestif_bymoduleBi=Digestif_bimoduleEq=Digestif_eqmoduleHash=Digestif_hashmoduleConv=Digestif_convletfailwithfmt=Format.ksprintffailwithfmtmoduletypeS=sigvaldigest_size:inttypectxtypekindtypetvalkind:kindvalempty:ctxvalinit:unit->ctxvalfeed_bytes:ctx->?off:int->?len:int->Bytes.t->ctxvalfeed_string:ctx->?off:int->?len:int->String.t->ctxvalfeed_bigstring:ctx->?off:int->?len:int->bigstring->ctxvalfeedi_bytes:ctx->Bytes.titer->ctxvalfeedi_string:ctx->String.titer->ctxvalfeedi_bigstring:ctx->bigstringiter->ctxvalget:ctx->tvaldigest_bytes:?off:int->?len:int->Bytes.t->tvaldigest_string:?off:int->?len:int->String.t->tvaldigest_bigstring:?off:int->?len:int->bigstring->tvaldigesti_bytes:Bytes.titer->tvaldigesti_string:String.titer->tvaldigesti_bigstring:bigstringiter->tvaldigestv_bytes:Bytes.tlist->tvaldigestv_string:String.tlist->tvaldigestv_bigstring:bigstringlist->tvalhmac_bytes:key:Bytes.t->?off:int->?len:int->Bytes.t->tvalhmac_string:key:String.t->?off:int->?len:int->String.t->tvalhmac_bigstring:key:bigstring->?off:int->?len:int->bigstring->tvalhmaci_bytes:key:Bytes.t->Bytes.titer->tvalhmaci_string:key:String.t->String.titer->tvalhmaci_bigstring:key:bigstring->bigstringiter->tvalhmacv_bytes:key:Bytes.t->Bytes.tlist->tvalhmacv_string:key:String.t->String.tlist->tvalhmacv_bigstring:key:bigstring->bigstringlist->tvalunsafe_compare:tcomparevalequal:tequalvalpp:tppvalof_hex:string->tvalof_hex_opt:string->toptionvalconsistent_of_hex:string->tvalconsistent_of_hex_opt:string->toptionvalto_hex:t->stringvalof_raw_string:string->tvalof_raw_string_opt:string->toptionvalto_raw_string:t->stringendmoduletypeMAC=sigtypetvalmac_bytes:key:Bytes.t->?off:int->?len:int->Bytes.t->tvalmac_string:key:String.t->?off:int->?len:int->String.t->tvalmac_bigstring:key:bigstring->?off:int->?len:int->bigstring->tvalmaci_bytes:key:Bytes.t->Bytes.titer->tvalmaci_string:key:String.t->String.titer->tvalmaci_bigstring:key:bigstring->bigstringiter->tvalmacv_bytes:key:Bytes.t->Bytes.tlist->tvalmacv_string:key:String.t->String.tlist->tvalmacv_bigstring:key:bigstring->bigstringlist->tendmoduletypeDesc=sigtypekindvaldigest_size:intvalblock_size:intvalkind:kindendmoduletypeHash=sigtypectxtypekindvalinit:unit->ctxvalunsafe_feed_bytes:ctx->By.t->int->int->unitvalunsafe_feed_bigstring:ctx->Bi.t->int->int->unitvalunsafe_get:ctx->By.tvaldup:ctx->ctxendmoduleUnsafe(Hash:Hash)(D:Desc)=structopenHashletdigest_size=D.digest_sizeletblock_size=D.block_sizeletempty=init()letinit=initletunsafe_feed_bytesctx?off?lenbuf=letoff,len=match(off,len)with|Someoff,Somelen->(off,len)|Someoff,None->(off,By.lengthbuf-off)|None,Somelen->(0,len)|None,None->(0,By.lengthbuf)inifoff<0||len<0||off>By.lengthbuf-lentheninvalid_arg"offset out of bounds"elseunsafe_feed_bytesctxbufofflenletunsafe_feed_stringctx?off?lenbuf=unsafe_feed_bytesctx?off?len(By.unsafe_of_stringbuf)letunsafe_feed_bigstringctx?off?lenbuf=letoff,len=match(off,len)with|Someoff,Somelen->(off,len)|Someoff,None->(off,Bi.lengthbuf-off)|None,Somelen->(0,len)|None,None->(0,Bi.lengthbuf)inifoff<0||len<0||off>Bi.lengthbuf-lentheninvalid_arg"offset out of bounds"elseunsafe_feed_bigstringctxbufofflenletunsafe_get=unsafe_getendmoduleCore(Hash:Hash)(D:Desc)=structtypet=stringtypectx=Hash.ctxtypekind=Hash.kindincludeUnsafe(Hash)(D)includeConv.Make(D)includeEq.Make(D)letkind=D.kindletgett=lett=Hash.duptinunsafe_gett|>By.unsafe_to_stringletfeed_bytest?off?lenbuf=lett=Hash.duptinunsafe_feed_bytest?off?lenbuf;tletfeed_stringt?off?lenbuf=lett=Hash.duptinunsafe_feed_stringt?off?lenbuf;tletfeed_bigstringt?off?lenbuf=lett=Hash.duptinunsafe_feed_bigstringt?off?lenbuf;tletfeedi_bytestiter=lett=Hash.duptinletfeedbuf=unsafe_feed_bytestbufiniterfeed;tletfeedi_stringtiter=lett=Hash.duptinletfeedbuf=unsafe_feed_stringtbufiniterfeed;tletfeedi_bigstringtiter=lett=Hash.duptinletfeedbuf=unsafe_feed_bigstringtbufiniterfeed;tletdigest_bytes?off?lenbuf=feed_bytesempty?off?lenbuf|>getletdigest_string?off?lenbuf=feed_stringempty?off?lenbuf|>getletdigest_bigstring?off?lenbuf=feed_bigstringempty?off?lenbuf|>getletdigesti_bytesiter=feedi_bytesemptyiter|>getletdigesti_stringiter=feedi_stringemptyiter|>getletdigesti_bigstringiter=feedi_bigstringemptyiter|>getletdigestv_byteslst=digesti_bytes(funf->List.iterflst)letdigestv_stringlst=digesti_string(funf->List.iterflst)letdigestv_bigstringlst=digesti_bigstring(funf->List.iterflst)endmoduleMake(H:Hash)(D:Desc)=structincludeCore(H)(D)letbytes_opad=By.initblock_size(fun_->'\x5c')letbytes_ipad=By.initblock_size(fun_->'\x36')letrecnorm_byteskey=matchStdlib.compare(By.lengthkey)block_sizewith|1->norm_bytes(By.unsafe_of_string(digest_byteskey))|-1->By.rpadkeyblock_size'\000'|_->keyletbigstring_opad=Bi.initblock_size(fun_->'\x5c')letbigstring_ipad=Bi.initblock_size(fun_->'\x36')letnorm_bigstringkey=letkey=Bi.to_stringkeyinletres0=norm_bytes(By.unsafe_of_stringkey)inletres1=Bi.create(By.lengthres0)inBi.blit_from_bytesres00res10(By.lengthres0);res1lethmaci_bytes~keyiter=letkey=norm_byteskeyinletouter=Xor.Bytes.xorkeybytes_opadinletinner=Xor.Bytes.xorkeybytes_ipadinletres=digesti_bytes(funf->finner;iterf)indigesti_bytes(funf->fouter;f(By.unsafe_of_stringres))lethmaci_string~keyiter=letkey=norm_bytes(By.unsafe_of_stringkey)in(* XXX(dinosaure): safe, [rpad] and [digest] have a read-only access. *)letouter=Xor.Bytes.xorkeybytes_opadinletinner=Xor.Bytes.xorkeybytes_ipadinletctx=feed_bytesemptyinnerinletres=feedi_stringctxiter|>getinletctx=feed_bytesemptyouterinfeed_stringctx(res:>string)|>getlethmaci_bigstring~keyiter=letkey=norm_bigstringkeyinletouter=Xor.Bigstring.xorkeybigstring_opadinletinner=Xor.Bigstring.xorkeybigstring_ipadinletres=digesti_bigstring(funf->finner;iterf)inletctx=feed_bigstringemptyouterinfeed_stringctx(res:>string)|>getlethmac_bytes~key?off?lenbuf=letbuf=match(off,len)with|Someoff,Somelen->By.subbufofflen|Someoff,None->By.subbufoff(By.lengthbuf-off)|None,Somelen->By.subbuf0len|None,None->bufinhmaci_bytes~key(funf->fbuf)lethmac_string~key?off?lenbuf=letbuf=match(off,len)with|Someoff,Somelen->String.subbufofflen|Someoff,None->String.subbufoff(String.lengthbuf-off)|None,Somelen->String.subbuf0len|None,None->bufinhmaci_string~key(funf->fbuf)lethmac_bigstring~key?off?lenbuf=letbuf=match(off,len)with|Someoff,Somelen->Bi.subbufofflen|Someoff,None->Bi.subbufoff(Bi.lengthbuf-off)|None,Somelen->Bi.subbuf0len|None,None->bufinhmaci_bigstring~key(funf->fbuf)lethmacv_bytes~keybufs=hmaci_bytes~key(funf->List.iterfbufs)lethmacv_string~keybufs=hmaci_string~key(funf->List.iterfbufs)lethmacv_bigstring~keybufs=hmaci_bigstring~key(funf->List.iterfbufs)endmoduletypeHash_BLAKE2=sigtypectxtypekindvalwith_outlen_and_bytes_key:int->By.t->int->int->ctxvalwith_outlen_and_bigstring_key:int->Bi.t->int->int->ctxvalunsafe_feed_bytes:ctx->By.t->int->int->unitvalunsafe_feed_bigstring:ctx->Bi.t->int->int->unitvalunsafe_get:ctx->By.tvaldup:ctx->ctxvalmax_outlen:intendmoduleMake_BLAKE2(H:Hash_BLAKE2)(D:Desc)=structlet()=ifD.digest_size>H.max_outlenthenfailwith"Invalid digest_size:%d to make a BLAKE2{S,B} implementation"D.digest_sizeincludeMake(structtypectx=H.ctxtypekind=H.kindletinit()=H.with_outlen_and_bytes_keyD.digest_sizeBy.empty00letunsafe_feed_bytes=H.unsafe_feed_bytesletunsafe_feed_bigstring=H.unsafe_feed_bigstringletunsafe_get=H.unsafe_getletdup=H.dupend)(D)typeouter=tmoduleKeyed=structtypet=outerletmaci_bytes~keyiter=letctx=H.with_outlen_and_bytes_keydigest_sizekey0(By.lengthkey)infeedi_bytesctxiter|>getletmaci_string~keyiter=letctx=H.with_outlen_and_bytes_keydigest_size(By.unsafe_of_stringkey)0(String.lengthkey)infeedi_stringctxiter|>getletmaci_bigstring~keyiter=letctx=H.with_outlen_and_bigstring_keydigest_sizekey0(Bi.lengthkey)infeedi_bigstringctxiter|>getletmac_bytes~key?off?lenbuf:t=letbuf=match(off,len)with|Someoff,Somelen->By.subbufofflen|Someoff,None->By.subbufoff(By.lengthbuf-off)|None,Somelen->By.subbuf0len|None,None->bufinmaci_bytes~key(funf->fbuf)letmac_string~key?off?lenbuf=letbuf=match(off,len)with|Someoff,Somelen->String.subbufofflen|Someoff,None->String.subbufoff(String.lengthbuf-off)|None,Somelen->String.subbuf0len|None,None->bufinmaci_string~key(funf->fbuf)letmac_bigstring~key?off?lenbuf=letbuf=match(off,len)with|Someoff,Somelen->Bi.subbufofflen|Someoff,None->Bi.subbufoff(Bi.lengthbuf-off)|None,Somelen->Bi.subbuf0len|None,None->bufinmaci_bigstring~key(funf->fbuf)letmacv_bytes~keybufs=maci_bytes~key(funf->List.iterfbufs)letmacv_string~keybufs=maci_string~key(funf->List.iterfbufs)letmacv_bigstring~keybufs=maci_bigstring~key(funf->List.iterfbufs)endendmoduleMD5:Swithtypekind=[`MD5]=Make(Baijiu_md5.Unsafe)(structletdigest_size,block_size=(16,64)typekind=[`MD5]letkind=`MD5end)moduleSHA1:Swithtypekind=[`SHA1]=Make(Baijiu_sha1.Unsafe)(structletdigest_size,block_size=(20,64)typekind=[`SHA1]letkind=`SHA1end)moduleSHA224:Swithtypekind=[`SHA224]=Make(Baijiu_sha224.Unsafe)(structletdigest_size,block_size=(28,64)typekind=[`SHA224]letkind=`SHA224end)moduleSHA256:Swithtypekind=[`SHA256]=Make(Baijiu_sha256.Unsafe)(structletdigest_size,block_size=(32,64)typekind=[`SHA256]letkind=`SHA256end)moduleSHA384:Swithtypekind=[`SHA384]=Make(Baijiu_sha384.Unsafe)(structletdigest_size,block_size=(48,128)typekind=[`SHA384]letkind=`SHA384end)moduleSHA512:Swithtypekind=[`SHA512]=Make(Baijiu_sha512.Unsafe)(structletdigest_size,block_size=(64,128)typekind=[`SHA512]letkind=`SHA512end)moduleSHA3_224:Swithtypekind=[`SHA3_224]=Make(Baijiu_sha3_224.Unsafe)(structletdigest_size,block_size=(28,144)typekind=[`SHA3_224]letkind=`SHA3_224end)moduleSHA3_256:Swithtypekind=[`SHA3_256]=Make(Baijiu_sha3_256.Unsafe)(structletdigest_size,block_size=(32,136)typekind=[`SHA3_256]letkind=`SHA3_256end)moduleSHA3_384:Swithtypekind=[`SHA3_384]=Make(Baijiu_sha3_384.Unsafe)(structletdigest_size,block_size=(48,104)typekind=[`SHA3_384]letkind=`SHA3_384end)moduleSHA3_512:Swithtypekind=[`SHA3_512]=Make(Baijiu_sha3_512.Unsafe)(structletdigest_size,block_size=(64,72)typekind=[`SHA3_512]letkind=`SHA3_512end)moduleWHIRLPOOL:Swithtypekind=[`WHIRLPOOL]=Make(Baijiu_whirlpool.Unsafe)(structletdigest_size,block_size=(64,64)typekind=[`WHIRLPOOL]letkind=`WHIRLPOOLend)moduleBLAKE2B:sigincludeSwithtypekind=[`BLAKE2B]moduleKeyed:MACwithtypet=tend=Make_BLAKE2(Baijiu_blake2b.Unsafe)(structletdigest_size,block_size=(64,128)typekind=[`BLAKE2B]letkind=`BLAKE2Bend)moduleBLAKE2S:sigincludeSwithtypekind=[`BLAKE2S]moduleKeyed:MACwithtypet=tend=Make_BLAKE2(Baijiu_blake2s.Unsafe)(structletdigest_size,block_size=(32,64)typekind=[`BLAKE2S]letkind=`BLAKE2Send)moduleRMD160:Swithtypekind=[`RMD160]=Make(Baijiu_rmd160.Unsafe)(structletdigest_size,block_size=(20,64)typekind=[`RMD160]letkind=`RMD160end)moduleMake_BLAKE2B(D:sigvaldigest_size:intend):Swithtypekind=[`BLAKE2B]=structincludeMake_BLAKE2(Baijiu_blake2b.Unsafe)(structletdigest_size,block_size=(D.digest_size,128)typekind=[`BLAKE2B]letkind=`BLAKE2Bend)endmoduleMake_BLAKE2S(D:sigvaldigest_size:intend):Swithtypekind=[`BLAKE2S]=structincludeMake_BLAKE2(Baijiu_blake2s.Unsafe)(structletdigest_size,block_size=(D.digest_size,64)typekind=[`BLAKE2S]letkind=`BLAKE2Send)endincludeHashtypeblake2b=(moduleSwithtypekind=[`BLAKE2B])typeblake2s=(moduleSwithtypekind=[`BLAKE2S])letmodule_of:typek.khash->(moduleSwithtypekind=k)=funhash->letb2b:(int,blake2b)Hashtbl.t=Hashtbl.create13inletb2s:(int,blake2s)Hashtbl.t=Hashtbl.create13inmatchhashwith|MD5->(moduleMD5)|SHA1->(moduleSHA1)|RMD160->(moduleRMD160)|SHA224->(moduleSHA224)|SHA256->(moduleSHA256)|SHA384->(moduleSHA384)|SHA512->(moduleSHA512)|SHA3_224->(moduleSHA3_224)|SHA3_256->(moduleSHA3_256)|SHA3_384->(moduleSHA3_384)|SHA3_512->(moduleSHA3_512)|WHIRLPOOL->(moduleWHIRLPOOL)|BLAKE2Bdigest_size->(matchHashtbl.findb2bdigest_sizewith|exceptionNot_found->letm:(moduleSwithtypekind=[`BLAKE2B])=(moduleMake_BLAKE2B(structletdigest_size=digest_sizeend):Swithtypekind=[`BLAKE2B])inHashtbl.replaceb2bdigest_sizem;m|m->m)|BLAKE2Sdigest_size->matchHashtbl.findb2sdigest_sizewith|exceptionNot_found->letm=(moduleMake_BLAKE2S(structletdigest_size=digest_sizeend):Swithtypekind=[`BLAKE2S])inHashtbl.replaceb2sdigest_sizem;m|m->mtype'kindt=stringletdigest_bytes:typek.khash->Bytes.t->kt=funhashbuf->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.digest_bytesbuf):H.kindt)letdigest_string:typek.khash->String.t->kt=funhashbuf->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.digest_stringbuf):H.kindt)letdigest_bigstring:typek.khash->bigstring->kt=funhashbuf->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.digest_bigstringbuf):H.kindt)letdigesti_bytes:typek.khash->Bytes.titer->kt=funhashiter->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.digesti_bytesiter):H.kindt)letdigesti_string:typek.khash->String.titer->kt=funhashiter->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.digesti_stringiter):H.kindt)letdigesti_bigstring:typek.khash->bigstringiter->kt=funhashiter->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.digesti_bigstringiter):H.kindt)lethmaci_bytes:typek.khash->key:Bytes.t->Bytes.titer->kt=funhash~keyiter->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.hmaci_bytes~keyiter):H.kindt)lethmaci_string:typek.khash->key:String.t->String.titer->kt=funhash~keyiter->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.hmaci_string~keyiter):H.kindt)lethmaci_bigstring:typek.khash->key:bigstring->bigstringiter->kt=funhash~keyiter->letmoduleH=(valmodule_ofhash)in(H.to_raw_string(H.hmaci_bigstring~keyiter):H.kindt)(* XXX(dinosaure): unsafe part to avoid overhead. *)letunsafe_compare:typek.khash->kt->kt->int=funhashab->letmoduleH=(valmodule_ofhash)inletunsafe:'kt->H.t=H.of_raw_stringinH.unsafe_compare(unsafea)(unsafeb)letequal:typek.khash->ktequal=funhashab->letmoduleH=(valmodule_ofhash)inletunsafe:'kt->H.t=H.of_raw_stringinH.equal(unsafea)(unsafeb)letpp:typek.khash->ktpp=funhashppft->letmoduleH=(valmodule_ofhash)inletunsafe:'kt->H.t=H.of_raw_stringinH.ppppf(unsafet)letof_hex:typek.khash->string->kt=funhashhex->letmoduleH=(valmodule_ofhash)inH.to_raw_string(H.of_hexhex)letof_hex_opt:typek.khash->string->ktoption=funhashhex->letmoduleH=(valmodule_ofhash)inmatchH.of_hex_opthexwith|None->None|Somedigest->Some(H.to_raw_stringdigest)letconsistent_of_hex:typek.khash->string->kt=funhashhex->letmoduleH=(valmodule_ofhash)inH.to_raw_string(H.consistent_of_hexhex)letconsistent_of_hex_opt:typek.khash->string->ktoption=funhashhex->letmoduleH=(valmodule_ofhash)inmatchH.consistent_of_hex_opthexwith|None->None|Somedigest->Some(H.to_raw_stringdigest)letto_hex:typek.khash->kt->string=funhasht->letmoduleH=(valmodule_ofhash)inletunsafe:'kt->H.t=H.of_raw_stringinH.to_hex(unsafet)letof_raw_string:typek.khash->string->kt=funhashs->letmoduleH=(valmodule_ofhash)inletunsafe:H.t->'kt=H.to_raw_stringinunsafe(H.of_raw_strings)letof_raw_string_opt:typek.khash->string->ktoption=funhashs->letmoduleH=(valmodule_ofhash)inletunsafe:H.t->'kt=H.to_raw_stringinmatchH.of_raw_string_optswith|None->None|Somedigest->Some(unsafedigest)letto_raw_string:typek.khash->kt->string=fun_t->tletof_digest(typehashkind)(moduleH:Swithtypet=hashandtypekind=kind)(hash:H.t):kindt=H.to_raw_stringhashletof_md5hash=of_raw_stringmd5(MD5.to_raw_stringhash)letof_sha1hash=of_raw_stringsha1(SHA1.to_raw_stringhash)letof_rmd160hash=of_raw_stringrmd160(RMD160.to_raw_stringhash)letof_sha224hash=of_raw_stringsha224(SHA224.to_raw_stringhash)letof_sha256hash=of_raw_stringsha256(SHA256.to_raw_stringhash)letof_sha384hash=of_raw_stringsha384(SHA384.to_raw_stringhash)letof_sha512hash=of_raw_stringsha512(SHA512.to_raw_stringhash)letof_sha3_224hash=of_raw_stringsha3_224(SHA3_224.to_raw_stringhash)letof_sha3_256hash=of_raw_stringsha3_256(SHA3_256.to_raw_stringhash)letof_sha3_384hash=of_raw_stringsha3_384(SHA3_384.to_raw_stringhash)letof_sha3_512hash=of_raw_stringsha3_512(SHA3_512.to_raw_stringhash)letof_whirlpoolhash=of_raw_stringwhirlpool(WHIRLPOOL.to_raw_stringhash)letof_blake2bhash=of_raw_string(blake2bBLAKE2B.digest_size)(BLAKE2B.to_raw_stringhash)letof_blake2shash=of_raw_string(blake2sBLAKE2S.digest_size)(BLAKE2S.to_raw_stringhash)