I just saw that Crypto.SHA1 and Crypto.SHA256 are missing the asn1_id method. Looking at the old crypto library the id should be
/* * SHA1 OBJECT IDENTIFIER ::= { * iso(1) identified-organization(3) oiw(14) secsig(3) * algorithm(2) 26 * } * * 0x2b0e 0302 1a */ static char sha_id[] = { 0x2b, 0x0e, 0x03, 0x02, 0x1a, };
or
(string)({ 0x2b, 0x0e, 0x03, 0x02, 0x1a });
(1) Result: "+\16\3\2\32"
but actually encoding it from start generates
Standards.ASN1.Types.Identifier(1,3,14,3,2,26)->get_der();
(2) Result: "\6\5+\16\3\2\32"
Why are the leading bytes missing/added? Similar discrepancies can be seen for MD2/MD4/MD5. SHA256 has an PKCS id (2.16.840.1.101.3.4.0.1) that should be added to that algorithm, if we can only figure out if the two extra bytes at the beginning should be there.