The unified diff between revisions [31712ff1..] and [494bb21e..] is displayed below. It can also be downloaded as a raw diff.
#
#
# delete "src/pk/asn1/der/der_get_multi_integer.c"
#
# delete "src/pk/asn1/der/der_put_multi_integer.c"
#
# delete "src/pk/pkcs1/pkcs_1_v15_es_decode.c"
#
# delete "src/pk/pkcs1/pkcs_1_v15_es_encode.c"
#
# delete "src/pk/pkcs1/pkcs_1_v15_sa_decode.c"
#
# delete "src/pk/pkcs1/pkcs_1_v15_sa_encode.c"
#
# delete "src/pk/rsa/rsa_v15_decrypt_key.c"
#
# delete "src/pk/rsa/rsa_v15_encrypt_key.c"
#
# delete "src/pk/rsa/rsa_v15_sign_hash.c"
#
# delete "src/pk/rsa/rsa_v15_verify_hash.c"
#
# rename "src/pk/asn1/der/der_decode_integer.c"
# to "src/pk/asn1/der/integer/der_decode_integer.c"
#
# rename "src/pk/asn1/der/der_encode_integer.c"
# to "src/pk/asn1/der/integer/der_encode_integer.c"
#
# rename "src/pk/asn1/der/der_length_integer.c"
# to "src/pk/asn1/der/integer/der_length_integer.c"
#
# add_dir "src/pk/asn1/der/bit"
#
# add_dir "src/pk/asn1/der/choice"
#
# add_dir "src/pk/asn1/der/ia5"
#
# add_dir "src/pk/asn1/der/integer"
#
# add_dir "src/pk/asn1/der/object_identifier"
#
# add_dir "src/pk/asn1/der/octet"
#
# add_dir "src/pk/asn1/der/printable_string"
#
# add_dir "src/pk/asn1/der/sequence"
#
# add_dir "src/pk/asn1/der/short_integer"
#
# add_dir "src/pk/asn1/der/utctime"
#
# add_file "build.sh"
# content [6fdd754df5acb227ee2bbcbb62ee469bccabcb52]
#
# add_file "mess.sh"
# content [ee34aef379627e97871efac71f93ebe600548bd7]
#
# add_file "notes/tech0005.txt"
# content [f4853d5fd1c3b89604d601783e5d07302dd7e187]
#
# add_file "notes/tech0006.txt"
# content [808b72012bf29653039b60246d3a93e1ef04ff56]
#
# add_file "run.sh"
# content [a3de4a3233961d1d7bcb88781e0c224d624523f2]
#
# add_file "src/pk/asn1/der/bit/der_decode_bit_string.c"
# content [124502ebdcfa0aea9821d1802ad27049a32b177c]
#
# add_file "src/pk/asn1/der/bit/der_encode_bit_string.c"
# content [7519cc10aa368d7d3087ab638721900989ffb2f7]
#
# add_file "src/pk/asn1/der/bit/der_length_bit_string.c"
# content [9e7e35c66dcb874c1888a4e1e3366bc9c8246db9]
#
# add_file "src/pk/asn1/der/choice/der_decode_choice.c"
# content [b42f2aa51999ab1a1643d208cd17ec663dfd9ac4]
#
# add_file "src/pk/asn1/der/ia5/der_decode_ia5_string.c"
# content [0368564f032b9fbaf4a430673fe306cc0677a725]
#
# add_file "src/pk/asn1/der/ia5/der_encode_ia5_string.c"
# content [57c849eb06ad7816e0080a9935794f7e208a022b]
#
# add_file "src/pk/asn1/der/ia5/der_length_ia5_string.c"
# content [0d538c963b79b6d3ecaa7e7fbb50eecf7f9edf7b]
#
# add_file "src/pk/asn1/der/object_identifier/der_decode_object_identifier.c"
# content [cbb123740cbdc724887e647afc83f0b5a9cab421]
#
# add_file "src/pk/asn1/der/object_identifier/der_encode_object_identifier.c"
# content [f40286bd83c9ea6154a0cf683f499c0895f00e06]
#
# add_file "src/pk/asn1/der/object_identifier/der_length_object_identifier.c"
# content [46fae94eb84b5af85543acb5092f4388171be261]
#
# add_file "src/pk/asn1/der/octet/der_decode_octet_string.c"
# content [818bd4829a592568427715a489744fe851004b17]
#
# add_file "src/pk/asn1/der/octet/der_encode_octet_string.c"
# content [dc6651e9ec3c1ddb52ff6211d1c3caa9d7d3b796]
#
# add_file "src/pk/asn1/der/octet/der_length_octet_string.c"
# content [e08f461aba3ce9e9d438f5bba2dd3d5435a1d912]
#
# add_file "src/pk/asn1/der/printable_string/der_decode_printable_string.c"
# content [24a774be26f0cf141b9f08058ed2006708354122]
#
# add_file "src/pk/asn1/der/printable_string/der_encode_printable_string.c"
# content [94ad3500660c20651849ea72d0cdcc81edd26ee4]
#
# add_file "src/pk/asn1/der/printable_string/der_length_printable_string.c"
# content [dfe9a2d25d55a1911b64f3367444f980438cb278]
#
# add_file "src/pk/asn1/der/sequence/der_decode_sequence.c"
# content [86f50d2479bdff803c068e121885175c032b66cc]
#
# add_file "src/pk/asn1/der/sequence/der_decode_sequence_multi.c"
# content [ab0211f4ea4eed25dd552edefe4028bea38c8c0a]
#
# add_file "src/pk/asn1/der/sequence/der_encode_sequence.c"
# content [792c3db0d29568f7fa3450e3eeabfd2e49d0348d]
#
# add_file "src/pk/asn1/der/sequence/der_encode_sequence_multi.c"
# content [1857a51d055148003b171b6208bc23c73d9b0268]
#
# add_file "src/pk/asn1/der/sequence/der_length_sequence.c"
# content [37ec5773651e7e3e7d30d1dc3e35777b8b2f4ba1]
#
# add_file "src/pk/asn1/der/short_integer/der_decode_short_integer.c"
# content [0e27a507a14d4fa094f32e05631711e63a714f6e]
#
# add_file "src/pk/asn1/der/short_integer/der_encode_short_integer.c"
# content [329ac63b8cfe79d2341d93c89e21dc8f692ca26e]
#
# add_file "src/pk/asn1/der/short_integer/der_length_short_integer.c"
# content [10df89f9544bfaedbc67e69bd2637fd700fc117f]
#
# add_file "src/pk/asn1/der/utctime/der_decode_utctime.c"
# content [4cb5bf42eeb9b9b83d6610dd3eae7203788e8792]
#
# add_file "src/pk/asn1/der/utctime/der_encode_utctime.c"
# content [f1623656c31d86e8710820430eedd270b678a8bb]
#
# add_file "src/pk/asn1/der/utctime/der_length_utctime.c"
# content [6b212542ca8b50c47e8c0ed1e2dba7b7f6486c99]
#
# add_file "testbuild.sh"
# content [5cb55071e5e0ec5d913365d0c47ab3586618dfad]
#
# add_file "testme.sh"
# content [4b8c8a593055e7938d63f87784cdec02d235d4dc]
#
# add_file "testprof/test.key"
# content [c17a11eef02d7a2ad7250bc2ee22bdf37ed21f0f]
#
# patch "Doxyfile"
# from [f598520dc8de8639cf00b6c10068be941f3314f8]
# to [965b49681f503adb5625decbe4f06b31d0d8b97d]
#
# patch "TODO"
# from [adc83b19e793491b1c6ea0fd8b46cd9f32e592fc]
# to [ee08adca96454cc03b64631f65020b7195d9b298]
#
# patch "changes"
# from [7af48b0b984f9514858fdecdcbd38ff95460a4f4]
# to [5e6b2dd772d307708dd2c22e367ecc803518f452]
#
# patch "crypt.tex"
# from [167807069423bd360720c6321abfc3a08be769f4]
# to [9d0e4b16e9c58b110c0453b7be0ba6f044efc4bb]
#
# patch "demos/encrypt.c"
# from [8f22401767e5b4048960ddb3a74e7f147d6f03d1]
# to [96f2bb8b37cb3b0e6a4760c5ee09c87a32e82e81]
#
# patch "demos/hashsum.c"
# from [8ab6e72a6c240058547f3b5b575df3dbb8235e55]
# to [34d53d4e033abb3b56d3ca91ff329d3d050cb441]
#
# patch "demos/multi.c"
# from [9fc4054e04be585b24b1d5005840528a7c1751fd]
# to [fbc94e576fc2728f537a8de2a1581ed16d015dab]
#
# patch "demos/small.c"
# from [8cb3a0d305ad5e6bc5646bd6f5ce2bca54be7c87]
# to [f75f2118189c56534ada98bb6e71ae540578360d]
#
# patch "demos/test.c"
# from [71c89230248837771cc5a0534af4dbfe2f2d824d]
# to [471f4ac922aeb44563b18bfb40f20ecf60009684]
#
# patch "demos/timing.c"
# from [5ee953004e190ea4799623e5bc9bdca0c9727f4d]
# to [3acf7517eabfd4f62530a8ca210ab84f2b8c8b1c]
#
# patch "demos/tv_gen.c"
# from [366667c4d035cfb459b521ac81000cff564b91ba]
# to [89aa4504677d22aa321893d6d9c06788896733b2]
#
# patch "doc/footer.html"
# from [71f094156317545aaa2f4e642f05a8c91a7d8abc]
# to [0e5ae37d02adb83ae291182903c4fe4152cdbd92]
#
# patch "doc/header.html"
# from [5666f806e6b87ed588ac1cd9bfbb6757f3d6b034]
# to [5f20c36d444f35084d054ddee5d6e6b56f98aeb0]
#
# patch "genlist.sh"
# from [a298a32fb96043b8a8e7d3ed3691e7ca4a98e4b2]
# to [f798fe9b01aef8b0ab9402ea9969c82eec907789]
#
# patch "makefile.icc"
# from [074ce8176358d32c84ea8e7cbb9bca86b9d3ce6e]
# to [1db577d7146b5024f1371e70169f8ea57f8dde4c]
#
# patch "makefile.msvc"
# from [cd11b38cbcef129bbafa9abaa574145c7f5a0547]
# to [06471f26754ab2b8fe4a9a065a25c0305a1eb08b]
#
# patch "makefile.shared"
# from [23206ff50cffc853039a6f6f612e7e90de5bd816]
# to [c0bd3aa7c8ff8332e2b67b42813d469c66a03f5b]
#
# patch "notes/etc/saferp_optimizer.c"
# from [f42419577021e48a5e2522a9041441152c79cd06]
# to [5b6ec6012f78c872b12eb0180ccf712b031689c5]
#
# patch "notes/etc/whirlgen.c"
# from [78675b211c37e90fa7a64c0bffb2e3fd254fd72d]
# to [39afe9cdced89ceb25048818d116d50e2d0be43c]
#
# patch "notes/etc/whirltest.c"
# from [0e2850e3f2d84392eb2157d92e741356723189e2]
# to [54db1492094068526c4227fa0001a73bdec87eec]
#
# patch "parsenames.pl"
# from [0ea305a2de0f95fcf326f98f949a5915e6772346]
# to [648a2b24ff66ef63c8665f79d7c0b697796d4df8]
#
# patch "src/ciphers/aes/aes.c"
# from [558140fe1020cfacadeb3bfba7163ec8bf1f947d]
# to [2b4241346e0b72c826331a558b790b5154659390]
#
# patch "src/ciphers/aes/aes_tab.c"
# from [6aa40d26867375630eeda1aa3160e339b55854d5]
# to [5e4d1fdedbd4d284e5f55b6c0000049811a3a3fe]
#
# patch "src/ciphers/anubis.c"
# from [c04797ce5a26527a5c197a85a78150b49e3f0c53]
# to [3b6a366bd3fcc9f36f13b1679b4aab1e2743f663]
#
# patch "src/ciphers/blowfish.c"
# from [99e204350bcc18510b36c75be0e27c55941cef58]
# to [abd3966672a621c393c5cab9ed71f39ff94c9efb]
#
# patch "src/ciphers/cast5.c"
# from [ca59e3ce578fdc040a7660b0dbfc7002ab9e3bbb]
# to [36575be89764f5deaee436b6d12851be50240ea3]
#
# patch "src/ciphers/des.c"
# from [94725b9892450212bf776fd4b701fdc40334ef0a]
# to [061580d86b86d272ef888272b8e604f70d7eec9a]
#
# patch "src/ciphers/khazad.c"
# from [96b37e809a38f7101e541dc51597aa126251f100]
# to [0766ec05b06b590736fa5b18f993a47aaca418b6]
#
# patch "src/ciphers/noekeon.c"
# from [69e2e18530ed08da686c76e9dd18a0f8df38d87f]
# to [6f888239996d36533be59e6ee031c709536be083]
#
# patch "src/ciphers/rc2.c"
# from [b1194f27b6ee50677a893071175db30a71baa71b]
# to [5d4f983538e061f3b3f4e1f2d52f6c06cec61ad9]
#
# patch "src/ciphers/rc5.c"
# from [49855e75e932d84796f5b0ef964fd4add0a9e4e1]
# to [eb19e99598ce9b4fe3674776af617791adee47eb]
#
# patch "src/ciphers/rc6.c"
# from [f243097cc834a80e6c43b07f868cdb493618df9c]
# to [f19d158bab217262a5b6a48711b7af6e198b0c66]
#
# patch "src/ciphers/safer/safer.c"
# from [159880031f6347201b42439b3a032e3415c890ee]
# to [7caa9b5ca07bf10d2101c59c74fff9105975e5c7]
#
# patch "src/ciphers/safer/safer_tab.c"
# from [87f524d91ffa56751b05345283849aaf100f94ca]
# to [ae782cabbd071676d9794deec9583827873b0bb1]
#
# patch "src/ciphers/safer/saferp.c"
# from [205fdd6569426b767b947aed9438a069d57ed2a1]
# to [69028fce205b8daab0dad11e482028fc50d8ba8a]
#
# patch "src/ciphers/skipjack.c"
# from [30515990e0e4f115c76656dde232cd60617bc2e9]
# to [868611ba96f0b59d98cf5cf0b47cbd05ebebf460]
#
# patch "src/ciphers/twofish/twofish.c"
# from [e92756325032dd319325d4144769aff494bb3890]
# to [cc01e431050c57f8fbe010bb7b71514a824e7f0d]
#
# patch "src/ciphers/twofish/twofish_tab.c"
# from [22a405fe6a7757eeb2125e03c0065347977327e5]
# to [3c7f1812d71ca5c5311f3bc051a33da0bff126c7]
#
# patch "src/ciphers/xtea.c"
# from [ec8bb1ac97b4f6b7783f60122f78fdd5328f7aa9]
# to [763d882c9fa168cb8faa35e851234437d8284a3a]
#
# patch "src/encauth/ccm/ccm_memory.c"
# from [7aa783eee34c730b442067ed54c195012980bbc8]
# to [364966474d7b4b52ae448086ece214f7038555e6]
#
# patch "src/encauth/ccm/ccm_test.c"
# from [f535080cb6918bd2958945ef3f6e9aab298cafa7]
# to [b5ecd2f4b12a9fec084f3f8e7e6708f61954d0c7]
#
# patch "src/encauth/eax/eax_addheader.c"
# from [54da61b70a12678e19f6cf32ce64b9db5d451c2e]
# to [26d1a3b5c117295aa1bf6566f0e6b9a17d42d7e8]
#
# patch "src/encauth/eax/eax_decrypt.c"
# from [30f72b465671c0ac5f7071704cd280cc24e1f119]
# to [156800632e38ca156699cfb725362370850eeef6]
#
# patch "src/encauth/eax/eax_decrypt_verify_memory.c"
# from [0334f04351aed94c93b40d15bd7988f79b83ee81]
# to [06cafe2a350a6242bc3449b0740c567689d0bffd]
#
# patch "src/encauth/eax/eax_done.c"
# from [b0d6517ecfae1e30271c2a0b01194d519496bc07]
# to [f02e476731d9abd88475afe5f9674f34e37a715e]
#
# patch "src/encauth/eax/eax_encrypt.c"
# from [e811ec77026bcd707697e892020009b1d303c316]
# to [6b4d667de01909400a1bd0e6741a01c09c6e00b7]
#
# patch "src/encauth/eax/eax_encrypt_authenticate_memory.c"
# from [859a24ee147d4f621228d477ec19a6fbbdf84d4a]
# to [a36dbe130915db7e5b7cef809b251ea682903007]
#
# patch "src/encauth/eax/eax_init.c"
# from [994a1a1904574e5e29862ae5ff8ffc0e3ad1e35c]
# to [20be71323fe74756d9db03cb5b7673afc7c7e9e0]
#
# patch "src/encauth/eax/eax_test.c"
# from [569e6af97711a030ad120c230ac2a82f84f99258]
# to [6a6a6b02c3bf640b758892017cc2b7f59d516ed7]
#
# patch "src/encauth/gcm/gcm_add_aad.c"
# from [edec18cf102a01a941095de5a7142f608ff55c13]
# to [488e4c8c70591a40cfcd6c5d45446e10177923a6]
#
# patch "src/encauth/gcm/gcm_add_iv.c"
# from [9d4f03deceb813060a907f1e3ac21a31eb8b7d94]
# to [22fbdfc1061e756f0792b8f1e69e0eb942b67d85]
#
# patch "src/encauth/gcm/gcm_done.c"
# from [f8aba7c71c1f377728073803f1d5f0be563dd042]
# to [96afa40e4e5358f4e7e085776fbee295f79b2257]
#
# patch "src/encauth/gcm/gcm_gf_mult.c"
# from [069b4fd0c7a140948ba1bce6a4fc960ff70a3712]
# to [09e626c86af66066a742f6a68f39a2ee08b3bc2b]
#
# patch "src/encauth/gcm/gcm_init.c"
# from [9a14fe8ea735d8d60fa37ea432e4ce56bcc9fa36]
# to [6896f998f78576e73d3b9268be1ababf7295acc4]
#
# patch "src/encauth/gcm/gcm_memory.c"
# from [d7f897fe165231a790613d85f1433be98af84405]
# to [625deeec8ef20f964c0474f38eb3a6e96964e501]
#
# patch "src/encauth/gcm/gcm_process.c"
# from [9ba906686befe29b4a26a6863900d02cc8e51852]
# to [b4ce8258428a094930d55d694d31f3f55bc05acf]
#
# patch "src/encauth/gcm/gcm_reset.c"
# from [f1547db92cc5232fde292dcb29c42f955f18b01f]
# to [07dd1ed36b20f797f3dcd871beab9fb3bad00ae0]
#
# patch "src/encauth/gcm/gcm_test.c"
# from [f6e9a41af3688ae1b07c06fcea403087a17538e5]
# to [09bd29cd7482a235a5cea20197992d2748b97f66]
#
# patch "src/encauth/ocb/ocb_decrypt.c"
# from [fa8be4e45994c0acc5d298d8917681f66778d38a]
# to [4cff476e9b4623b23affbba6d31c5438b4fb74a6]
#
# patch "src/encauth/ocb/ocb_decrypt_verify_memory.c"
# from [6a3a72959384d484b69247063d8c081e4732ca76]
# to [411dddfb0c9061dd19a6b8e30240e65ff1e5cbe2]
#
# patch "src/encauth/ocb/ocb_done_decrypt.c"
# from [5d0c1fb4cff9ce7ac8d4d5bfa6465707f20dbefe]
# to [cdc2cb34f2720284888fa739e7e41c63ff7052f5]
#
# patch "src/encauth/ocb/ocb_done_encrypt.c"
# from [3b3730f538929a5df9e8308897d0975df24cd3a8]
# to [0a9b215485c9f7a7e9377796125c9ff09b566083]
#
# patch "src/encauth/ocb/ocb_encrypt.c"
# from [4696aacaa626f3ebddd41c6af12ec6a5a1c6d571]
# to [f15bfb6578fdf3347e24b3afb035d81747e9417d]
#
# patch "src/encauth/ocb/ocb_encrypt_authenticate_memory.c"
# from [cbc1afc1d30a5fe827ecd8834cb7e571cd1b6d94]
# to [1ca962172743bf96e16a57b3cecc4b4d703dda3e]
#
# patch "src/encauth/ocb/ocb_init.c"
# from [a428d6e911235d71f2f0e4ffef1ecd7caddd71b5]
# to [008797b24b779e6ec0a2f6dd9bcd73cf474d09fd]
#
# patch "src/encauth/ocb/ocb_ntz.c"
# from [d7e1b3355be90137006f64a2af7a34b4eacfc693]
# to [9ad7b7590813bf5f43d25333b12ec64ede12fd51]
#
# patch "src/encauth/ocb/ocb_shift_xor.c"
# from [9df2150677e0abcc57a357c69d8b344e6f97b4f3]
# to [589c159c3edc95900a59a0568d46f4946b0dbab2]
#
# patch "src/encauth/ocb/ocb_test.c"
# from [22cf7cbe500b1b52d5825349cb578b962eb37aae]
# to [0a3442d6499d19427a77f367bef1de3bfd56054d]
#
# patch "src/encauth/ocb/s_ocb_done.c"
# from [76d936faff9dbc74cbd0074835188dd56044086d]
# to [900ebdeb1cb674d2155e665ed55b104683c0c868]
#
# patch "src/hashes/chc/chc.c"
# from [e84fa8757fd857ba0dcfcb4ffb605c4142cdb2e6]
# to [c9c6a67e0c435fb792451272a84d9ad3060c515e]
#
# patch "src/hashes/helper/hash_file.c"
# from [5c7382f84dde857ae229cfb1880eeeab74ffe93b]
# to [2e09e32cfcfa2e42ddc4a3e47da9b3cf351b23fd]
#
# patch "src/hashes/helper/hash_filehandle.c"
# from [9acb233f5fdfd4cc83accb0c6bfea04053caa53c]
# to [6f35e6b5122858e0d46b715cecc2317d447f5ea1]
#
# patch "src/hashes/helper/hash_memory.c"
# from [54854ef926cfeb7596071b8c986d1507281b1fa9]
# to [ca78222a4b9bd8f916c3f5f079d3bbe7d24a36ec]
#
# patch "src/hashes/helper/hash_memory_multi.c"
# from [6eabb84a9920bda9e1c9baf0ebeb96f673d124db]
# to [65d168ca0e97b879f9ad1e4cd327e319459259ed]
#
# patch "src/hashes/md2.c"
# from [635eca4de00349c7fa5b9e318ad0664b3755010e]
# to [ece687f327a355a7fd71fcc2cc44e038d48cb87d]
#
# patch "src/hashes/md4.c"
# from [ac21a62167a7c87186007e570f4e6109a5f69ae3]
# to [08aeeeb1371290f8a8fbe208e8fe01780120356b]
#
# patch "src/hashes/md5.c"
# from [e80689df83c9bd087ba1b23c0784a93d931f2856]
# to [eaaf0037124ae924f9c70cd895ca24c643d69dde]
#
# patch "src/hashes/rmd128.c"
# from [46d2298e5b48a6d766472eb66f12ec5155bf6c0f]
# to [bef52df8af069e995d5ab0332c4e5c016e62177e]
#
# patch "src/hashes/rmd160.c"
# from [d5dc3993de901e20e76ceb5fb8b7326a5ec903d5]
# to [d07679b36c4ce346b73e68a3ca35b327a85724e9]
#
# patch "src/hashes/sha1.c"
# from [928cfd671d995ed512e398a050c8cd21c69a3de8]
# to [d7f5eecff190b32e59f7ef83298fcae7ffe50099]
#
# patch "src/hashes/sha2/sha224.c"
# from [4c2aa772ad27f88b5ce05cb8f16fd7ccb2007e54]
# to [49ddb25abd6a93eaea004950287a84d2f08de7b4]
#
# patch "src/hashes/sha2/sha256.c"
# from [2e4eb8930b8dd053a87c8d339825ed4bfb1dbf54]
# to [41472ac44b4f7db06b11b9ef804404dfc2eb8035]
#
# patch "src/hashes/sha2/sha384.c"
# from [0a376f4f101f8fb1168d5d88fbe14630480c4807]
# to [78272b4f576fcc46ab0f313c93654bf4a18ed1d4]
#
# patch "src/hashes/sha2/sha512.c"
# from [f3270b310e6e7991c123c6598f5266f5fc2d070a]
# to [0abb7bf30c6d27e6c3dceaa48a88b3c5b9b39f74]
#
# patch "src/hashes/tiger.c"
# from [f6cc0cbb334efa0fa5b54f5f93ace0c3ff91a6d1]
# to [b52c2abe4250b5de9ed4120c6ae7fb9f7c33214a]
#
# patch "src/hashes/whirl/whirl.c"
# from [dba6eede1bab0e1d91dc9a63dd3dafb52e02a28f]
# to [fa54a1033580737b4084442a9eb5e86d9c65e38a]
#
# patch "src/hashes/whirl/whirltab.c"
# from [618a74a7e1d8114985486557e5258276e02dce67]
# to [b46a2443ddb64fe1c0ed34b92d3ffbaeed61d95b]
#
# patch "src/headers/ltc_tommath.h"
# from [dd8f0170439f781295162b36a085638aee7e6574]
# to [a6ad1c8a7e280669d3ec8b6d150451ec1d1c9ea0]
#
# patch "src/headers/tomcrypt.h"
# from [e886ca765cd37ad34f2bc79670c4b4fe8b103a15]
# to [bceecf59bf6a6fd02640e37dc21590c4327c88f2]
#
# patch "src/headers/tomcrypt_argchk.h"
# from [edb91e50137d2749e5408cd81c46c655addb7216]
# to [0f2e2d74131de68de1dbf8b80ffb897e3c92f5d6]
#
# patch "src/headers/tomcrypt_cfg.h"
# from [00f8eeeb65e6e41e7eb82c753d5df50dd2558bb7]
# to [2183f8b4456136feda31f32d056862eb3ce6a5ac]
#
# patch "src/headers/tomcrypt_cipher.h"
# from [f64337b619123bb38dd6d1ce6395d7edcc103cfb]
# to [111bd8bf66cb23359cdb27b5f3ec1479cbbdb380]
#
# patch "src/headers/tomcrypt_custom.h"
# from [df1fe7a694865e5a4adfa9ddcf6c9bf0840e21fb]
# to [baa9c701e90b3de1330da7c185a90cb5256ebc44]
#
# patch "src/headers/tomcrypt_hash.h"
# from [651df488cac70df27c536395f7c6dd8f32d8f7d3]
# to [c1ced8ed0a7bd83ba58a98f40e0827d8bc7f13fa]
#
# patch "src/headers/tomcrypt_mac.h"
# from [d32a763272f2ecdccae2479bcaf14b3fc389d4ba]
# to [e248dfe77f26271526185bf96c21aa20f87f0381]
#
# patch "src/headers/tomcrypt_macros.h"
# from [c3d4a6951627f8948958a7b52d1eec8edd63de33]
# to [90831ab5a2fb50959e9d9bc6a2e426b039cdb1ef]
#
# patch "src/headers/tomcrypt_misc.h"
# from [2e32eec0844c6aab3c447e344f539dae2888bf1c]
# to [2137350d66d2b64205947792b5b89208510d6c50]
#
# patch "src/headers/tomcrypt_pk.h"
# from [ee3d17e4ab485b9a69da6fd246ef07ad66d3eb0e]
# to [0cbe63bd012ca6ed3e248c7a621cb4e363e2465e]
#
# patch "src/headers/tomcrypt_pkcs.h"
# from [9f28361cb5f5126bc309575ca33b0e30e884ff2e]
# to [1af35751a7494c7f89904aeda462e6baa7720e95]
#
# patch "src/headers/tomcrypt_prng.h"
# from [e1833b46a52910b766a378ea268c70995e76191a]
# to [89674e4e0d214164a2e0db6917ae3731a9fa2edc]
#
# patch "src/headers/tommath_class.h"
# from [a91c35ab0e5d115c16d6c6c9f6a107d22ee31d55]
# to [bfdec2d39bd21cf3cbba50b791f687c8021ec6e1]
#
# patch "src/headers/tommath_superclass.h"
# from [47527ad5ee97a9524e14b307da9796293b1f586f]
# to [804d02f839ed9eb510c0357c8c5f668eab0ea0fc]
#
# patch "src/mac/hmac/hmac_done.c"
# from [4cf1736e9f5b8eae8157a1d1ed75550862a7f9c3]
# to [830ce002191b07ed010cfbe3ebafaf599514e35c]
#
# patch "src/mac/hmac/hmac_file.c"
# from [d0dda234c1119734c21a153e0501b484fba34b5f]
# to [cba21a9e8f1ffdbf0bdadec345118d8056f15b00]
#
# patch "src/mac/hmac/hmac_init.c"
# from [bc94183b075988f8b2c06f6e270a0da0d7c2122e]
# to [8b4d50b9190d94a292d038776667ac5e68469f73]
#
# patch "src/mac/hmac/hmac_memory.c"
# from [2d49bba01a1826af0cbefadc0e7673a2f58cff38]
# to [2ac221c04ad057319e58880c54fc6a223265bf2e]
#
# patch "src/mac/hmac/hmac_memory_multi.c"
# from [18fb26628b34b1fe3dcd528c8f4424c7e4cdbc51]
# to [db5e84752ff3b9eb06bd029fad08b4077f4707d7]
#
# patch "src/mac/hmac/hmac_process.c"
# from [416afc863d3ff74d528855802c3e3db76782907c]
# to [cf938a2b5d5c09f1cdd2f833c8f222664a7ef623]
#
# patch "src/mac/hmac/hmac_test.c"
# from [64ea8b7e74f63276f06cb23a807b786a3f890a14]
# to [7da9b4c2226351f5648c2cae38e41a2228f25163]
#
# patch "src/mac/omac/omac_done.c"
# from [0f5c7fa106f551baf73708a333819e9c06389ea5]
# to [e2d78a61797e4ff9adbc1dedd5da98a7d2e95830]
#
# patch "src/mac/omac/omac_file.c"
# from [e19e6ca6f578697660a926af09a282a84f705033]
# to [f8153f37ea40c07c9fef04ac36ba9bcf43d1744b]
#
# patch "src/mac/omac/omac_init.c"
# from [e5494ef2fa438568140ae84c1662fece231292c1]
# to [16be47c6d1baea3ef6177d605fc11843e17439f0]
#
# patch "src/mac/omac/omac_memory.c"
# from [34e98ac77e9b27fb46fc17c9ba844cae8854fa9f]
# to [085f9691bc92bc058f013c893a41280490b33307]
#
# patch "src/mac/omac/omac_memory_multi.c"
# from [ff4437278094f3a6bbe64311d4af2c68fc0481fd]
# to [a09d05a87abb45f526c417a5a4d46d31b27de0e1]
#
# patch "src/mac/omac/omac_process.c"
# from [98e14fd297795a16d5848a35a4ae5abfb7a4e423]
# to [5c4a530ab94b6eb25e7c07ad422548e05497d75d]
#
# patch "src/mac/omac/omac_test.c"
# from [249568fe334d3d6959e328b606cd00255bfd6c59]
# to [89b8600f5b778f718d2e2586a963e1365312096b]
#
# patch "src/mac/pelican/pelican.c"
# from [fd5e3a0d7d0d04b5e8606a095087e7507f7bf2fa]
# to [821e8c39d43f95fb7f67dc9a61f2321c57974fef]
#
# patch "src/mac/pelican/pelican_memory.c"
# from [1b51066303bbbe1a513f9cf20a13534f47057152]
# to [810cae7759949e01fb93ed019f6cf7fac43ff23d]
#
# patch "src/mac/pelican/pelican_test.c"
# from [75b1e1ff21eaf78a25fd43558491422ce37ed4db]
# to [a594625260e82831bd75fb04ad91de1e83b791f1]
#
# patch "src/mac/pmac/pmac_done.c"
# from [facd4596a001a3e8d0bf090fd42257772b8a749f]
# to [395bd725adec86ea03d81fd24e389a2235826fc0]
#
# patch "src/mac/pmac/pmac_file.c"
# from [560d3c5982590cdc922b1b48afe2ef60c1759c13]
# to [23525f3b42869e2ff69db36c8b5e83c7b769a2bd]
#
# patch "src/mac/pmac/pmac_init.c"
# from [248a7874f5d4de42b15bee4d9d623f88e65243b9]
# to [f1b9cd65c1ac3cf84f450821c8154ed5060dabb2]
#
# patch "src/mac/pmac/pmac_memory.c"
# from [3b7fdf9029a92e8153f57e86bf190a66bb517dd5]
# to [4d9991501038856d19d31de036f4172d91077111]
#
# patch "src/mac/pmac/pmac_memory_multi.c"
# from [b4c924de487f09e6ea30adcb33dcc0bb8478c113]
# to [44576abaa594d6b762d9a5b0b76a44a750cc4918]
#
# patch "src/mac/pmac/pmac_ntz.c"
# from [32735d3c542079e238e82c437a2555843f09038e]
# to [b2e8bb923b5560bb7f3aedfc71fc19cb3242acc6]
#
# patch "src/mac/pmac/pmac_process.c"
# from [911818803695bdd7640a944293294981791676b8]
# to [6810c45353e9430a866cde47f272004a4240b7a1]
#
# patch "src/mac/pmac/pmac_shift_xor.c"
# from [35150cfa2c1f46fabdec097c3a50631f9b7c646c]
# to [c8e491c7131ce4e912f1180789b280ed52554c02]
#
# patch "src/mac/pmac/pmac_test.c"
# from [43b056a1ffb3767148c33c8b69dbb670bc8f1c83]
# to [b51f7ac831d65ef710b98ff9c09af8be7c2425f2]
#
# patch "src/misc/base64/base64_decode.c"
# from [1234d08a6b8e62f9404656f94cb37667a704822d]
# to [06a5ce800927e83cea98ed256790fca8e8fd22bc]
#
# patch "src/misc/base64/base64_encode.c"
# from [a0c2917fee5a620ea834bc583366fb5e76f47be0]
# to [f7bc6e9ceb8f1a484f886437cc419bed4712164f]
#
# patch "src/misc/burn_stack.c"
# from [a612253210fe6b15297cb1e16edb7056289c4fcd]
# to [caf4bc2d8db35135ee7574b9b2b002e6051eef40]
#
# patch "src/misc/crypt/crypt.c"
# from [e259676da511645310599e62a08a44330c83624e]
# to [3e6e49ccaf2067e1ebe1df669eb58a927c43a6a0]
#
# patch "src/misc/crypt/crypt_argchk.c"
# from [d8d16e6b3218d44f631b7d4953ad16c27bdaccf5]
# to [2c479f471c4075cf4e4f9e59a2a10946a0201256]
#
# patch "src/misc/crypt/crypt_cipher_descriptor.c"
# from [128f8116648e023b15024995f9ed4916ce9672e8]
# to [73f932c13ab5f26a7b58215f892aaf81eaabcb14]
#
# patch "src/misc/crypt/crypt_cipher_is_valid.c"
# from [7b797c8118241891e75a5d24a17cfbc74987b4bb]
# to [0709756d15e9c7406036d894fd8d8557c024a809]
#
# patch "src/misc/crypt/crypt_find_cipher.c"
# from [de5cb0722faabf8c7f229296108959875f68ca28]
# to [2b7184d907e3dec8b07602f2a2a728a3117ab35d]
#
# patch "src/misc/crypt/crypt_find_cipher_any.c"
# from [e84adb7c2d8c2586dd111b918d16d191be154e13]
# to [5ab0723b521cb2e0573076ee7b2443336fc440c0]
#
# patch "src/misc/crypt/crypt_find_cipher_id.c"
# from [1d07300a2f76095c916c695f2e0435cc94e36ffe]
# to [ff397ce99ac1432e850426c871246fd9150539da]
#
# patch "src/misc/crypt/crypt_find_hash.c"
# from [1a55324ea7bedb47fea8a1db9071310b8f632948]
# to [476b4976ac23a6b0f8c04f1ee2c7c76c7b316321]
#
# patch "src/misc/crypt/crypt_find_hash_any.c"
# from [da3dcb6ffc03fa5126909be763c86cf5c3a6f51a]
# to [11de7fc09c2192142aabf52bc4b1717f8661f2de]
#
# patch "src/misc/crypt/crypt_find_hash_id.c"
# from [aa68c34f6dff090d85d7e7d0a7bbbe5ac667ef59]
# to [e1ba2002d82e219d2e56275a7130ca0cd3f79d55]
#
# patch "src/misc/crypt/crypt_find_prng.c"
# from [bf07beaf5c13dd60bf5d1ef16a585a87b8bcd975]
# to [34967f9e2afb080c6e265cdbf3850110940750f4]
#
# patch "src/misc/crypt/crypt_hash_descriptor.c"
# from [31cbe8deb690142c3037bde1dd0e5536ea6a4b5b]
# to [e3dbe0f53fc63730885e25e8abf9c6bd12223eda]
#
# patch "src/misc/crypt/crypt_hash_is_valid.c"
# from [e0f6732986e4f9d9b6383fbe0bf451cc0bd12c3c]
# to [b39564f1f2cf44b8ebff19c6f020f7dd2e2c9c1a]
#
# patch "src/misc/crypt/crypt_prng_descriptor.c"
# from [463cc3a1c94ceb1a33d0bc26adf45723ddbf5c92]
# to [2ede0fb59891ecc5304e4ded54df4c66d3ff600c]
#
# patch "src/misc/crypt/crypt_prng_is_valid.c"
# from [d668c3c1a0845bdcd3283ad30e1c6b02c7cc17b7]
# to [e659acc91909966777347558f8557210e840edfb]
#
# patch "src/misc/crypt/crypt_register_cipher.c"
# from [35fa0aaedf4a678f795b3f6a81c2c6432e1a1020]
# to [e1b80d76dd8e11a78a53bab2672a1c6a6ccad9aa]
#
# patch "src/misc/crypt/crypt_register_hash.c"
# from [ffe4cea6e07bd8cc2edc3ebdd480daccba064496]
# to [1dba421730f0d54e2e5f761d04920711c283cada]
#
# patch "src/misc/crypt/crypt_register_prng.c"
# from [61e163ab3ab26886f7a0d9eb2ed65f2b1f5de7bb]
# to [d2d86c2d1258b5fdbbbc9a8cd74ef9ad1435c356]
#
# patch "src/misc/crypt/crypt_unregister_cipher.c"
# from [92980848872076139f662b987a3fafb2c538bb6e]
# to [e4d1c233e4a5a978ddc45e3a172b22d874ca01d8]
#
# patch "src/misc/crypt/crypt_unregister_hash.c"
# from [acdbdfc8d6df9dc16ae3f48f1d4eafba334b348c]
# to [372403e67f0e6cc7853fe2f210939bc92f1e0548]
#
# patch "src/misc/crypt/crypt_unregister_prng.c"
# from [37a0739cc9aef8471043ccb92f73a13709cd05d2]
# to [66f1ec4730e95d001b2ba18c1b354c064a4cca40]
#
# patch "src/misc/error_to_string.c"
# from [44d80375b9e86aca6148c8236b34eefdbd8fcfe4]
# to [8f05e03460d34499712060ecd422a51ce0654c51]
#
# patch "src/misc/mpi/is_prime.c"
# from [f90368f0eea64fb7d8294580bb4a13f6e912717c]
# to [83e72f8c29bf7644a2b345a531fd5d702d51cdd8]
#
# patch "src/misc/mpi/mpi_to_ltc_error.c"
# from [12426967cef16802c06111345a0a00ff131554cb]
# to [f395a4779049cfef3611b316463cfdbe673e75e0]
#
# patch "src/misc/mpi/rand_prime.c"
# from [56895c9c59102fea0554f586507a6e5e71e98e01]
# to [194d34e51de2b0a1468133a049c129a15de13162]
#
# patch "src/misc/pkcs5/pkcs_5_1.c"
# from [5fa7e88b321abdc133e2bb8d0906c8aedd7d0bf0]
# to [793dc22fe06f752db28714d47b9bcce1683375cf]
#
# patch "src/misc/pkcs5/pkcs_5_2.c"
# from [70fac0e375dcf0ab0ea3ebdd27b6c3bd4c465fb9]
# to [cb0e63ae9481366f2372a7a6f337271d20ba281a]
#
# patch "src/misc/zeromem.c"
# from [8d923cd228e0bd3624f95ecf70ad4c0845512d7f]
# to [b2a19872a28f4b41103dd44c9f0f8159530949a9]
#
# patch "src/modes/cbc/cbc_decrypt.c"
# from [26c4cb70ca3990284d7c7279efa54050cebc4df1]
# to [5657191904b53c1e2306c6e6c4a7875133994326]
#
# patch "src/modes/cbc/cbc_done.c"
# from [30128d5ca583a558618dbf1ad7f09a1331d45d2e]
# to [8ebf4b6eac171b79f7f84c189c55fe38ed3013f8]
#
# patch "src/modes/cbc/cbc_encrypt.c"
# from [9b66bfa3b7f59a72e721ab13549d44268fd973cb]
# to [3807fb6073ece9d2640e6f3de47a1342d62c9757]
#
# patch "src/modes/cbc/cbc_getiv.c"
# from [5d66bbe0024a84042e7c40a154f3396d5117949d]
# to [7f5b71fc6a30f319cf0f77d5172e3674ab2fd98d]
#
# patch "src/modes/cbc/cbc_setiv.c"
# from [e4b7c01a6b7483ac0a088f4cf2ed05cb3fa21645]
# to [0eb7da8bb5c8947b3db9e0895a5d4229b996e5c9]
#
# patch "src/modes/cbc/cbc_start.c"
# from [759e39ab6e48aecdfd859d0304939fe5d99c66d3]
# to [d72bc2140a079b057b5d613a52e76b21683c6856]
#
# patch "src/modes/cfb/cfb_decrypt.c"
# from [11493900d8af922cd2bff4ac35736ac164221589]
# to [e8607545ea7b5979ed6e6b9904dbbb18c6d0c393]
#
# patch "src/modes/cfb/cfb_done.c"
# from [b4f30dcca617aa14d75cc42983e4c16c9a1ff4e3]
# to [fb7c9f663fb3bc9673d396763bba10e8f2c63cc1]
#
# patch "src/modes/cfb/cfb_encrypt.c"
# from [92a48265c262d030ddbc33a52389c96efa8e3951]
# to [14a69e6a4a06fa12eb4dc435249caa8478d11fcf]
#
# patch "src/modes/cfb/cfb_getiv.c"
# from [fdc28b694bb32f3e8c4268fe0d77d21e63381038]
# to [eaf7c390991e4883bc3758be55877dfd799c7988]
#
# patch "src/modes/cfb/cfb_setiv.c"
# from [914640893997bda295b76b0b00910c8933eb1746]
# to [124740d4b6fff12f3c9e643a0cf3b355055e0ea1]
#
# patch "src/modes/cfb/cfb_start.c"
# from [0322866d5549c92af8af4f021f3d846621c99bc1]
# to [9abd8e45c4122c3c22ae012bfcbd58406161d6f9]
#
# patch "src/modes/ctr/ctr_decrypt.c"
# from [2a65bcbcd9b291e6f88214ff8b2542c9ad81b489]
# to [ee776d7959d119c232920d1e3d42ee257f8b07ca]
#
# patch "src/modes/ctr/ctr_done.c"
# from [0c5cdc744e32054cdb79ca435507f99c8268e0f8]
# to [9b7159a30e6466f872463f3015ac30f5e1475a1f]
#
# patch "src/modes/ctr/ctr_encrypt.c"
# from [edca09fecfa62ef9efad01f2f105e5a0ec83cf0c]
# to [21fe301efa077202148343f086ff6f9926725447]
#
# patch "src/modes/ctr/ctr_getiv.c"
# from [ed2e6a9794de7e1cb06aaee7a96de37769ac250f]
# to [028d7e4f016b3bd22a704c647fa477e5b6584d0d]
#
# patch "src/modes/ctr/ctr_setiv.c"
# from [8e4ebee2d13ddb2cd06c87bd70779ce1a94b0fef]
# to [6574faa288336fce210c09574de3dcd79680d089]
#
# patch "src/modes/ctr/ctr_start.c"
# from [1d6d95c609864ff54af4c190143aad5f94637f38]
# to [93c4e9fc22ddedd10f8d5e45aa4fed6120d3112a]
#
# patch "src/modes/ecb/ecb_decrypt.c"
# from [80bbc43f117ec8c86c5dda102e122f3cb53dd81e]
# to [c58ea543f299be0533fb37d04568a14e7c0e529f]
#
# patch "src/modes/ecb/ecb_done.c"
# from [ec87a5d64790f194b263bf1c0c5b34a16f56b4f3]
# to [b989329af83ff1da7cdfb6bba77cc4a80987d4f8]
#
# patch "src/modes/ecb/ecb_encrypt.c"
# from [e434144bb08b2ca984a3c487a4560773b7c215fb]
# to [7f394644cc1a95161b106b57f323ac3f1f887f43]
#
# patch "src/modes/ecb/ecb_start.c"
# from [3676c0039ec13f09585eb6c77fab54eb21fefe10]
# to [4603e4eabd823ac3da3ae4f510ec14bddde2d008]
#
# patch "src/modes/ofb/ofb_decrypt.c"
# from [cee2112ed1c12ab20fd624cbfbf404dd2ee80196]
# to [65c8d77312929be4b5929ba72c92494d21adb6dd]
#
# patch "src/modes/ofb/ofb_done.c"
# from [d4c90fbd88a6ddd83642dd3d1cd6f17fcc372bb9]
# to [bab707be6ba6e854f7e9a51641a7188dec22ece6]
#
# patch "src/modes/ofb/ofb_encrypt.c"
# from [09a23059e097f3b943f16cd2a5f126b2c929ef96]
# to [df30fbb6b98c983dd1b4fa943e1526f23c8637f1]
#
# patch "src/modes/ofb/ofb_getiv.c"
# from [c982e3488ce838cd4495402e1f96648d8883db44]
# to [9ce11360bca1c3ee68a27b6d80476e50ab1ac657]
#
# patch "src/modes/ofb/ofb_setiv.c"
# from [cd3bbce4ef982638a607d43b7c4fa76321b32183]
# to [49257bf651c61a12fae022b8c04b916f202f715c]
#
# patch "src/modes/ofb/ofb_start.c"
# from [7b18975731a61a99b95ab2228db7a1004c42b170]
# to [6729f0bbfe04bbd0765937cf726de4da58ef91dc]
#
# patch "src/pk/asn1/der/integer/der_decode_integer.c"
# from [f1b2df04c74453d994104e3ed0c796979c3a69af]
# to [75ee83a26e358f83d5c2832295605e9832038e7f]
#
# patch "src/pk/asn1/der/integer/der_encode_integer.c"
# from [f0aab76f826af981b349afe2e95ff26bf0a6db47]
# to [60c202f266990c9679aeccfaaf6eb42d61cfad10]
#
# patch "src/pk/asn1/der/integer/der_length_integer.c"
# from [2baf47016f12132663ce8e24769709b0eab49fbe]
# to [3dac3242be79c3e134776cf9c7a65846fc32efe9]
#
# patch "src/pk/dh/dh.c"
# from [7c6f8255f6978969661a050055067b82ab31e909]
# to [2bc979826ab57121c5a0ed62dc9cf207436b3d59]
#
# patch "src/pk/dh/dh_sys.c"
# from [43d6fd75fc5f21d48a8605cee3e9f54a48625c59]
# to [0e6061291a0e4f8c571e2ee6371e4267341c3e4c]
#
# patch "src/pk/dsa/dsa_export.c"
# from [d11b05e1dc6d7f602077f3d585f394f51a15f48c]
# to [b97ff705c170c99fc987b8f131e61662abeacd6f]
#
# patch "src/pk/dsa/dsa_free.c"
# from [943eb6ca3bc184fe7e0f2f79a10574dad4824bd2]
# to [664f22a829d3ae5e388407a75457a5af3029b2fb]
#
# patch "src/pk/dsa/dsa_import.c"
# from [f6989f91c6926568148e9ff6335762505b5865fa]
# to [3461896a9037efdb61f635c57a21fbe23b5efbf9]
#
# patch "src/pk/dsa/dsa_make_key.c"
# from [d4178a39c75011f7cf705c2b3d8aad9c831372fe]
# to [c6316d13e52ab41823979e637a4e564778eaffed]
#
# patch "src/pk/dsa/dsa_sign_hash.c"
# from [f00d6b45ea5ff99aa7a0e3bf6e566f572b7cf3a5]
# to [a3a3e813b9e004e5c0ca38dff304ddd3fb5c5ea9]
#
# patch "src/pk/dsa/dsa_verify_hash.c"
# from [e0522e3b2502e4983c1984a982e5cc623d0ded49]
# to [42dda609eebadc9503471c2c41e416eb4266bc3a]
#
# patch "src/pk/dsa/dsa_verify_key.c"
# from [4e5fb1a9f1904631252bfbd31f51baa46cfa16a9]
# to [10c2d2ad066a096b31d9d4b88327e63343278c4a]
#
# patch "src/pk/ecc/ecc.c"
# from [afabaf7220a2e8633b8e011d00ae7c4857e17941]
# to [f49c8df95ba46b8dec02e240d5f465fe0c91846f]
#
# patch "src/pk/ecc/ecc_sys.c"
# from [197b93b8b8145b88c854385f211f50f3ab02dd99]
# to [cfb691aef44b3d8aad694f35a5e4b12657845097]
#
# patch "src/pk/packet_store_header.c"
# from [d7684f999173897c0d037f1cc405b51ddddccc72]
# to [6f052b5c5d1248914a836f192a3afd5480219680]
#
# patch "src/pk/packet_valid_header.c"
# from [f46989bf8b667c3a6b17038f56de9ca02421b0eb]
# to [c9c2f9dd6e0a5f4ad3b4cdd40494cc6ab270d138]
#
# patch "src/pk/pkcs1/pkcs_1_i2osp.c"
# from [aa18e58984102e19b745be170fb039cd4bfe6d83]
# to [946bf839fe6c4558ce80b099844df4d80265ac7c]
#
# patch "src/pk/pkcs1/pkcs_1_mgf1.c"
# from [54d57d032fb514368948efbcb4f6d12bdae5a618]
# to [7b0cae632d1b1a023a78f9b7278606985e57b8a9]
#
# patch "src/pk/pkcs1/pkcs_1_oaep_decode.c"
# from [52b90d68028e365f7ba6dc7fb917d65d40bbc342]
# to [ed3f16f08b8576ed2e6569f06982e3aaf38bc164]
#
# patch "src/pk/pkcs1/pkcs_1_oaep_encode.c"
# from [7113c97a95f6f1a89c77e9524f0d8eede0297290]
# to [64b76d3b83a274f828d908f87076a0f805ab2855]
#
# patch "src/pk/pkcs1/pkcs_1_os2ip.c"
# from [27e607937696d414d49db73821e522ef06aff249]
# to [fe259380a76ccccca37ca70a0e024e3fbffa6b95]
#
# patch "src/pk/pkcs1/pkcs_1_pss_decode.c"
# from [ebdc48ff73769a3ac475f697dd9f45f5958cdb7d]
# to [66a0b128f829e54f3aa24ff7b6678dfdd0804c89]
#
# patch "src/pk/pkcs1/pkcs_1_pss_encode.c"
# from [176bd5c4293d7b9e32f4120dfee812e76c8bf03e]
# to [e2cba20e37780fc0e490d2f59df630069c560042]
#
# patch "src/pk/rsa/rsa_decrypt_key.c"
# from [646a4df41a250539066b16f0358dbb0b61258136]
# to [d56135d77a951341213a7f569c2986efe006c205]
#
# patch "src/pk/rsa/rsa_encrypt_key.c"
# from [798cc56ac67a3735ff58005e0df3f6cd356a2106]
# to [7a61f097fdab859a81e5405e2e13a13a5020ffa9]
#
# patch "src/pk/rsa/rsa_export.c"
# from [b9649351531ce522a92472e8f9a16a14c59b9ede]
# to [e13eb090612e6570f2264c403110bd5a3c6b6de5]
#
# patch "src/pk/rsa/rsa_exptmod.c"
# from [dc387e2d5c44eab263e4ae5e39421fe4b68681e3]
# to [aa0fdf5842b2890f26c0eac6c2c5cf4025230f7a]
#
# patch "src/pk/rsa/rsa_free.c"
# from [e2424d9509d56b415994c820c150e23bcaba83f6]
# to [57bf35b38eae8c17b59e760dac8b1bcd90633fb6]
#
# patch "src/pk/rsa/rsa_import.c"
# from [2031dc9145c417a5dd616eaa0c8dc7406a3736f8]
# to [8b35baf83699e0e45136734a2000902d7fb0b09c]
#
# patch "src/pk/rsa/rsa_make_key.c"
# from [1cf56e4a08bdda254a808e561e1c30a02733e6d4]
# to [3e9ffaabcad59f039c280d9c14110aecbad56947]
#
# patch "src/pk/rsa/rsa_sign_hash.c"
# from [9b60bd6f5b606c96ea35cc982823e5e81bab3470]
# to [ce264f97caf9276b92b2f18be3b6e6784217d1ab]
#
# patch "src/pk/rsa/rsa_verify_hash.c"
# from [14fd31ced67e771d6b88ff4f4999a0ebe47d4989]
# to [c48a5a47fe407fae89b90d7a6079397213d206cc]
#
# patch "src/prngs/fortuna.c"
# from [7e83ac6383ae2759d71517a38534ef6c6cd14e5d]
# to [f838282dd7d485c4f0ffa3e2d0c33dd9187c11c2]
#
# patch "src/prngs/rc4.c"
# from [12bfe70351575b7d7c1e22c56c1a1309d09202b5]
# to [ced2dc5bab5331e47ac7f2404e28dd8e57a10700]
#
# patch "src/prngs/rng_get_bytes.c"
# from [2ff93a9b8ae1fa0c2fd161a64a217c874fbfc129]
# to [62a3db1e644dc6ce0c7df5aaef7ff740e7083fe2]
#
# patch "src/prngs/rng_make_prng.c"
# from [0c316073d3e907ad6f07fd39c59db2e689153570]
# to [b2a5921f56d12a5e4088302756535b8c9af6f2f5]
#
# patch "src/prngs/sober128.c"
# from [2cb2260e93316a2df897b4cfd95dfaf35ef0a433]
# to [1e355bfc23e7c561458223dda3c7b77f43744084]
#
# patch "src/prngs/sober128tab.c"
# from [08541e7cb863e9cdf888349bd0f054d7c97f1280]
# to [f29b14ed0c4b70fead2b8a633925772bb5e1e700]
#
# patch "src/prngs/sprng.c"
# from [d61eaa0afe4c641ff79770744713c19c33c6fae9]
# to [87c2c1dc6c2a17e1593f5131d224691187266607]
#
# patch "src/prngs/yarrow.c"
# from [4dc99762d70293de5be569f537e0394cea23791b]
# to [093607543fb36bfe851d499780fc7acef89206a7]
#
# patch "testprof/base64_test.c"
# from [95cb020cf20c30055036667688d09bffec7e9f8a]
# to [a21ba8b7210d2417651f3f3564a3a996a4adb2c3]
#
# patch "testprof/cipher_hash_test.c"
# from [aa8ace5a89c62254fe9563bc6c9249cbedfe0c46]
# to [15a9af5dc06b90801964cf5cfe0f455ac1ecd03b]
#
# patch "testprof/der_tests.c"
# from [860d8e3f40635d263400777698f0a2b44baa6b02]
# to [b5f481758588466833d312515066672e0d4687e4]
#
# patch "testprof/dh_tests.c"
# from [03efe0f0f3fb14072c8bbd5e7fb91bc53db70e28]
# to [60d7c6ec06bf550373e5349e0ffaf1f3f870a75d]
#
# patch "testprof/dsa_test.c"
# from [66e05b75e3b01c06aac4c5a1d2dd8f8b093460ae]
# to [71f8cd03e6e3e09778507fe4503e62fb4d490eaf]
#
# patch "testprof/ecc_test.c"
# from [24ddb16a200e277fa7de961f07a6b2d692eec844]
# to [618734615cb07e6076dd9175863699c15f03aebe]
#
# patch "testprof/mac_test.c"
# from [b6fa28d808d448d6752bfd987e91b1b586c17052]
# to [0c666d90789a5706db8f32f3d7af8a342a8f988a]
#
# patch "testprof/makefile.icc"
# from [f22db73701ad72390d4ae7ce6c54153952f78685]
# to [f05458758a1b5419ebdc00ff616f0239141a6c7f]
#
# patch "testprof/modes_test.c"
# from [e157a8cf94dd19424e4858076aacade07aafd227]
# to [bc64ebd47786eb069d28f75b43b7329671f19a34]
#
# patch "testprof/pkcs_1_test.c"
# from [588bdd0b33ca1aa945e4f9258ea5ce21a7e66ae7]
# to [af5e9e49a064f9d64e7a650f80cd900d1bec9533]
#
# patch "testprof/rsa_test.c"
# from [26c6c27b14ed4b09d553729b9045f929b69a37c1]
# to [360b59353dbb66388e745ba30ae141bda417359b]
#
# patch "testprof/store_test.c"
# from [0b24a24804108f4d1d20db7cae607be15b29ad44]
# to [293da8118a56bc08a77813dd8c0302767b636dfc]
#
# patch "testprof/test.c"
# from [42b7eb2010712a015ec9001d90ca49dd80b58ee6]
# to [d31df3bbea875e73632d75cab3c7c7f8dc805bd1]
#
# patch "testprof/tomcrypt_test.h"
# from [c59d99d3c98d1c4c67f5bd30bb3a38b36c3d4bfc]
# to [a2099caba584563b2eaab9796afefdfbda76578f]
#
# patch "testprof/x86_prof.c"
# from [18ead80a615389c7cac9363b9c9d52006a0d67a1]
# to [ecbf14dad9f800da52723d3485c7f3f99a26977a]
#
============================================================
--- build.sh 6fdd754df5acb227ee2bbcbb62ee469bccabcb52
+++ build.sh 6fdd754df5acb227ee2bbcbb62ee469bccabcb52
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "$1 ($2, $3)..."
+make clean 1>/dev/null 2>/dev/null
+echo -n "building..."
+CFLAGS="$2 $CFLAGS" make -j3 -f $3 test tv_gen 1>gcc_1.txt 2>gcc_2.txt || (echo "build $1 failed see gcc_2.txt for more information" && cat gcc_2.txt && exit 1)
+echo -n "testing..."
+if [ -a test ] && [ -f test ] && [ -x test ]; then
+ ((./test >test_std.txt 2>test_err.txt && ./tv_gen > tv.txt) && echo "$1 test passed." && echo "y" > testok.txt) || (echo "$1 test failed" && cat test_err.txt && exit 1)
+ if find *_tv.txt -type f 1>/dev/null 2>/dev/null ; then
+ for f in *_tv.txt; do if (diff $f notes/$f) then true; else (echo "tv_gen $f failed" && rm -f testok.txt && exit 1); fi; done
+ fi
+fi
+if [ -a testok.txt ] && [ -f testok.txt ]; then
+ exit 0
+fi
+exit 1
+
+# $Source: /cvs/libtom/libtomcrypt/build.sh,v $
+# $Revision: 1.5 $
+# $Date: 2005/06/27 13:04:05 $
============================================================
--- mess.sh ee34aef379627e97871efac71f93ebe600548bd7
+++ mess.sh ee34aef379627e97871efac71f93ebe600548bd7
@@ -0,0 +1,4 @@
+#!/bin/bash
+if cvs log $1 >/dev/null 2>/dev/null; then exit 0; else echo "$1 shouldn't be here" ; exit 1; fi
+
+
============================================================
--- notes/tech0005.txt f4853d5fd1c3b89604d601783e5d07302dd7e187
+++ notes/tech0005.txt f4853d5fd1c3b89604d601783e5d07302dd7e187
@@ -0,0 +1,18 @@
+Tech Note 0005
+Minimizing Code Space
+Tom St Denis
+
+Introduction
+------------
+
+Tweaking...
+
+You can disable whole classes of algorithms on the command line with the LTC_NO_* defines. From there you can manually turn on what you want to enable.
+
+The following build with GCC 3.4.3 on an AMD64 box gets you AES, CTR mode, SHA-256, HMAC, Yarrow, full RSA PKCS #1, PKCS #5, ASN.1 DER and MPI in
+roughly 80KB of code.
+
+CFLAGS="-DSC_RSA_1 -DLTC_NO_CIPHERS -DLTC_NO_HASHES -DLTC_NO_PRNGS -DLTC_NO_MACS -DLTC_NO_MODES -DLTC_NO_PK -DRIJNDAEL -DCTR -DSHA256 \
+-DHMAC -DYARROW -DMRSA -DMPI -Os -fomit-frame-pointer" make IGNORE_SPEED=1
+
+Neato eh?
============================================================
--- notes/tech0006.txt 808b72012bf29653039b60246d3a93e1ef04ff56
+++ notes/tech0006.txt 808b72012bf29653039b60246d3a93e1ef04ff56
@@ -0,0 +1,91 @@
+Tech Note 0006
+PK Standards Compliance
+Tom St Denis
+
+RSA
+----
+
+PKCS #1 compliance.
+
+Key Format: RSAPublicKey and RSAPrivateKey as per PKCS #1 v2.1
+Encryption: OAEP as per PKCS #1
+Signature : PSS as per PKCS #1
+
+DSA
+----
+
+The NIST DSA algorithm
+
+Key Format: HomeBrew [see below]
+Signature : ANSI X9.62 format [see below].
+
+Keys are stored as
+
+DSAPublicKey ::= SEQUENCE {
+ publicFlags BIT STRING(1), -- must be 0
+ g INTEGER , -- base generator, check that g^q mod p == 1
+ -- and that 1 < g < p - 1
+ p INTEGER , -- prime modulus
+ q INTEGER , -- order of sub-group (must be prime)
+ y INTEGER , -- public key, specifically, g^x mod p,
+ -- check that y^q mod p == 1
+ -- and that 1 < y < p - 1
+}
+
+DSAPrivateKey ::= SEQUENCE {
+ publicFlags BIT STRING(1), -- must be 1
+ g INTEGER , -- base generator, check that g^q mod p == 1
+ -- and that 1 < g < p - 1
+ p INTEGER , -- prime modulus
+ q INTEGER , -- order of sub-group (must be prime)
+ y INTEGER , -- public key, specifically, g^x mod p,
+ -- check that y^q mod p == 1
+ -- and that 1 < y < p - 1
+ x INTEGER -- private key
+}
+
+Signatures are stored as
+
+DSASignature ::= SEQUENCE {
+ r, s INTEGER -- signature parameters
+}
+
+ECC
+----
+
+The ANSI X9.62 and X9.63 algorithms [partial]. Supports all NIST GF(p) curves.
+
+Key Format : Homebrew [see below, only GF(p) NIST curves supported]
+Signature : X9.62 compliant
+Encryption : Homebrew [based on X9.63, differs in that the public point is stored as an ECCPublicKey]
+Shared Secret: X9.63 compliant
+
+ECCPublicKey ::= SEQUENCE {
+ flags BIT STRING(1), -- public/private flag (always zero),
+ keySize INTEGER, -- Curve size (in bits) divided by eight
+ -- and rounded down, e.g. 521 => 65
+ pubkey.x INTEGER, -- The X co-ordinate of the public key point
+ pubkey.y INTEGER, -- The Y co-ordinate of the public key point
+}
+
+ECCPrivateKey ::= SEQUENCE {
+ flags BIT STRING(1), -- public/private flag (always one),
+ keySize INTEGER, -- Curve size (in bits) divided by eight
+ -- and rounded down, e.g. 521 => 65
+ pubkey.x INTEGER, -- The X co-ordinate of the public key point
+ pubkey.y INTEGER, -- The Y co-ordinate of the public key point
+ secret.k INTEGER, -- The secret key scalar
+}
+
+The encryption works by finding the X9.63 shared secret and hashing it. The hash is then simply XOR'ed against the message [which must be at most the size
+of the hash digest]. The format of the encrypted text is as follows
+
+ECCEncrypted ::= SEQUENCE {
+ hashOID OBJECT IDENTIFIER, -- The OID of the hash used
+ pubkey OCTET STRING , -- Encapsulation of a random ECCPublicKey
+ skey OCTET STRING -- The encrypted text (which the hash was XOR'ed against)
+}
+
+% $Source: /cvs/libtom/libtomcrypt/notes/tech0006.txt,v $
+% $Revision: 1.2 $
+% $Date: 2005/06/18 02:26:27 $
============================================================
--- run.sh a3de4a3233961d1d7bcb88781e0c224d624523f2
+++ run.sh a3de4a3233961d1d7bcb88781e0c224d624523f2
@@ -0,0 +1,35 @@
+#!/bin/bash
+bash build.sh " $1" "$2 -O2" "$3 IGNORE_SPEED=1"
+if [ -a testok.txt ] && [ -f testok.txt ]; then
+ echo
+else
+ echo
+ echo "Test failed"
+ exit 1
+fi
+
+rm -f testok.txt
+bash build.sh " $1" "$2 -Os" " $3 IGNORE_SPEED=1 LTC_SMALL=1"
+if [ -a testok.txt ] && [ -f testok.txt ]; then
+ echo
+else
+ echo
+ echo "Test failed"
+ exit 1
+fi
+
+rm -f testok.txt
+bash build.sh " $1" " $2" " $3"
+if [ -a testok.txt ] && [ -f testok.txt ]; then
+ echo
+else
+ echo
+ echo "Test failed"
+ exit 1
+fi
+
+exit 0
+
+# $Source: /cvs/libtom/libtomcrypt/run.sh,v $
+# $Revision: 1.13 $
+# $Date: 2005/05/11 18:59:53 $
============================================================
--- src/pk/asn1/der/bit/der_decode_bit_string.c 124502ebdcfa0aea9821d1802ad27049a32b177c
+++ src/pk/asn1/der/bit/der_decode_bit_string.c 124502ebdcfa0aea9821d1802ad27049a32b177c
@@ -0,0 +1,101 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_decode_bit_string.c
+ ASN.1 DER, encode a BIT STRING, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+
+/**
+ Store a BIT STRING
+ @param in The DER encoded BIT STRING
+ @param inlen The size of the DER BIT STRING
+ @param out [out] The array of bits stored (one per char)
+ @param outlen [in/out] The number of bits stored
+ @return CRYPT_OK if successful
+*/
+int der_decode_bit_string(const unsigned char *in, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long dlen, blen, x, y;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* packet must be at least 4 bytes */
+ if (inlen < 4) {
+ return CRYPT_INVALID_ARG;
+ }
+
+ /* check for 0x03 */
+ if ((in[0]&0x1F) != 0x03) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* offset in the data */
+ x = 1;
+
+ /* get the length of the data */
+ if (in[x] & 0x80) {
+ /* long format get number of length bytes */
+ y = in[x++] & 127;
+
+ /* invalid if 0 or > 2 */
+ if (y == 0 || y > 2) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read the data len */
+ dlen = 0;
+ while (y--) {
+ dlen = (dlen << 8) | (unsigned long)in[x++];
+ }
+ } else {
+ /* short format */
+ dlen = in[x++] & 127;
+ }
+
+ /* is the data len too long or too short? */
+ if ((dlen == 0) || (dlen + x > inlen)) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* get padding count */
+ blen = ((dlen - 1) << 3) - (in[x++] & 7);
+
+ /* too many bits? */
+ if (blen > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ /* decode/store the bits */
+ for (y = 0; y < blen; y++) {
+ out[y] = (in[x] & (1 << (7 - (y & 7)))) ? 1 : 0;
+ if ((y & 7) == 7) {
+ ++x;
+ }
+ }
+
+ /* we done */
+ *outlen = blen;
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_decode_bit_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/bit/der_encode_bit_string.c 7519cc10aa368d7d3087ab638721900989ffb2f7
+++ src/pk/asn1/der/bit/der_encode_bit_string.c 7519cc10aa368d7d3087ab638721900989ffb2f7
@@ -0,0 +1,87 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_encode_bit_string.c
+ ASN.1 DER, encode a BIT STRING, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+
+/**
+ Store a BIT STRING
+ @param in The array of bits to store (one per char)
+ @param inlen The number of bits tostore
+ @param out [out] The destination for the DER encoded BIT STRING
+ @param outlen [in/out] The max size and resulting size of the DER BIT STRING
+ @return CRYPT_OK if successful
+*/
+int der_encode_bit_string(const unsigned char *in, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long len, x, y, buf;
+ int err;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* avoid overflows */
+ if ((err = der_length_bit_string(inlen, &len)) != CRYPT_OK) {
+ return err;
+ }
+
+ if (len > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ /* store header (include bit padding count in length) */
+ x = 0;
+ y = (inlen >> 3) + ((inlen&7) ? 1 : 0) + 1;
+
+ out[x++] = 0x03;
+ if (y < 128) {
+ out[x++] = y;
+ } else if (y < 256) {
+ out[x++] = 0x81;
+ out[x++] = y;
+ } else if (y < 65536) {
+ out[x++] = 0x82;
+ out[x++] = (y>>8)&255;
+ out[x++] = y&255;
+ }
+
+ /* store number of zero padding bits */
+ out[x++] = (8 - inlen) & 7;
+
+ /* store the bits in big endian format */
+ for (y = buf = 0; y < inlen; y++) {
+ buf |= (in[y] ? 1 : 0) << (7 - (y & 7));
+ if ((y & 7) == 7) {
+ out[x++] = buf;
+ buf = 0;
+ }
+ }
+ /* store last byte */
+ if (inlen & 7) {
+ out[x++] = buf;
+ }
+ *outlen = x;
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_encode_bit_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/bit/der_length_bit_string.c 9e7e35c66dcb874c1888a4e1e3366bc9c8246db9
+++ src/pk/asn1/der/bit/der_length_bit_string.c 9e7e35c66dcb874c1888a4e1e3366bc9c8246db9
@@ -0,0 +1,54 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_length_bit_string.c
+ ASN.1 DER, get length of BIT STRING, Tom St Denis
+*/
+
+#ifdef LTC_DER
+/**
+ Gets length of DER encoding of BIT STRING
+ @param nbits The number of bits in the string to encode
+ @param outlen [out] The length of the DER encoding for the given string
+ @return CRYPT_OK if successful
+*/
+int der_length_bit_string(unsigned long nbits, unsigned long *outlen)
+{
+ unsigned long nbytes;
+ LTC_ARGCHK(outlen != NULL);
+
+ /* get the number of the bytes */
+ nbytes = (nbits >> 3) + ((nbits & 7) ? 1 : 0) + 1;
+
+ if (nbytes < 128) {
+ /* 03 LL PP DD DD DD ... */
+ *outlen = 2 + nbytes;
+ } else if (nbytes < 256) {
+ /* 03 81 LL PP DD DD DD ... */
+ *outlen = 3 + nbytes;
+ } else if (nbytes < 65536) {
+ /* 03 82 LL LL PP DD DD DD ... */
+ *outlen = 4 + nbytes;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ return CRYPT_OK;
+}
+
+#endif
+
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_length_bit_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/choice/der_decode_choice.c b42f2aa51999ab1a1643d208cd17ec663dfd9ac4
+++ src/pk/asn1/der/choice/der_decode_choice.c b42f2aa51999ab1a1643d208cd17ec663dfd9ac4
@@ -0,0 +1,168 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_decode_choice.c
+ ASN.1 DER, decode a CHOICE, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+/**
+ Decode a CHOICE
+ @param in The DER encoded input
+ @param inlen [in/out] The size of the input and resulting size of read type
+ @param list The list of items to decode
+ @param outlen The number of items in the list
+ @return CRYPT_OK on success
+*/
+int der_decode_choice(const unsigned char *in, unsigned long *inlen,
+ ltc_asn1_list *list, unsigned long outlen)
+{
+ unsigned long size, x, z;
+ void *data;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(inlen != NULL);
+ LTC_ARGCHK(list != NULL);
+
+ /* get blk size */
+ if (*inlen < 2) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* set all of the "used" flags to zero */
+ for (x = 0; x < outlen; x++) {
+ list[x].used = 0;
+ }
+
+ /* now scan until we have a winner */
+ for (x = 0; x < outlen; x++) {
+ size = list[x].size;
+ data = list[x].data;
+
+ switch (list[x].type) {
+ case LTC_ASN1_INTEGER:
+ if (der_decode_integer(in, *inlen, data) == CRYPT_OK) {
+ if (der_length_integer(data, &z) == CRYPT_OK) {
+ list[x].used = 1;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ }
+ break;
+
+ case LTC_ASN1_SHORT_INTEGER:
+ if (der_decode_short_integer(in, *inlen, data) == CRYPT_OK) {
+ if (der_length_short_integer(size, &z) == CRYPT_OK) {
+ list[x].used = 1;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ }
+ break;
+
+ case LTC_ASN1_BIT_STRING:
+ if (der_decode_bit_string(in, *inlen, data, &size) == CRYPT_OK) {
+ if (der_length_bit_string(size, &z) == CRYPT_OK) {
+ list[x].used = 1;
+ list[x].size = size;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ }
+ break;
+
+ case LTC_ASN1_OCTET_STRING:
+ if (der_decode_octet_string(in, *inlen, data, &size) == CRYPT_OK) {
+ if (der_length_octet_string(size, &z) == CRYPT_OK) {
+ list[x].used = 1;
+ list[x].size = size;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ }
+ break;
+
+ case LTC_ASN1_NULL:
+ if (*inlen == 2 && in[x] == 0x05 && in[x+1] == 0x00) {
+ *inlen = 2;
+ return CRYPT_OK;
+ }
+ break;
+
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ if (der_decode_object_identifier(in, *inlen, data, &size) == CRYPT_OK) {
+ if (der_length_object_identifier(data, size, &z) == CRYPT_OK) {
+ list[x].used = 1;
+ list[x].size = size;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ }
+ break;
+
+ case LTC_ASN1_IA5_STRING:
+ if (der_decode_ia5_string(in, *inlen, data, &size) == CRYPT_OK) {
+ if (der_length_ia5_string(data, size, &z) == CRYPT_OK) {
+ list[x].used = 1;
+ list[x].size = size;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ }
+ break;
+
+
+ case LTC_ASN1_PRINTABLE_STRING:
+ if (der_decode_printable_string(in, *inlen, data, &size) == CRYPT_OK) {
+ if (der_length_printable_string(data, size, &z) == CRYPT_OK) {
+ list[x].used = 1;
+ list[x].size = size;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ }
+ break;
+
+ case LTC_ASN1_UTCTIME:
+ z = *inlen;
+ if (der_decode_utctime(in, &z, data) == CRYPT_OK) {
+ list[x].used = 1;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ break;
+
+ case LTC_ASN1_SEQUENCE:
+ if (der_decode_sequence(in, *inlen, data, size) == CRYPT_OK) {
+ if (der_length_sequence(data, size, &z) == CRYPT_OK) {
+ list[x].used = 1;
+ *inlen = z;
+ return CRYPT_OK;
+ }
+ }
+ break;
+
+ default:
+ return CRYPT_INVALID_ARG;
+ }
+ }
+
+ return CRYPT_INVALID_PACKET;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/choice/der_decode_choice.c,v $ */
+/* $Revision: 1.4 $ */
+/* $Date: 2005/06/19 11:25:01 $ */
============================================================
--- src/pk/asn1/der/ia5/der_decode_ia5_string.c 0368564f032b9fbaf4a430673fe306cc0677a725
+++ src/pk/asn1/der/ia5/der_decode_ia5_string.c 0368564f032b9fbaf4a430673fe306cc0677a725
@@ -0,0 +1,95 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_decode_ia5_string.c
+ ASN.1 DER, encode a IA5 STRING, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+
+/**
+ Store a IA5 STRING
+ @param in The DER encoded IA5 STRING
+ @param inlen The size of the DER IA5 STRING
+ @param out [out] The array of octets stored (one per char)
+ @param outlen [in/out] The number of octets stored
+ @return CRYPT_OK if successful
+*/
+int der_decode_ia5_string(const unsigned char *in, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long x, y, len;
+ int t;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* must have header at least */
+ if (inlen < 2) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* check for 0x16 */
+ if ((in[0] & 0x1F) != 0x16) {
+ return CRYPT_INVALID_PACKET;
+ }
+ x = 1;
+
+ /* decode the length */
+ if (in[x] & 0x80) {
+ /* valid # of bytes in length are 1,2,3 */
+ y = in[x] & 0x7F;
+ if ((y == 0) || (y > 3) || ((x + y) > inlen)) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read the length in */
+ len = 0;
+ ++x;
+ while (y--) {
+ len = (len << 8) | in[x++];
+ }
+ } else {
+ len = in[x++] & 0x7F;
+ }
+
+ /* is it too long? */
+ if (len > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ if (len + x > inlen) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read the data */
+ for (y = 0; y < len; y++) {
+ t = der_ia5_value_decode(in[x++]);
+ if (t == -1) {
+ return CRYPT_INVALID_ARG;
+ }
+ out[y] = t;
+ }
+
+ *outlen = y;
+
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_decode_ia5_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/ia5/der_encode_ia5_string.c 57c849eb06ad7816e0080a9935794f7e208a022b
+++ src/pk/asn1/der/ia5/der_encode_ia5_string.c 57c849eb06ad7816e0080a9935794f7e208a022b
@@ -0,0 +1,84 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_encode_ia5_string.c
+ ASN.1 DER, encode a IA5 STRING, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+/**
+ Store an IA5 STRING
+ @param in The array of IA5 to store (one per char)
+ @param inlen The number of IA5 to store
+ @param out [out] The destination for the DER encoded IA5 STRING
+ @param outlen [in/out] The max size and resulting size of the DER IA5 STRING
+ @return CRYPT_OK if successful
+*/
+int der_encode_ia5_string(const unsigned char *in, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long x, y, len;
+ int err;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* get the size */
+ if ((err = der_length_ia5_string(in, inlen, &len)) != CRYPT_OK) {
+ return err;
+ }
+
+ /* too big? */
+ if (len > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ /* encode the header+len */
+ x = 0;
+ out[x++] = 0x16;
+ if (inlen < 128) {
+ out[x++] = inlen;
+ } else if (inlen < 256) {
+ out[x++] = 0x81;
+ out[x++] = inlen;
+ } else if (inlen < 65536UL) {
+ out[x++] = 0x82;
+ out[x++] = (inlen>>8)&255;
+ out[x++] = inlen&255;
+ } else if (inlen < 16777216UL) {
+ out[x++] = 0x83;
+ out[x++] = (inlen>>16)&255;
+ out[x++] = (inlen>>8)&255;
+ out[x++] = inlen&255;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ /* store octets */
+ for (y = 0; y < inlen; y++) {
+ out[x++] = der_ia5_char_encode(in[y]);
+ }
+
+ /* retun length */
+ *outlen = x;
+
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_encode_ia5_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/ia5/der_length_ia5_string.c 0d538c963b79b6d3ecaa7e7fbb50eecf7f9edf7b
+++ src/pk/asn1/der/ia5/der_length_ia5_string.c 0d538c963b79b6d3ecaa7e7fbb50eecf7f9edf7b
@@ -0,0 +1,194 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_length_ia5_string.c
+ ASN.1 DER, get length of IA5 STRING, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+static const struct {
+ int code, value;
+} ia5_table[] = {
+{ '\0', 0 },
+{ '\a', 7 },
+{ '\b', 8 },
+{ '\t', 9 },
+{ '\n', 10 },
+{ '\f', 12 },
+{ '\r', 13 },
+{ ' ', 32 },
+{ '!', 33 },
+{ '"', 34 },
+{ '#', 35 },
+{ '$', 36 },
+{ '%', 37 },
+{ '&', 38 },
+{ '\'', 39 },
+{ '(', 40 },
+{ ')', 41 },
+{ '*', 42 },
+{ '+', 43 },
+{ ',', 44 },
+{ '-', 45 },
+{ '.', 46 },
+{ '/', 47 },
+{ '0', 48 },
+{ '1', 49 },
+{ '2', 50 },
+{ '3', 51 },
+{ '4', 52 },
+{ '5', 53 },
+{ '6', 54 },
+{ '7', 55 },
+{ '8', 56 },
+{ '9', 57 },
+{ ':', 58 },
+{ ';', 59 },
+{ '<', 60 },
+{ '=', 61 },
+{ '>', 62 },
+{ '?', 63 },
+{ '@', 64 },
+{ 'A', 65 },
+{ 'B', 66 },
+{ 'C', 67 },
+{ 'D', 68 },
+{ 'E', 69 },
+{ 'F', 70 },
+{ 'G', 71 },
+{ 'H', 72 },
+{ 'I', 73 },
+{ 'J', 74 },
+{ 'K', 75 },
+{ 'L', 76 },
+{ 'M', 77 },
+{ 'N', 78 },
+{ 'O', 79 },
+{ 'P', 80 },
+{ 'Q', 81 },
+{ 'R', 82 },
+{ 'S', 83 },
+{ 'T', 84 },
+{ 'U', 85 },
+{ 'V', 86 },
+{ 'W', 87 },
+{ 'X', 88 },
+{ 'Y', 89 },
+{ 'Z', 90 },
+{ '[', 91 },
+{ '\\', 92 },
+{ ']', 93 },
+{ '^', 94 },
+{ '_', 95 },
+{ '`', 96 },
+{ 'a', 97 },
+{ 'b', 98 },
+{ 'c', 99 },
+{ 'd', 100 },
+{ 'e', 101 },
+{ 'f', 102 },
+{ 'g', 103 },
+{ 'h', 104 },
+{ 'i', 105 },
+{ 'j', 106 },
+{ 'k', 107 },
+{ 'l', 108 },
+{ 'm', 109 },
+{ 'n', 110 },
+{ 'o', 111 },
+{ 'p', 112 },
+{ 'q', 113 },
+{ 'r', 114 },
+{ 's', 115 },
+{ 't', 116 },
+{ 'u', 117 },
+{ 'v', 118 },
+{ 'w', 119 },
+{ 'x', 120 },
+{ 'y', 121 },
+{ 'z', 122 },
+{ '{', 123 },
+{ '|', 124 },
+{ '}', 125 },
+{ '~', 126 }
+};
+
+int der_ia5_char_encode(int c)
+{
+ int x;
+ for (x = 0; x < (int)(sizeof(ia5_table)/sizeof(ia5_table[0])); x++) {
+ if (ia5_table[x].code == c) {
+ return ia5_table[x].value;
+ }
+ }
+ return -1;
+}
+
+int der_ia5_value_decode(int v)
+{
+ int x;
+ for (x = 0; x < (int)(sizeof(ia5_table)/sizeof(ia5_table[0])); x++) {
+ if (ia5_table[x].value == v) {
+ return ia5_table[x].code;
+ }
+ }
+ return -1;
+}
+
+/**
+ Gets length of DER encoding of IA5 STRING
+ @param octets The values you want to encode
+ @param noctets The number of octets in the string to encode
+ @param outlen [out] The length of the DER encoding for the given string
+ @return CRYPT_OK if successful
+*/
+int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen)
+{
+ unsigned long x;
+
+ LTC_ARGCHK(outlen != NULL);
+ LTC_ARGCHK(octets != NULL);
+
+ /* scan string for validity */
+ for (x = 0; x < noctets; x++) {
+ if (der_ia5_char_encode(octets[x]) == -1) {
+ return CRYPT_INVALID_ARG;
+ }
+ }
+
+ if (noctets < 128) {
+ /* 16 LL DD DD DD ... */
+ *outlen = 2 + noctets;
+ } else if (noctets < 256) {
+ /* 16 81 LL DD DD DD ... */
+ *outlen = 3 + noctets;
+ } else if (noctets < 65536UL) {
+ /* 16 82 LL LL DD DD DD ... */
+ *outlen = 4 + noctets;
+ } else if (noctets < 16777216UL) {
+ /* 16 83 LL LL LL DD DD DD ... */
+ *outlen = 5 + noctets;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ return CRYPT_OK;
+}
+
+#endif
+
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_length_ia5_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/object_identifier/der_decode_object_identifier.c cbb123740cbdc724887e647afc83f0b5a9cab421
+++ src/pk/asn1/der/object_identifier/der_decode_object_identifier.c cbb123740cbdc724887e647afc83f0b5a9cab421
@@ -0,0 +1,99 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_decode_object_identifier.c
+ ASN.1 DER, Decode Object Identifier, Tom St Denis
+*/
+
+#ifdef LTC_DER
+/**
+ Decode OID data and store the array of integers in words
+ @param in The OID DER encoded data
+ @param inlen The length of the OID data
+ @param words [out] The destination of the OID words
+ @param outlen [in/out] The number of OID words
+ @return CRYPT_OK if successful
+*/
+int der_decode_object_identifier(const unsigned char *in, unsigned long inlen,
+ unsigned long *words, unsigned long *outlen)
+{
+ unsigned long x, y, t, len;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(words != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* header is at least 3 bytes */
+ if (inlen < 3) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* must be room for at least two words */
+ if (*outlen < 2) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ /* decode the packet header */
+ x = 0;
+ if ((in[x++] & 0x1F) != 0x06) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* get the length */
+ if (in[x] < 128) {
+ len = in[x++];
+ } else {
+ if (in[x] < 0x81 || in[x] > 0x82) {
+ return CRYPT_INVALID_PACKET;
+ }
+ y = in[x++] & 0x7F;
+ len = 0;
+ while (y--) {
+ len = (len << 8) | (unsigned long)in[x++];
+ }
+ }
+
+ if (len < 1 || (len + x) > inlen) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* decode word1 and word2 */
+ --len;
+ t = in[x++];
+ words[0] = t/40;
+ words[1] = t%40;
+
+ /* decode rest */
+ y = 2;
+ t = 0;
+ while (len--) {
+ t = (t << 7) | (in[x] & 0x7F);
+ if (!(in[x++] & 0x80)) {
+ /* store t */
+ if (y >= *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+ words[y++] = t;
+ t = 0;
+ }
+ }
+
+ *outlen = y;
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_decode_object_identifier.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/object_identifier/der_encode_object_identifier.c f40286bd83c9ea6154a0cf683f499c0895f00e06
+++ src/pk/asn1/der/object_identifier/der_encode_object_identifier.c f40286bd83c9ea6154a0cf683f499c0895f00e06
@@ -0,0 +1,103 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_encode_object_identifier.c
+ ASN.1 DER, Encode Object Identifier, Tom St Denis
+*/
+
+#ifdef LTC_DER
+/**
+ Encode an OID
+ @param words The words to encode (upto 32-bits each)
+ @param nwords The number of words in the OID
+ @param out [out] Destination of OID data
+ @param outlen [in/out] The max and resulting size of the OID
+ @return CRYPT_OK if successful
+*/
+int der_encode_object_identifier(unsigned long *words, unsigned long nwords,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long i, x, y, z, t, mask;
+ int err;
+
+ LTC_ARGCHK(words != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* check length */
+ if ((err = der_length_object_identifier(words, nwords, &x)) != CRYPT_OK) {
+ return err;
+ }
+ if (x > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ /* compute length to store OID data */
+ z = 1;
+ for (y = 2; y < nwords; y++) {
+ t = der_object_identifier_bits(words[y]);
+ z += t/7 + ((t%7) ? 1 : 0);
+ }
+
+ /* store header + length */
+ x = 0;
+ out[x++] = 0x06;
+ if (z < 128) {
+ out[x++] = z;
+ } else if (z < 256) {
+ out[x++] = 0x81;
+ out[x++] = z;
+ } else if (z < 65536UL) {
+ out[x++] = 0x82;
+ out[x++] = (z>>8)&255;
+ out[x++] = z&255;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ /* store first byte */
+ out[x++] = words[0] * 40 + words[1];
+
+ for (i = 2; i < nwords; i++) {
+ /* store 7 bit words in little endian */
+ t = words[i] & 0xFFFFFFFF;
+ if (t) {
+ y = x;
+ mask = 0;
+ while (t) {
+ out[x++] = (t & 0x7F) | mask;
+ t >>= 7;
+ mask |= 0x80; /* upper bit is set on all but the last byte */
+ }
+ /* now swap bytes y...x-1 */
+ z = x - 1;
+ while (y < z) {
+ t = out[y]; out[y] = out[z]; out[z] = t;
+ ++y;
+ --z;
+ }
+ } else {
+ /* zero word */
+ out[x++] = 0x00;
+ }
+ }
+
+ *outlen = x;
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_encode_object_identifier.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/object_identifier/der_length_object_identifier.c 46fae94eb84b5af85543acb5092f4388171be261
+++ src/pk/asn1/der/object_identifier/der_length_object_identifier.c 46fae94eb84b5af85543acb5092f4388171be261
@@ -0,0 +1,84 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_length_object_identifier.c
+ ASN.1 DER, get length of Object Identifier, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+unsigned long der_object_identifier_bits(unsigned long x)
+{
+ unsigned long c;
+ x &= 0xFFFFFFFF;
+ c = 0;
+ while (x) {
+ ++c;
+ x >>= 1;
+ }
+ return c;
+}
+
+
+/**
+ Gets length of DER encoding of Object Identifier
+ @param nwords The number of OID words
+ @param words The actual OID words to get the size of
+ @param outlen [out] The length of the DER encoding for the given string
+ @return CRYPT_OK if successful
+*/
+int der_length_object_identifier(unsigned long *words, unsigned long nwords, unsigned long *outlen)
+{
+ unsigned long y, z, t;
+
+ LTC_ARGCHK(words != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+
+ /* must be >= 2 words */
+ if (nwords < 2) {
+ return CRYPT_INVALID_ARG;
+ }
+
+ /* word1 = 0,1,2 and word2 0..39 */
+ if (words[0] > 2 || words[1] > 39) {
+ return CRYPT_INVALID_ARG;
+ }
+
+ /* leading byte of first two words */
+ z = 1;
+ for (y = 2; y < nwords; y++) {
+ t = der_object_identifier_bits(words[y]);
+ z += t/7 + ((t%7) ? 1 : 0);
+ }
+
+ /* now depending on the length our length encoding changes */
+ if (z < 128) {
+ z += 2;
+ } else if (z < 256) {
+ z += 3;
+ } else if (z < 65536UL) {
+ z += 4;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ *outlen = z;
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_length_object_identifier.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/octet/der_decode_octet_string.c 818bd4829a592568427715a489744fe851004b17
+++ src/pk/asn1/der/octet/der_decode_octet_string.c 818bd4829a592568427715a489744fe851004b17
@@ -0,0 +1,90 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_decode_octet_string.c
+ ASN.1 DER, encode a OCTET STRING, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+
+/**
+ Store a OCTET STRING
+ @param in The DER encoded OCTET STRING
+ @param inlen The size of the DER OCTET STRING
+ @param out [out] The array of octets stored (one per char)
+ @param outlen [in/out] The number of octets stored
+ @return CRYPT_OK if successful
+*/
+int der_decode_octet_string(const unsigned char *in, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long x, y, len;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* must have header at least */
+ if (inlen < 2) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* check for 0x04 */
+ if ((in[0] & 0x1F) != 0x04) {
+ return CRYPT_INVALID_PACKET;
+ }
+ x = 1;
+
+ /* decode the length */
+ if (in[x] & 0x80) {
+ /* valid # of bytes in length are 1,2,3 */
+ y = in[x] & 0x7F;
+ if ((y == 0) || (y > 3) || ((x + y) > inlen)) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read the length in */
+ len = 0;
+ ++x;
+ while (y--) {
+ len = (len << 8) | in[x++];
+ }
+ } else {
+ len = in[x++] & 0x7F;
+ }
+
+ /* is it too long? */
+ if (len > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ if (len + x > inlen) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read the data */
+ for (y = 0; y < len; y++) {
+ out[y] = in[x++];
+ }
+
+ *outlen = y;
+
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_decode_octet_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/octet/der_encode_octet_string.c dc6651e9ec3c1ddb52ff6211d1c3caa9d7d3b796
+++ src/pk/asn1/der/octet/der_encode_octet_string.c dc6651e9ec3c1ddb52ff6211d1c3caa9d7d3b796
@@ -0,0 +1,85 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_encode_octet_string.c
+ ASN.1 DER, encode a OCTET STRING, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+
+/**
+ Store an OCTET STRING
+ @param in The array of OCTETS to store (one per char)
+ @param inlen The number of OCTETS to store
+ @param out [out] The destination for the DER encoded OCTET STRING
+ @param outlen [in/out] The max size and resulting size of the DER OCTET STRING
+ @return CRYPT_OK if successful
+*/
+int der_encode_octet_string(const unsigned char *in, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long x, y, len;
+ int err;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* get the size */
+ if ((err = der_length_octet_string(inlen, &len)) != CRYPT_OK) {
+ return err;
+ }
+
+ /* too big? */
+ if (len > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ /* encode the header+len */
+ x = 0;
+ out[x++] = 0x04;
+ if (inlen < 128) {
+ out[x++] = inlen;
+ } else if (inlen < 256) {
+ out[x++] = 0x81;
+ out[x++] = inlen;
+ } else if (inlen < 65536UL) {
+ out[x++] = 0x82;
+ out[x++] = (inlen>>8)&255;
+ out[x++] = inlen&255;
+ } else if (inlen < 16777216UL) {
+ out[x++] = 0x83;
+ out[x++] = (inlen>>16)&255;
+ out[x++] = (inlen>>8)&255;
+ out[x++] = inlen&255;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ /* store octets */
+ for (y = 0; y < inlen; y++) {
+ out[x++] = in[y];
+ }
+
+ /* retun length */
+ *outlen = x;
+
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_encode_octet_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/octet/der_length_octet_string.c e08f461aba3ce9e9d438f5bba2dd3d5435a1d912
+++ src/pk/asn1/der/octet/der_length_octet_string.c e08f461aba3ce9e9d438f5bba2dd3d5435a1d912
@@ -0,0 +1,53 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_length_octet_string.c
+ ASN.1 DER, get length of OCTET STRING, Tom St Denis
+*/
+
+#ifdef LTC_DER
+/**
+ Gets length of DER encoding of OCTET STRING
+ @param noctets The number of octets in the string to encode
+ @param outlen [out] The length of the DER encoding for the given string
+ @return CRYPT_OK if successful
+*/
+int der_length_octet_string(unsigned long noctets, unsigned long *outlen)
+{
+ LTC_ARGCHK(outlen != NULL);
+
+ if (noctets < 128) {
+ /* 04 LL DD DD DD ... */
+ *outlen = 2 + noctets;
+ } else if (noctets < 256) {
+ /* 04 81 LL DD DD DD ... */
+ *outlen = 3 + noctets;
+ } else if (noctets < 65536UL) {
+ /* 04 82 LL LL DD DD DD ... */
+ *outlen = 4 + noctets;
+ } else if (noctets < 16777216UL) {
+ /* 04 83 LL LL LL DD DD DD ... */
+ *outlen = 5 + noctets;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ return CRYPT_OK;
+}
+
+#endif
+
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_length_octet_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/16 15:08:11 $ */
============================================================
--- src/pk/asn1/der/printable_string/der_decode_printable_string.c 24a774be26f0cf141b9f08058ed2006708354122
+++ src/pk/asn1/der/printable_string/der_decode_printable_string.c 24a774be26f0cf141b9f08058ed2006708354122
@@ -0,0 +1,95 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_decode_printable_string.c
+ ASN.1 DER, encode a printable STRING, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+
+/**
+ Store a printable STRING
+ @param in The DER encoded printable STRING
+ @param inlen The size of the DER printable STRING
+ @param out [out] The array of octets stored (one per char)
+ @param outlen [in/out] The number of octets stored
+ @return CRYPT_OK if successful
+*/
+int der_decode_printable_string(const unsigned char *in, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long x, y, len;
+ int t;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* must have header at least */
+ if (inlen < 2) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* check for 0x13 */
+ if ((in[0] & 0x1F) != 0x13) {
+ return CRYPT_INVALID_PACKET;
+ }
+ x = 1;
+
+ /* decode the length */
+ if (in[x] & 0x80) {
+ /* valid # of bytes in length are 1,2,3 */
+ y = in[x] & 0x7F;
+ if ((y == 0) || (y > 3) || ((x + y) > inlen)) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read the length in */
+ len = 0;
+ ++x;
+ while (y--) {
+ len = (len << 8) | in[x++];
+ }
+ } else {
+ len = in[x++] & 0x7F;
+ }
+
+ /* is it too long? */
+ if (len > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ if (len + x > inlen) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read the data */
+ for (y = 0; y < len; y++) {
+ t = der_printable_value_decode(in[x++]);
+ if (t == -1) {
+ return CRYPT_INVALID_ARG;
+ }
+ out[y] = t;
+ }
+
+ *outlen = y;
+
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_decode_printable_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/21 02:29:54 $ */
============================================================
--- src/pk/asn1/der/printable_string/der_encode_printable_string.c 94ad3500660c20651849ea72d0cdcc81edd26ee4
+++ src/pk/asn1/der/printable_string/der_encode_printable_string.c 94ad3500660c20651849ea72d0cdcc81edd26ee4
@@ -0,0 +1,84 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_encode_printable_string.c
+ ASN.1 DER, encode a printable STRING, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+/**
+ Store an printable STRING
+ @param in The array of printable to store (one per char)
+ @param inlen The number of printable to store
+ @param out [out] The destination for the DER encoded printable STRING
+ @param outlen [in/out] The max size and resulting size of the DER printable STRING
+ @return CRYPT_OK if successful
+*/
+int der_encode_printable_string(const unsigned char *in, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ unsigned long x, y, len;
+ int err;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* get the size */
+ if ((err = der_length_printable_string(in, inlen, &len)) != CRYPT_OK) {
+ return err;
+ }
+
+ /* too big? */
+ if (len > *outlen) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ /* encode the header+len */
+ x = 0;
+ out[x++] = 0x13;
+ if (inlen < 128) {
+ out[x++] = inlen;
+ } else if (inlen < 256) {
+ out[x++] = 0x81;
+ out[x++] = inlen;
+ } else if (inlen < 65536UL) {
+ out[x++] = 0x82;
+ out[x++] = (inlen>>8)&255;
+ out[x++] = inlen&255;
+ } else if (inlen < 16777216UL) {
+ out[x++] = 0x83;
+ out[x++] = (inlen>>16)&255;
+ out[x++] = (inlen>>8)&255;
+ out[x++] = inlen&255;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ /* store octets */
+ for (y = 0; y < inlen; y++) {
+ out[x++] = der_printable_char_encode(in[y]);
+ }
+
+ /* retun length */
+ *outlen = x;
+
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_encode_printable_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/21 02:29:54 $ */
============================================================
--- src/pk/asn1/der/printable_string/der_length_printable_string.c dfe9a2d25d55a1911b64f3367444f980438cb278
+++ src/pk/asn1/der/printable_string/der_length_printable_string.c dfe9a2d25d55a1911b64f3367444f980438cb278
@@ -0,0 +1,166 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_length_printable_string.c
+ ASN.1 DER, get length of Printable STRING, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+static const struct {
+ int code, value;
+} printable_table[] = {
+{ ' ', 32 },
+{ '\'', 39 },
+{ '(', 40 },
+{ ')', 41 },
+{ '+', 43 },
+{ ',', 44 },
+{ '-', 45 },
+{ '.', 46 },
+{ '/', 47 },
+{ '0', 48 },
+{ '1', 49 },
+{ '2', 50 },
+{ '3', 51 },
+{ '4', 52 },
+{ '5', 53 },
+{ '6', 54 },
+{ '7', 55 },
+{ '8', 56 },
+{ '9', 57 },
+{ ':', 58 },
+{ '=', 61 },
+{ '?', 63 },
+{ 'A', 65 },
+{ 'B', 66 },
+{ 'C', 67 },
+{ 'D', 68 },
+{ 'E', 69 },
+{ 'F', 70 },
+{ 'G', 71 },
+{ 'H', 72 },
+{ 'I', 73 },
+{ 'J', 74 },
+{ 'K', 75 },
+{ 'L', 76 },
+{ 'M', 77 },
+{ 'N', 78 },
+{ 'O', 79 },
+{ 'P', 80 },
+{ 'Q', 81 },
+{ 'R', 82 },
+{ 'S', 83 },
+{ 'T', 84 },
+{ 'U', 85 },
+{ 'V', 86 },
+{ 'W', 87 },
+{ 'X', 88 },
+{ 'Y', 89 },
+{ 'Z', 90 },
+{ 'a', 97 },
+{ 'b', 98 },
+{ 'c', 99 },
+{ 'd', 100 },
+{ 'e', 101 },
+{ 'f', 102 },
+{ 'g', 103 },
+{ 'h', 104 },
+{ 'i', 105 },
+{ 'j', 106 },
+{ 'k', 107 },
+{ 'l', 108 },
+{ 'm', 109 },
+{ 'n', 110 },
+{ 'o', 111 },
+{ 'p', 112 },
+{ 'q', 113 },
+{ 'r', 114 },
+{ 's', 115 },
+{ 't', 116 },
+{ 'u', 117 },
+{ 'v', 118 },
+{ 'w', 119 },
+{ 'x', 120 },
+{ 'y', 121 },
+{ 'z', 122 },
+};
+
+int der_printable_char_encode(int c)
+{
+ int x;
+ for (x = 0; x < (int)(sizeof(printable_table)/sizeof(printable_table[0])); x++) {
+ if (printable_table[x].code == c) {
+ return printable_table[x].value;
+ }
+ }
+ return -1;
+}
+
+int der_printable_value_decode(int v)
+{
+ int x;
+ for (x = 0; x < (int)(sizeof(printable_table)/sizeof(printable_table[0])); x++) {
+ if (printable_table[x].value == v) {
+ return printable_table[x].code;
+ }
+ }
+ return -1;
+}
+
+/**
+ Gets length of DER encoding of Printable STRING
+ @param octets The values you want to encode
+ @param noctets The number of octets in the string to encode
+ @param outlen [out] The length of the DER encoding for the given string
+ @return CRYPT_OK if successful
+*/
+int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen)
+{
+ unsigned long x;
+
+ LTC_ARGCHK(outlen != NULL);
+ LTC_ARGCHK(octets != NULL);
+
+ /* scan string for validity */
+ for (x = 0; x < noctets; x++) {
+ if (der_printable_char_encode(octets[x]) == -1) {
+ return CRYPT_INVALID_ARG;
+ }
+ }
+
+ if (noctets < 128) {
+ /* 16 LL DD DD DD ... */
+ *outlen = 2 + noctets;
+ } else if (noctets < 256) {
+ /* 16 81 LL DD DD DD ... */
+ *outlen = 3 + noctets;
+ } else if (noctets < 65536UL) {
+ /* 16 82 LL LL DD DD DD ... */
+ *outlen = 4 + noctets;
+ } else if (noctets < 16777216UL) {
+ /* 16 83 LL LL LL DD DD DD ... */
+ *outlen = 5 + noctets;
+ } else {
+ return CRYPT_INVALID_ARG;
+ }
+
+ return CRYPT_OK;
+}
+
+#endif
+
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_length_printable_string.c,v $ */
+/* $Revision: 1.1 $ */
+/* $Date: 2005/05/21 02:29:54 $ */
============================================================
--- src/pk/asn1/der/sequence/der_decode_sequence.c 86f50d2479bdff803c068e121885175c032b66cc
+++ src/pk/asn1/der/sequence/der_decode_sequence.c 86f50d2479bdff803c068e121885175c032b66cc
@@ -0,0 +1,234 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+#include <stdarg.h>
+
+
+/**
+ @file der_decode_sequence.c
+ ASN.1 DER, decode a SEQUENCE, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+/**
+ Decode a SEQUENCE
+ @param in The DER encoded input
+ @param inlen The size of the input
+ @param list The list of items to decode
+ @param outlen The number of items in the list
+ @return CRYPT_OK on success
+*/
+int der_decode_sequence(const unsigned char *in, unsigned long inlen,
+ ltc_asn1_list *list, unsigned long outlen)
+{
+ int err, type;
+ unsigned long size, x, y, z, i, blksize;
+ void *data;
+
+ LTC_ARGCHK(in != NULL);
+ LTC_ARGCHK(list != NULL);
+
+ /* get blk size */
+ if (inlen < 2) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* sequence type? */
+ x = 0;
+ if (in[x++] != 0x30) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ if (in[x] < 128) {
+ blksize = in[x++];
+ } else if (in[x] & 0x80) {
+ if (in[x] < 0x81 || in[x] > 0x83) {
+ return CRYPT_INVALID_PACKET;
+ }
+ y = in[x++] & 0x7F;
+
+ /* would reading the len bytes overrun? */
+ if (x + y > inlen) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read len */
+ blksize = 0;
+ while (y--) {
+ blksize = (blksize << 8) | (unsigned long)in[x++];
+ }
+ }
+
+ /* would this blksize overflow? */
+ if (x + blksize > inlen) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* ok read data */
+ inlen = blksize;
+ for (i = 0; i < outlen; i++) {
+ type = list[i].type;
+ size = list[i].size;
+ data = list[i].data;
+
+ if (type == LTC_ASN1_EOL) {
+ break;
+ }
+
+ switch (type) {
+ case LTC_ASN1_INTEGER:
+ z = inlen;
+ if ((err = der_decode_integer(in + x, z, data)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ if ((err = der_length_integer(data, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+
+ case LTC_ASN1_SHORT_INTEGER:
+ z = inlen;
+ if ((err = der_decode_short_integer(in + x, z, data)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ if ((err = der_length_short_integer(size, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+ case LTC_ASN1_BIT_STRING:
+ z = inlen;
+ if ((err = der_decode_bit_string(in + x, z, data, &size)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ list[i].size = size;
+ if ((err = der_length_bit_string(size, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+ case LTC_ASN1_OCTET_STRING:
+ z = inlen;
+ if ((err = der_decode_octet_string(in + x, z, data, &size)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ list[i].size = size;
+ if ((err = der_length_octet_string(size, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+ case LTC_ASN1_NULL:
+ if (inlen < 2 || in[x] != 0x05 || in[x+1] != 0x00) {
+ err = CRYPT_INVALID_PACKET;
+ goto LBL_ERR;
+ }
+ x += 2;
+ inlen -= 2;
+ break;
+
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ z = inlen;
+ if ((err = der_decode_object_identifier(in + x, z, data, &size)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ list[i].size = size;
+ if ((err = der_length_object_identifier(data, size, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+ case LTC_ASN1_IA5_STRING:
+ z = inlen;
+ if ((err = der_decode_ia5_string(in + x, z, data, &size)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ list[i].size = size;
+ if ((err = der_length_ia5_string(data, size, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+
+ case LTC_ASN1_PRINTABLE_STRING:
+ z = inlen;
+ if ((err = der_decode_printable_string(in + x, z, data, &size)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ list[i].size = size;
+ if ((err = der_length_printable_string(data, size, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+ case LTC_ASN1_UTCTIME:
+ z = inlen;
+ if ((err = der_decode_utctime(in + x, &z, data)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+ case LTC_ASN1_SEQUENCE:
+ z = inlen;
+ if ((err = der_decode_sequence(in + x, z, data, size)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ if ((err = der_length_sequence(data, size, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+
+ case LTC_ASN1_CHOICE:
+ z = inlen;
+ if ((err = der_decode_choice(in + x, &z, data, size)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ inlen -= z;
+ break;
+
+ default:
+ err = CRYPT_INVALID_ARG;
+ goto LBL_ERR;
+ }
+ }
+ err = CRYPT_OK;
+
+LBL_ERR:
+ return err;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence.c,v $ */
+/* $Revision: 1.8 $ */
+/* $Date: 2005/06/18 19:20:23 $ */
============================================================
--- src/pk/asn1/der/sequence/der_decode_sequence_multi.c ab0211f4ea4eed25dd552edefe4028bea38c8c0a
+++ src/pk/asn1/der/sequence/der_decode_sequence_multi.c ab0211f4ea4eed25dd552edefe4028bea38c8c0a
@@ -0,0 +1,124 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+#include <stdarg.h>
+
+
+/**
+ @file der_decode_sequence_multi.c
+ ASN.1 DER, decode a SEQUENCE, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...)
+{
+ int err, type;
+ unsigned long size, x;
+ void *data;
+ va_list args;
+ ltc_asn1_list *list;
+
+ LTC_ARGCHK(in != NULL);
+
+ /* get size of output that will be required */
+ va_start(args, inlen);
+ x = 0;
+ for (;;) {
+ type = va_arg(args, int);
+ size = va_arg(args, unsigned long);
+ data = va_arg(args, void*);
+
+ if (type == LTC_ASN1_EOL) {
+ break;
+ }
+
+ switch (type) {
+ case LTC_ASN1_INTEGER:
+ case LTC_ASN1_SHORT_INTEGER:
+ case LTC_ASN1_BIT_STRING:
+ case LTC_ASN1_OCTET_STRING:
+ case LTC_ASN1_NULL:
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ case LTC_ASN1_IA5_STRING:
+ case LTC_ASN1_PRINTABLE_STRING:
+ case LTC_ASN1_UTCTIME:
+ case LTC_ASN1_SEQUENCE:
+ case LTC_ASN1_CHOICE:
+ ++x;
+ break;
+
+ default:
+ va_end(args);
+ return CRYPT_INVALID_ARG;
+ }
+ }
+ va_end(args);
+
+ /* allocate structure for x elements */
+ if (x == 0) {
+ return CRYPT_NOP;
+ }
+
+ list = XCALLOC(sizeof(*list), x);
+ if (list == NULL) {
+ return CRYPT_MEM;
+ }
+
+ /* fill in the structure */
+ va_start(args, inlen);
+ x = 0;
+ for (;;) {
+ type = va_arg(args, int);
+ size = va_arg(args, unsigned long);
+ data = va_arg(args, void*);
+
+ if (type == LTC_ASN1_EOL) {
+ break;
+ }
+
+ switch (type) {
+ case LTC_ASN1_INTEGER:
+ case LTC_ASN1_SHORT_INTEGER:
+ case LTC_ASN1_BIT_STRING:
+ case LTC_ASN1_OCTET_STRING:
+ case LTC_ASN1_NULL:
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ case LTC_ASN1_IA5_STRING:
+ case LTC_ASN1_PRINTABLE_STRING:
+ case LTC_ASN1_UTCTIME:
+ case LTC_ASN1_SEQUENCE:
+ case LTC_ASN1_CHOICE:
+ list[x].type = type;
+ list[x].size = size;
+ list[x++].data = data;
+ break;
+
+ default:
+ va_end(args);
+ err = CRYPT_INVALID_ARG;
+ goto LBL_ERR;
+ }
+ }
+ va_end(args);
+
+ err = der_decode_sequence(in, inlen, list, x);
+LBL_ERR:
+ XFREE(list);
+ return err;
+}
+
+#endif
+
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_multi.c,v $ */
+/* $Revision: 1.7 $ */
+/* $Date: 2005/06/18 19:20:23 $ */
============================================================
--- src/pk/asn1/der/sequence/der_encode_sequence.c 792c3db0d29568f7fa3450e3eeabfd2e49d0348d
+++ src/pk/asn1/der/sequence/der_encode_sequence.c 792c3db0d29568f7fa3450e3eeabfd2e49d0348d
@@ -0,0 +1,281 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+#include <stdarg.h>
+
+
+/**
+ @file der_encode_sequence.c
+ ASN.1 DER, encode a SEQUENCE, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+/**
+ Encode a SEQUENCE
+ @param list The list of items to encode
+ @param inlen The number of items in the list
+ @param out [out] The destination
+ @param outlen [in/out] The size of the output
+ @return CRYPT_OK on success
+*/
+int der_encode_sequence(ltc_asn1_list *list, unsigned long inlen,
+ unsigned char *out, unsigned long *outlen)
+{
+ int err, type;
+ unsigned long size, x, y, z, i;
+ void *data;
+
+ LTC_ARGCHK(list != NULL);
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* get size of output that will be required */
+ y = 0;
+ for (i = 0; i < inlen; i++) {
+ type = list[i].type;
+ size = list[i].size;
+ data = list[i].data;
+
+ if (type == LTC_ASN1_EOL) {
+ break;
+ }
+
+ switch (type) {
+ case LTC_ASN1_INTEGER:
+ if ((err = der_length_integer(data, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_SHORT_INTEGER:
+ if ((err = der_length_short_integer(*((unsigned long*)data), &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_BIT_STRING:
+ if ((err = der_length_bit_string(size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_OCTET_STRING:
+ if ((err = der_length_octet_string(size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_NULL:
+ y += 2;
+ break;
+
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ if ((err = der_length_object_identifier(data, size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_IA5_STRING:
+ if ((err = der_length_ia5_string(data, size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_PRINTABLE_STRING:
+ if ((err = der_length_printable_string(data, size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_UTCTIME:
+ if ((err = der_length_utctime(data, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_SEQUENCE:
+ if ((err = der_length_sequence(data, size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+
+ default:
+ err = CRYPT_INVALID_ARG;
+ goto LBL_ERR;
+ }
+ }
+
+ /* calc header size */
+ z = y;
+ if (y < 128) {
+ y += 2;
+ } else if (y < 256) {
+ /* 0x30 0x81 LL */
+ y += 3;
+ } else if (y < 65536UL) {
+ /* 0x30 0x82 LL LL */
+ y += 4;
+ } else if (y < 16777216UL) {
+ /* 0x30 0x83 LL LL LL */
+ y += 5;
+ } else {
+ err = CRYPT_INVALID_ARG;
+ goto LBL_ERR;
+ }
+
+ /* too big ? */
+ if (*outlen < y) {
+ err = CRYPT_BUFFER_OVERFLOW;
+ goto LBL_ERR;
+ }
+
+ /* store header */
+ x = 0;
+ out[x++] = 0x30;
+ if (z < 128) {
+ out[x++] = z;
+ } else if (z < 256) {
+ out[x++] = 0x81;
+ out[x++] = z;
+ } else if (z < 65536UL) {
+ out[x++] = 0x82;
+ out[x++] = (z>>8UL)&255;
+ out[x++] = z&255;
+ } else if (z < 16777216UL) {
+ out[x++] = 0x83;
+ out[x++] = (z>>16UL)&255;
+ out[x++] = (z>>8UL)&255;
+ out[x++] = z&255;
+ }
+
+ /* store data */
+ *outlen -= x;
+ for (i = 0; i < inlen; i++) {
+ type = list[i].type;
+ size = list[i].size;
+ data = list[i].data;
+
+ if (type == LTC_ASN1_EOL) {
+ break;
+ }
+
+ switch (type) {
+ case LTC_ASN1_INTEGER:
+ z = *outlen;
+ if ((err = der_encode_integer(data, out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ case LTC_ASN1_SHORT_INTEGER:
+ z = *outlen;
+ if ((err = der_encode_short_integer(*((unsigned long*)data), out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ case LTC_ASN1_BIT_STRING:
+ z = *outlen;
+ if ((err = der_encode_bit_string(data, size, out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ case LTC_ASN1_OCTET_STRING:
+ z = *outlen;
+ if ((err = der_encode_octet_string(data, size, out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ case LTC_ASN1_NULL:
+ out[x++] = 0x05;
+ out[x++] = 0x00;
+ *outlen -= 2;
+ break;
+
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ z = *outlen;
+ if ((err = der_encode_object_identifier(data, size, out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ case LTC_ASN1_IA5_STRING:
+ z = *outlen;
+ if ((err = der_encode_ia5_string(data, size, out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ case LTC_ASN1_PRINTABLE_STRING:
+ z = *outlen;
+ if ((err = der_encode_printable_string(data, size, out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ case LTC_ASN1_UTCTIME:
+ z = *outlen;
+ if ((err = der_encode_utctime(data, out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ case LTC_ASN1_SEQUENCE:
+ z = *outlen;
+ if ((err = der_encode_sequence(data, size, out + x, &z)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ x += z;
+ *outlen -= z;
+ break;
+
+ default:
+ err = CRYPT_INVALID_ARG;
+ goto LBL_ERR;
+ }
+ }
+ *outlen = x;
+ err = CRYPT_OK;
+
+LBL_ERR:
+ return err;
+}
+
+#endif
============================================================
--- src/pk/asn1/der/sequence/der_encode_sequence_multi.c 1857a51d055148003b171b6208bc23c73d9b0268
+++ src/pk/asn1/der/sequence/der_encode_sequence_multi.c 1857a51d055148003b171b6208bc23c73d9b0268
@@ -0,0 +1,123 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+#include <stdarg.h>
+
+
+/**
+ @file der_encode_sequence_multi.c
+ ASN.1 DER, encode a SEQUENCE, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
+{
+ int err, type;
+ unsigned long size, x;
+ void *data;
+ va_list args;
+ ltc_asn1_list *list;
+
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* get size of output that will be required */
+ va_start(args, outlen);
+ x = 0;
+ for (;;) {
+ type = va_arg(args, int);
+ size = va_arg(args, unsigned long);
+ data = va_arg(args, void*);
+
+ if (type == LTC_ASN1_EOL) {
+ break;
+ }
+
+ switch (type) {
+ case LTC_ASN1_INTEGER:
+ case LTC_ASN1_SHORT_INTEGER:
+ case LTC_ASN1_BIT_STRING:
+ case LTC_ASN1_OCTET_STRING:
+ case LTC_ASN1_NULL:
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ case LTC_ASN1_IA5_STRING:
+ case LTC_ASN1_PRINTABLE_STRING:
+ case LTC_ASN1_UTCTIME:
+ case LTC_ASN1_SEQUENCE:
+ ++x;
+ break;
+
+ default:
+ va_end(args);
+ return CRYPT_INVALID_ARG;
+ }
+ }
+ va_end(args);
+
+ /* allocate structure for x elements */
+ if (x == 0) {
+ return CRYPT_NOP;
+ }
+
+ list = XCALLOC(sizeof(*list), x);
+ if (list == NULL) {
+ return CRYPT_MEM;
+ }
+
+ /* fill in the structure */
+ va_start(args, outlen);
+ x = 0;
+ for (;;) {
+ type = va_arg(args, int);
+ size = va_arg(args, unsigned long);
+ data = va_arg(args, void*);
+
+ if (type == LTC_ASN1_EOL) {
+ break;
+ }
+
+ switch (type) {
+ case LTC_ASN1_INTEGER:
+ case LTC_ASN1_SHORT_INTEGER:
+ case LTC_ASN1_BIT_STRING:
+ case LTC_ASN1_OCTET_STRING:
+ case LTC_ASN1_NULL:
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ case LTC_ASN1_IA5_STRING:
+ case LTC_ASN1_PRINTABLE_STRING:
+ case LTC_ASN1_UTCTIME:
+ case LTC_ASN1_SEQUENCE:
+ list[x].type = type;
+ list[x].size = size;
+ list[x++].data = data;
+ break;
+
+ default:
+ va_end(args);
+ err = CRYPT_INVALID_ARG;
+ goto LBL_ERR;
+ }
+ }
+ va_end(args);
+
+ err = der_encode_sequence(list, x, out, outlen);
+LBL_ERR:
+ XFREE(list);
+ return err;
+}
+
+#endif
+
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c,v $ */
+/* $Revision: 1.6 $ */
+/* $Date: 2005/06/18 19:20:23 $ */
============================================================
--- src/pk/asn1/der/sequence/der_length_sequence.c 37ec5773651e7e3e7d30d1dc3e35777b8b2f4ba1
+++ src/pk/asn1/der/sequence/der_length_sequence.c 37ec5773651e7e3e7d30d1dc3e35777b8b2f4ba1
@@ -0,0 +1,144 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+#include <stdarg.h>
+
+
+/**
+ @file der_length_sequence.c
+ ASN.1 DER, length a SEQUENCE, Tom St Denis
+*/
+
+#ifdef LTC_DER
+
+/**
+ Get the length of a DER sequence
+ @param list The sequences of items in the SEQUENCE
+ @param inlen The number of items
+ @param outlen [out] The length required in octets to store it
+ @return CRYPT_OK on success
+*/
+int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
+ unsigned long *outlen)
+{
+ int err, type;
+ unsigned long size, x, y, z, i;
+ void *data;
+
+ LTC_ARGCHK(list != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* get size of output that will be required */
+ y = 0;
+ for (i = 0; i < inlen; i++) {
+ type = list[i].type;
+ size = list[i].size;
+ data = list[i].data;
+
+ if (type == LTC_ASN1_EOL) {
+ break;
+ }
+
+ switch (type) {
+ case LTC_ASN1_INTEGER:
+ if ((err = der_length_integer(data, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_SHORT_INTEGER:
+ if ((err = der_length_short_integer(*((unsigned long *)data), &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_BIT_STRING:
+ if ((err = der_length_bit_string(size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_OCTET_STRING:
+ if ((err = der_length_octet_string(size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_NULL:
+ y += 2;
+ break;
+
+ case LTC_ASN1_OBJECT_IDENTIFIER:
+ if ((err = der_length_object_identifier(data, size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_IA5_STRING:
+ if ((err = der_length_ia5_string(data, size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_PRINTABLE_STRING:
+ if ((err = der_length_printable_string(data, size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+ case LTC_ASN1_SEQUENCE:
+ if ((err = der_length_sequence(data, size, &x)) != CRYPT_OK) {
+ goto LBL_ERR;
+ }
+ y += x;
+ break;
+
+
+ default:
+ err = CRYPT_INVALID_ARG;
+ goto LBL_ERR;
+ }
+ }
+
+ /* calc header size */
+ z = y;
+ if (y < 128) {
+ y += 2;
+ } else if (y < 256) {
+ /* 0x30 0x81 LL */
+ y += 3;
+ } else if (y < 65536UL) {
+ /* 0x30 0x82 LL LL */
+ y += 4;
+ } else if (y < 16777216UL) {
+ /* 0x30 0x83 LL LL LL */
+ y += 5;
+ } else {
+ err = CRYPT_INVALID_ARG;
+ goto LBL_ERR;
+ }
+
+ /* store size */
+ *outlen = y;
+ err = CRYPT_OK;
+
+LBL_ERR:
+ return err;
+}
+
+#endif
============================================================
--- src/pk/asn1/der/short_integer/der_decode_short_integer.c 0e27a507a14d4fa094f32e05631711e63a714f6e
+++ src/pk/asn1/der/short_integer/der_decode_short_integer.c 0e27a507a14d4fa094f32e05631711e63a714f6e
@@ -0,0 +1,68 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_decode_short_integer.c
+ ASN.1 DER, decode an integer, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+
+/**
+ Read a mp_int integer
+ @param in The DER encoded data
+ @param inlen Size of data
+ @param num [out] The integer to decode
+ @return CRYPT_OK if successful
+*/
+int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsigned long *num)
+{
+ unsigned long len, x, y;
+
+ LTC_ARGCHK(num != NULL);
+ LTC_ARGCHK(in != NULL);
+
+ /* check length */
+ if (inlen < 2) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* check header */
+ x = 0;
+ if ((in[x++] & 0x1F) != 0x02) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* get the packet len */
+ len = in[x++];
+
+ if (x + len > inlen) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* read number */
+ y = 0;
+ while (len--) {
+ y = (y<<8) | (unsigned long)in[x++];
+ }
+ *num = y;
+
+ return CRYPT_OK;
+
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/short_integer/der_decode_short_integer.c,v $ */
+/* $Revision: 1.4 $ */
+/* $Date: 2005/05/23 01:04:13 $ */
============================================================
--- src/pk/asn1/der/short_integer/der_encode_short_integer.c 329ac63b8cfe79d2341d93c89e21dc8f692ca26e
+++ src/pk/asn1/der/short_integer/der_encode_short_integer.c 329ac63b8cfe79d2341d93c89e21dc8f692ca26e
@@ -0,0 +1,97 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_encode_short_integer.c
+ ASN.1 DER, encode an integer, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+
+/* Exports a positive integer as DER format (upto 32-bits in size) */
+/**
+ Store a mp_int integer
+ @param num The integer to encode
+ @param out [out] The destination for the DER encoded integers
+ @param outlen [in/out] The max size and resulting size of the DER encoded integers
+ @return CRYPT_OK if successful
+*/
+int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen)
+{
+ unsigned long len, x, y, z;
+ int err;
+
+ LTC_ARGCHK(out != NULL);
+ LTC_ARGCHK(outlen != NULL);
+
+ /* force to 32 bits */
+ num &= 0xFFFFFFFFUL;
+
+ /* find out how big this will be */
+ if ((err = der_length_short_integer(num, &len)) != CRYPT_OK) {
+ return err;
+ }
+
+ if (*outlen < len) {
+ return CRYPT_BUFFER_OVERFLOW;
+ }
+
+ /* get len of output */
+ z = 0;
+ y = num;
+ while (y) {
+ ++z;
+ y >>= 8;
+ }
+
+ /* handle zero */
+ if (z == 0) {
+ z = 1;
+ }
+
+ /* see if msb is set */
+ z += (num&(1UL<<((z<<3) - 1))) ? 1 : 0;
+
+ /* adjust the number so the msB is non-zero */
+ for (x = 0; (z <= 4) && (x < (4 - z)); x++) {
+ num <<= 8;
+ }
+
+ /* store header */
+ x = 0;
+ out[x++] = 0x02;
+ out[x++] = z;
+
+ /* if 31st bit is set output a leading zero and decrement count */
+ if (z == 5) {
+ out[x++] = 0;
+ --z;
+ }
+
+ /* store values */
+ for (y = 0; y < z; y++) {
+ out[x++] = (num >> 24) & 0xFF;
+ num <<= 8;
+ }
+
+ /* we good */
+ *outlen = x;
+
+ return CRYPT_OK;
+}
+
+#endif
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/short_integer/der_encode_short_integer.c,v $ */
+/* $Revision: 1.3 $ */
+/* $Date: 2005/05/23 01:27:03 $ */
============================================================
--- src/pk/asn1/der/short_integer/der_length_short_integer.c 10df89f9544bfaedbc67e69bd2637fd700fc117f
+++ src/pk/asn1/der/short_integer/der_length_short_integer.c 10df89f9544bfaedbc67e69bd2637fd700fc117f
@@ -0,0 +1,69 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file der_length_short_integer.c
+ ASN.1 DER, get length of encoding, Tom St Denis
+*/
+
+
+#ifdef LTC_DER
+/**
+ Gets length of DER encoding of num
+ @param num The integer to get the size of
+ @param outlen [out] The length of the DER encoding for the given integer
+ @return CRYPT_OK if successful
+*/
+int der_length_short_integer(unsigned long num, unsigned long *outlen)
+{
+ unsigned long z, y, len;
+
+ LTC_ARGCHK(outlen != NULL);
+
+ /* force to 32 bits */
+ num &= 0xFFFFFFFFUL;
+
+ /* get the number of bytes */
+ z = 0;
+ y = num;
+ while (y) {
+ ++z;
+ y >>= 8;
+ }
+
+ /* handle zero */
+ if (z == 0) {
+ z = 1;
+ }
+
+ /* we need a 0x02 to indicate it's INTEGER */
+ len = 1;
+
+ /* length byte */
+ ++len;
+
+ /* bytes in value */
+ len += z;
+
+ /* se