aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/asn1/alg_id.cpp14
-rw-r--r--src/lib/asn1/alg_id.h6
-rw-r--r--src/lib/asn1/asn1_alt_name.cpp6
-rw-r--r--src/lib/asn1/asn1_attribute.cpp4
-rw-r--r--src/lib/asn1/asn1_attribute.h6
-rw-r--r--src/lib/asn1/asn1_obj.cpp10
-rw-r--r--src/lib/asn1/asn1_obj.h4
-rw-r--r--src/lib/asn1/asn1_oid.cpp12
-rw-r--r--src/lib/asn1/asn1_oid.h8
-rw-r--r--src/lib/asn1/asn1_str.cpp4
-rw-r--r--src/lib/asn1/asn1_time.cpp8
-rw-r--r--src/lib/asn1/asn1_time.h14
-rw-r--r--src/lib/asn1/ber_dec.cpp40
-rw-r--r--src/lib/asn1/ber_dec.h26
-rw-r--r--src/lib/asn1/der_enc.cpp66
-rw-r--r--src/lib/asn1/der_enc.h42
-rw-r--r--src/lib/asn1/x509_dn.cpp4
-rw-r--r--src/lib/asn1/x509_dn.h4
-rw-r--r--src/lib/base/buf_comp.h39
-rw-r--r--src/lib/base/sym_algo.h6
-rw-r--r--src/lib/base/symkey.cpp8
-rw-r--r--src/lib/base/symkey.h16
-rw-r--r--src/lib/block/aes/aes.cpp130
-rw-r--r--src/lib/block/aes/aes.h66
-rw-r--r--src/lib/block/aes/aes_ni/aes_ni.cpp20
-rw-r--r--src/lib/block/aes/aes_ssse3/aes_ssse3.cpp26
-rw-r--r--src/lib/block/block_cipher.h24
-rw-r--r--src/lib/block/blowfish/blowfish.cpp66
-rw-r--r--src/lib/block/blowfish/blowfish.h22
-rw-r--r--src/lib/block/camellia/camellia.cpp170
-rw-r--r--src/lib/block/camellia/camellia.h24
-rw-r--r--src/lib/block/cascade/cascade.cpp8
-rw-r--r--src/lib/block/cascade/cascade.h6
-rw-r--r--src/lib/block/cast/cast128.cpp46
-rw-r--r--src/lib/block/cast/cast128.h14
-rw-r--r--src/lib/block/cast/cast256.cpp42
-rw-r--r--src/lib/block/cast/cast256.h10
-rw-r--r--src/lib/block/cast/cast_sboxes.h8
-rw-r--r--src/lib/block/des/des.cpp56
-rw-r--r--src/lib/block/des/des.h40
-rw-r--r--src/lib/block/des/des_tab.cpp24
-rw-r--r--src/lib/block/des/desx.cpp6
-rw-r--r--src/lib/block/des/desx.h8
-rw-r--r--src/lib/block/gost_28147/gost_28147.cpp30
-rw-r--r--src/lib/block/gost_28147/gost_28147.h16
-rw-r--r--src/lib/block/idea/idea.cpp36
-rw-r--r--src/lib/block/idea/idea.h10
-rw-r--r--src/lib/block/idea/idea_sse2/idea_sse2.cpp4
-rw-r--r--src/lib/block/kasumi/kasumi.cpp48
-rw-r--r--src/lib/block/kasumi/kasumi.h8
-rw-r--r--src/lib/block/lion/lion.cpp14
-rw-r--r--src/lib/block/lion/lion.h8
-rw-r--r--src/lib/block/misty1/misty1.cpp48
-rw-r--r--src/lib/block/misty1/misty1.h8
-rw-r--r--src/lib/block/noekeon/noekeon.cpp50
-rw-r--r--src/lib/block/noekeon/noekeon.h14
-rw-r--r--src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp4
-rw-r--r--src/lib/block/seed/seed.cpp44
-rw-r--r--src/lib/block/seed/seed.h8
-rw-r--r--src/lib/block/serpent/serpent.cpp24
-rw-r--r--src/lib/block/serpent/serpent.h16
-rw-r--r--src/lib/block/serpent/serpent_simd/serpent_simd.cpp4
-rw-r--r--src/lib/block/threefish/threefish.cpp38
-rw-r--r--src/lib/block/threefish/threefish.h24
-rw-r--r--src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp12
-rw-r--r--src/lib/block/twofish/twofish.cpp38
-rw-r--r--src/lib/block/twofish/twofish.h30
-rw-r--r--src/lib/block/twofish/twofish_tab.cpp18
-rw-r--r--src/lib/block/xtea/xtea.cpp24
-rw-r--r--src/lib/block/xtea/xtea.h10
-rw-r--r--src/lib/codec/base64/base64.cpp32
-rw-r--r--src/lib/codec/base64/base64.h16
-rw-r--r--src/lib/codec/hex/hex.cpp38
-rw-r--r--src/lib/codec/hex/hex.h20
-rw-r--r--src/lib/compression/bzip2/bzip2.cpp10
-rw-r--r--src/lib/compression/compress_utils.cpp12
-rw-r--r--src/lib/compression/compress_utils.h4
-rw-r--r--src/lib/compression/compression.h40
-rw-r--r--src/lib/compression/lzma/lzma.cpp10
-rw-r--r--src/lib/compression/zlib/zlib.cpp12
-rw-r--r--src/lib/compression/zlib/zlib.h4
-rw-r--r--src/lib/entropy/cryptoapi_rng/es_capi.cpp4
-rw-r--r--src/lib/entropy/cryptoapi_rng/es_capi.h2
-rw-r--r--src/lib/entropy/proc_walk/proc_walk.h2
-rw-r--r--src/lib/ffi/ffi.h6
-rw-r--r--src/lib/filters/aead_filt.h2
-rw-r--r--src/lib/filters/algo_filt.cpp6
-rw-r--r--src/lib/filters/basefilt.h10
-rw-r--r--src/lib/filters/buf_filt.cpp2
-rw-r--r--src/lib/filters/buf_filt.h10
-rw-r--r--src/lib/filters/cipher_filter.cpp10
-rw-r--r--src/lib/filters/cipher_filter.h12
-rw-r--r--src/lib/filters/codec_filt/b64_filt.cpp8
-rw-r--r--src/lib/filters/codec_filt/b64_filt.h12
-rw-r--r--src/lib/filters/codec_filt/hex_filt.cpp6
-rw-r--r--src/lib/filters/codec_filt/hex_filt.h10
-rw-r--r--src/lib/filters/comp_filter.cpp4
-rw-r--r--src/lib/filters/comp_filter.h8
-rw-r--r--src/lib/filters/data_snk.cpp2
-rw-r--r--src/lib/filters/data_snk.h2
-rw-r--r--src/lib/filters/fd_unix/fd_unix.cpp4
-rw-r--r--src/lib/filters/filter.cpp2
-rw-r--r--src/lib/filters/filter.h16
-rw-r--r--src/lib/filters/filters.h8
-rw-r--r--src/lib/filters/out_buf.cpp4
-rw-r--r--src/lib/filters/out_buf.h4
-rw-r--r--src/lib/filters/pipe.cpp10
-rw-r--r--src/lib/filters/pipe.h28
-rw-r--r--src/lib/filters/pipe_io.cpp4
-rw-r--r--src/lib/filters/pipe_rw.cpp26
-rw-r--r--src/lib/filters/secqueue.cpp14
-rw-r--r--src/lib/filters/secqueue.h6
-rw-r--r--src/lib/filters/threaded_fork.cpp6
-rw-r--r--src/lib/hash/blake2/blake2b.cpp40
-rw-r--r--src/lib/hash/blake2/blake2b.h14
-rw-r--r--src/lib/hash/checksum/adler32/adler32.cpp12
-rw-r--r--src/lib/hash/checksum/adler32/adler32.h6
-rw-r--r--src/lib/hash/checksum/crc24/crc24.cpp8
-rw-r--r--src/lib/hash/checksum/crc24/crc24.h6
-rw-r--r--src/lib/hash/checksum/crc32/crc32.cpp8
-rw-r--r--src/lib/hash/checksum/crc32/crc32.h6
-rw-r--r--src/lib/hash/comb4p/comb4p.cpp16
-rw-r--r--src/lib/hash/comb4p/comb4p.h4
-rw-r--r--src/lib/hash/gost_3411/gost_3411.cpp30
-rw-r--r--src/lib/hash/gost_3411/gost_3411.h10
-rw-r--r--src/lib/hash/keccak/keccak.cpp6
-rw-r--r--src/lib/hash/keccak/keccak.h6
-rw-r--r--src/lib/hash/md4/md4.cpp12
-rw-r--r--src/lib/hash/md4/md4.h8
-rw-r--r--src/lib/hash/md5/md5.cpp22
-rw-r--r--src/lib/hash/md5/md5.h8
-rw-r--r--src/lib/hash/mdx_hash/mdx_hash.cpp8
-rw-r--r--src/lib/hash/mdx_hash/mdx_hash.h14
-rw-r--r--src/lib/hash/par_hash/par_hash.cpp6
-rw-r--r--src/lib/hash/par_hash/par_hash.h4
-rw-r--r--src/lib/hash/rmd160/rmd160.cpp28
-rw-r--r--src/lib/hash/rmd160/rmd160.h6
-rw-r--r--src/lib/hash/sha1/sha160.cpp14
-rw-r--r--src/lib/hash/sha1/sha160.h12
-rw-r--r--src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp14
-rw-r--r--src/lib/hash/sha2_32/sha2_32.cpp50
-rw-r--r--src/lib/hash/sha2_32/sha2_32.h12
-rw-r--r--src/lib/hash/sha2_64/sha2_64.cpp54
-rw-r--r--src/lib/hash/sha2_64/sha2_64.h18
-rw-r--r--src/lib/hash/sha3/sha3.cpp94
-rw-r--r--src/lib/hash/sha3/sha3.h12
-rw-r--r--src/lib/hash/shake/shake.cpp12
-rw-r--r--src/lib/hash/shake/shake.h12
-rw-r--r--src/lib/hash/skein/skein_512.cpp30
-rw-r--r--src/lib/hash/skein/skein_512.h10
-rw-r--r--src/lib/hash/tiger/tig_tab.cpp8
-rw-r--r--src/lib/hash/tiger/tiger.cpp16
-rw-r--r--src/lib/hash/tiger/tiger.h20
-rw-r--r--src/lib/hash/whirlpool/whirlpool.cpp12
-rw-r--r--src/lib/hash/whirlpool/whrl_tab.cpp16
-rw-r--r--src/lib/hash/whirlpool/whrlpool.h26
-rw-r--r--src/lib/kdf/hkdf/hkdf.cpp34
-rw-r--r--src/lib/kdf/hkdf/hkdf.h24
-rw-r--r--src/lib/kdf/kdf.h50
-rw-r--r--src/lib/kdf/kdf1/kdf1.cpp10
-rw-r--r--src/lib/kdf/kdf1/kdf1.h8
-rw-r--r--src/lib/kdf/kdf1_iso18033/kdf1_iso18033.cpp12
-rw-r--r--src/lib/kdf/kdf1_iso18033/kdf1_iso18033.h8
-rw-r--r--src/lib/kdf/kdf2/kdf2.cpp12
-rw-r--r--src/lib/kdf/kdf2/kdf2.h8
-rw-r--r--src/lib/kdf/prf_tls/prf_tls.cpp34
-rw-r--r--src/lib/kdf/prf_tls/prf_tls.h16
-rw-r--r--src/lib/kdf/prf_x942/prf_x942.cpp20
-rw-r--r--src/lib/kdf/prf_x942/prf_x942.h8
-rw-r--r--src/lib/kdf/sp800_108/sp800_108.cpp56
-rw-r--r--src/lib/kdf/sp800_108/sp800_108.h24
-rw-r--r--src/lib/kdf/sp800_56c/sp800_56c.cpp10
-rw-r--r--src/lib/kdf/sp800_56c/sp800_56c.h8
-rw-r--r--src/lib/mac/cbc_mac/cbc_mac.cpp6
-rw-r--r--src/lib/mac/cbc_mac/cbc_mac.h8
-rw-r--r--src/lib/mac/cmac/cmac.cpp14
-rw-r--r--src/lib/mac/cmac/cmac.h10
-rw-r--r--src/lib/mac/gmac/gmac.cpp14
-rw-r--r--src/lib/mac/gmac/gmac.h16
-rw-r--r--src/lib/mac/hmac/hmac.cpp8
-rw-r--r--src/lib/mac/hmac/hmac.h8
-rw-r--r--src/lib/mac/mac.cpp4
-rw-r--r--src/lib/mac/mac.h12
-rw-r--r--src/lib/mac/poly1305/poly1305.cpp64
-rw-r--r--src/lib/mac/poly1305/poly1305.h10
-rw-r--r--src/lib/mac/siphash/siphash.cpp24
-rw-r--r--src/lib/mac/siphash/siphash.h12
-rw-r--r--src/lib/mac/x919_mac/x919_mac.cpp6
-rw-r--r--src/lib/mac/x919_mac/x919_mac.h8
-rw-r--r--src/lib/math/bigint/big_code.cpp30
-rw-r--r--src/lib/math/bigint/big_io.cpp2
-rw-r--r--src/lib/math/bigint/big_ops2.cpp4
-rw-r--r--src/lib/math/bigint/big_ops3.cpp4
-rw-r--r--src/lib/math/bigint/big_rand.cpp2
-rw-r--r--src/lib/math/bigint/bigint.cpp30
-rw-r--r--src/lib/math/bigint/bigint.h48
-rw-r--r--src/lib/math/bigint/divide.cpp2
-rw-r--r--src/lib/math/ec_gfp/curve_nistp.cpp216
-rw-r--r--src/lib/math/ec_gfp/point_gfp.cpp26
-rw-r--r--src/lib/math/ec_gfp/point_gfp.h6
-rw-r--r--src/lib/math/mp/mp_core.cpp2
-rw-r--r--src/lib/math/mp/mp_core.h2
-rw-r--r--src/lib/math/mp/mp_karat.cpp6
-rw-r--r--src/lib/math/mp/mp_madd.h6
-rw-r--r--src/lib/math/mp/mp_types.h8
-rw-r--r--src/lib/math/numbertheory/dsa_gen.cpp14
-rw-r--r--src/lib/math/numbertheory/jacobi.cpp4
-rw-r--r--src/lib/math/numbertheory/make_prm.cpp4
-rw-r--r--src/lib/math/numbertheory/numthry.cpp2
-rw-r--r--src/lib/math/numbertheory/numthry.h8
-rw-r--r--src/lib/math/numbertheory/powm_fw.cpp2
-rw-r--r--src/lib/math/numbertheory/powm_mnt.cpp2
-rw-r--r--src/lib/math/numbertheory/primes.cpp2
-rw-r--r--src/lib/misc/aont/package.cpp16
-rw-r--r--src/lib/misc/aont/package.h8
-rw-r--r--src/lib/misc/cryptobox/cryptobox.cpp22
-rw-r--r--src/lib/misc/cryptobox/cryptobox.h4
-rw-r--r--src/lib/misc/fpe_fe1/fpe_fe1.cpp24
-rw-r--r--src/lib/misc/fpe_fe1/fpe_fe1.h4
-rw-r--r--src/lib/misc/rfc3394/rfc3394.cpp22
-rw-r--r--src/lib/misc/rfc3394/rfc3394.h4
-rw-r--r--src/lib/misc/srp6/srp6.cpp10
-rw-r--r--src/lib/misc/srp6/srp6.h4
-rw-r--r--src/lib/misc/srp6/srp6_files.cpp4
-rw-r--r--src/lib/misc/srp6/srp6_files.h6
-rw-r--r--src/lib/misc/tss/tss.cpp58
-rw-r--r--src/lib/misc/tss/tss.h12
-rw-r--r--src/lib/modes/aead/aead.h6
-rw-r--r--src/lib/modes/aead/ccm/ccm.cpp60
-rw-r--r--src/lib/modes/aead/ccm/ccm.h24
-rw-r--r--src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp30
-rw-r--r--src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h12
-rw-r--r--src/lib/modes/aead/eax/eax.cpp22
-rw-r--r--src/lib/modes/aead/eax/eax.h14
-rw-r--r--src/lib/modes/aead/gcm/clmul/clmul.cpp2
-rw-r--r--src/lib/modes/aead/gcm/clmul/clmul.h2
-rw-r--r--src/lib/modes/aead/gcm/gcm.cpp72
-rw-r--r--src/lib/modes/aead/gcm/gcm.h38
-rw-r--r--src/lib/modes/aead/ocb/ocb.cpp74
-rw-r--r--src/lib/modes/aead/ocb/ocb.h26
-rw-r--r--src/lib/modes/aead/siv/siv.cpp26
-rw-r--r--src/lib/modes/aead/siv/siv.h22
-rw-r--r--src/lib/modes/cbc/cbc.cpp22
-rw-r--r--src/lib/modes/cbc/cbc.h20
-rw-r--r--src/lib/modes/cfb/cfb.cpp12
-rw-r--r--src/lib/modes/cfb/cfb.h16
-rw-r--r--src/lib/modes/cipher_mode.h20
-rw-r--r--src/lib/modes/mode_pad/mode_pad.cpp34
-rw-r--r--src/lib/modes/mode_pad/mode_pad.h24
-rw-r--r--src/lib/modes/stream_mode.h6
-rw-r--r--src/lib/modes/xts/xts.cpp28
-rw-r--r--src/lib/modes/xts/xts.h12
-rw-r--r--src/lib/passhash/bcrypt/bcrypt.cpp28
-rw-r--r--src/lib/passhash/bcrypt/bcrypt.h2
-rw-r--r--src/lib/passhash/passhash9/passhash9.cpp18
-rw-r--r--src/lib/passhash/passhash9/passhash9.h4
-rw-r--r--src/lib/pbkdf/pbkdf.cpp20
-rw-r--r--src/lib/pbkdf/pbkdf.h28
-rw-r--r--src/lib/pbkdf/pbkdf1/pbkdf1.cpp6
-rw-r--r--src/lib/pbkdf/pbkdf1/pbkdf1.h4
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.cpp14
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.h8
-rw-r--r--src/lib/pk_pad/eme.cpp4
-rw-r--r--src/lib/pk_pad/eme.h10
-rw-r--r--src/lib/pk_pad/eme_oaep/oaep.cpp28
-rw-r--r--src/lib/pk_pad/eme_oaep/oaep.h8
-rw-r--r--src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp26
-rw-r--r--src/lib/pk_pad/eme_pkcs1/eme_pkcs.h6
-rw-r--r--src/lib/pk_pad/eme_raw/eme_raw.cpp8
-rw-r--r--src/lib/pk_pad/eme_raw/eme_raw.h6
-rw-r--r--src/lib/pk_pad/emsa.h10
-rw-r--r--src/lib/pk_pad/emsa1/emsa1.cpp20
-rw-r--r--src/lib/pk_pad/emsa1/emsa1.h10
-rw-r--r--src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp32
-rw-r--r--src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h20
-rw-r--r--src/lib/pk_pad/emsa_pssr/pssr.cpp26
-rw-r--r--src/lib/pk_pad/emsa_pssr/pssr.h10
-rw-r--r--src/lib/pk_pad/emsa_raw/emsa_raw.cpp12
-rw-r--r--src/lib/pk_pad/emsa_raw/emsa_raw.h10
-rw-r--r--src/lib/pk_pad/emsa_x931/emsa_x931.cpp18
-rw-r--r--src/lib/pk_pad/emsa_x931/emsa_x931.h12
-rw-r--r--src/lib/pk_pad/hash_id/hash_id.cpp42
-rw-r--r--src/lib/pk_pad/hash_id/hash_id.h8
-rw-r--r--src/lib/pk_pad/iso9796/iso9796.cpp70
-rw-r--r--src/lib/pk_pad/iso9796/iso9796.h24
-rw-r--r--src/lib/pk_pad/mgf1/mgf1.cpp8
-rw-r--r--src/lib/pk_pad/mgf1/mgf1.h4
-rw-r--r--src/lib/prov/openssl/openssl_block.cpp10
-rw-r--r--src/lib/prov/openssl/openssl_ec.cpp26
-rw-r--r--src/lib/prov/openssl/openssl_hash.cpp4
-rw-r--r--src/lib/prov/openssl/openssl_rc4.cpp10
-rw-r--r--src/lib/prov/openssl/openssl_rsa.cpp40
-rw-r--r--src/lib/prov/pkcs11/p11.h52
-rw-r--r--src/lib/prov/pkcs11/p11_ecc_key.cpp22
-rw-r--r--src/lib/prov/pkcs11/p11_ecc_key.h26
-rw-r--r--src/lib/prov/pkcs11/p11_ecdh.cpp8
-rw-r--r--src/lib/prov/pkcs11/p11_ecdh.h6
-rw-r--r--src/lib/prov/pkcs11/p11_ecdsa.cpp20
-rw-r--r--src/lib/prov/pkcs11/p11_ecdsa.h4
-rw-r--r--src/lib/prov/pkcs11/p11_mechanism.h8
-rw-r--r--src/lib/prov/pkcs11/p11_object.cpp28
-rw-r--r--src/lib/prov/pkcs11/p11_object.h50
-rw-r--r--src/lib/prov/pkcs11/p11_randomgenerator.cpp6
-rw-r--r--src/lib/prov/pkcs11/p11_randomgenerator.h4
-rw-r--r--src/lib/prov/pkcs11/p11_rsa.cpp32
-rw-r--r--src/lib/prov/pkcs11/p11_rsa.h2
-rw-r--r--src/lib/prov/pkcs11/p11_x509.cpp2
-rw-r--r--src/lib/prov/pkcs11/p11_x509.h20
-rw-r--r--src/lib/prov/tpm/tpm.cpp12
-rw-r--r--src/lib/prov/tpm/tpm.h8
-rw-r--r--src/lib/pubkey/cecpq1/cecpq1.cpp2
-rw-r--r--src/lib/pubkey/curve25519/curve25519.cpp20
-rw-r--r--src/lib/pubkey/curve25519/curve25519.h26
-rw-r--r--src/lib/pubkey/curve25519/donna.cpp6
-rw-r--r--src/lib/pubkey/dh/dh.cpp10
-rw-r--r--src/lib/pubkey/dh/dh.h8
-rw-r--r--src/lib/pubkey/dl_algo/dl_algo.cpp8
-rw-r--r--src/lib/pubkey/dl_algo/dl_algo.h8
-rw-r--r--src/lib/pubkey/dl_group/dl_group.cpp8
-rw-r--r--src/lib/pubkey/dl_group/dl_group.h6
-rw-r--r--src/lib/pubkey/dlies/dlies.cpp28
-rw-r--r--src/lib/pubkey/dlies/dlies.h12
-rw-r--r--src/lib/pubkey/dsa/dsa.cpp16
-rw-r--r--src/lib/pubkey/dsa/dsa.h4
-rw-r--r--src/lib/pubkey/ec_group/ec_group.cpp10
-rw-r--r--src/lib/pubkey/ec_group/ec_group.h4
-rw-r--r--src/lib/pubkey/ecc_key/ecc_key.cpp10
-rw-r--r--src/lib/pubkey/ecc_key/ecc_key.h10
-rw-r--r--src/lib/pubkey/ecdh/ecdh.cpp2
-rw-r--r--src/lib/pubkey/ecdh/ecdh.h12
-rw-r--r--src/lib/pubkey/ecdsa/ecdsa.cpp14
-rw-r--r--src/lib/pubkey/ecdsa/ecdsa.h4
-rw-r--r--src/lib/pubkey/ecgdsa/ecgdsa.cpp14
-rw-r--r--src/lib/pubkey/ecgdsa/ecgdsa.h4
-rw-r--r--src/lib/pubkey/ecies/ecies.cpp34
-rw-r--r--src/lib/pubkey/ecies/ecies.h16
-rw-r--r--src/lib/pubkey/eckcdsa/eckcdsa.cpp36
-rw-r--r--src/lib/pubkey/eckcdsa/eckcdsa.h4
-rw-r--r--src/lib/pubkey/elgamal/elgamal.cpp16
-rw-r--r--src/lib/pubkey/elgamal/elgamal.h4
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.cpp30
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.h6
-rw-r--r--src/lib/pubkey/keypair/keypair.cpp10
-rw-r--r--src/lib/pubkey/mce/code_based_key_gen.cpp56
-rw-r--r--src/lib/pubkey/mce/code_based_util.h8
-rw-r--r--src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp48
-rw-r--r--src/lib/pubkey/mce/gf2m_small_m.cpp10
-rw-r--r--src/lib/pubkey/mce/gf2m_small_m.h8
-rw-r--r--src/lib/pubkey/mce/goppa_code.cpp62
-rw-r--r--src/lib/pubkey/mce/mce_internal.h28
-rw-r--r--src/lib/pubkey/mce/mceliece.cpp52
-rw-r--r--src/lib/pubkey/mce/mceliece.h42
-rw-r--r--src/lib/pubkey/mce/mceliece_key.cpp82
-rw-r--r--src/lib/pubkey/mce/polyn_gf2m.cpp70
-rw-r--r--src/lib/pubkey/mce/polyn_gf2m.h22
-rw-r--r--src/lib/pubkey/mceies/mceies.cpp26
-rw-r--r--src/lib/pubkey/mceies/mceies.h12
-rw-r--r--src/lib/pubkey/newhope/newhope.cpp2
-rw-r--r--src/lib/pubkey/pbes2/pbes2.cpp28
-rw-r--r--src/lib/pubkey/pbes2/pbes2.h10
-rw-r--r--src/lib/pubkey/pem/pem.cpp20
-rw-r--r--src/lib/pubkey/pem/pem.h14
-rw-r--r--src/lib/pubkey/pk_algs.cpp4
-rw-r--r--src/lib/pubkey/pk_algs.h4
-rw-r--r--src/lib/pubkey/pk_keys.cpp6
-rw-r--r--src/lib/pubkey/pk_keys.h10
-rw-r--r--src/lib/pubkey/pk_ops.cpp52
-rw-r--r--src/lib/pubkey/pk_ops.h26
-rw-r--r--src/lib/pubkey/pk_ops_impl.h60
-rw-r--r--src/lib/pubkey/pkcs8.cpp18
-rw-r--r--src/lib/pubkey/pkcs8.h4
-rw-r--r--src/lib/pubkey/pubkey.cpp62
-rw-r--r--src/lib/pubkey/pubkey.h104
-rw-r--r--src/lib/pubkey/rfc6979/rfc6979.h2
-rw-r--r--src/lib/pubkey/rsa/rsa.cpp24
-rw-r--r--src/lib/pubkey/rsa/rsa.h8
-rw-r--r--src/lib/pubkey/x509_key.cpp6
-rw-r--r--src/lib/pubkey/x509_key.h4
-rw-r--r--src/lib/pubkey/xmss/xmss_address.h14
-rw-r--r--src/lib/pubkey/xmss/xmss_common_ops.cpp20
-rw-r--r--src/lib/pubkey/xmss/xmss_common_ops.h14
-rw-r--r--src/lib/pubkey/xmss/xmss_hash.cpp28
-rw-r--r--src/lib/pubkey/xmss/xmss_hash.h52
-rw-r--r--src/lib/pubkey/xmss/xmss_index_registry.cpp10
-rw-r--r--src/lib/pubkey/xmss/xmss_index_registry.h8
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.cpp24
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.h28
-rw-r--r--src/lib/pubkey/xmss/xmss_publickey.cpp16
-rw-r--r--src/lib/pubkey/xmss/xmss_publickey.h38
-rw-r--r--src/lib/pubkey/xmss/xmss_signature.cpp26
-rw-r--r--src/lib/pubkey/xmss/xmss_signature.h20
-rw-r--r--src/lib/pubkey/xmss/xmss_signature_operation.cpp12
-rw-r--r--src/lib/pubkey/xmss/xmss_signature_operation.h10
-rw-r--r--src/lib/pubkey/xmss/xmss_tools.h12
-rw-r--r--src/lib/pubkey/xmss/xmss_verification_operation.cpp22
-rw-r--r--src/lib/pubkey/xmss/xmss_verification_operation.h14
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h2
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h2
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_common_ops.cpp4
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_common_ops.h4
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_parameters.cpp16
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_parameters.h6
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_privatekey.cpp8
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_privatekey.h28
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_publickey.cpp10
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_publickey.h36
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp6
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_signature_operation.h10
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp6
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_verification_operation.h6
-rw-r--r--src/lib/rng/auto_rng/auto_rng.cpp8
-rw-r--r--src/lib/rng/auto_rng/auto_rng.h8
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.cpp12
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.h12
-rw-r--r--src/lib/rng/rng.cpp10
-rw-r--r--src/lib/rng/rng.h32
-rw-r--r--src/lib/rng/stateful_rng/stateful_rng.cpp6
-rw-r--r--src/lib/rng/stateful_rng/stateful_rng.h4
-rw-r--r--src/lib/stream/chacha/chacha.cpp56
-rw-r--r--src/lib/stream/chacha/chacha.h16
-rw-r--r--src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp2
-rw-r--r--src/lib/stream/ctr/ctr.cpp10
-rw-r--r--src/lib/stream/ctr/ctr.h10
-rw-r--r--src/lib/stream/ofb/ofb.cpp8
-rw-r--r--src/lib/stream/ofb/ofb.h10
-rw-r--r--src/lib/stream/rc4/rc4.cpp12
-rw-r--r--src/lib/stream/rc4/rc4.h16
-rw-r--r--src/lib/stream/salsa20/salsa20.cpp56
-rw-r--r--src/lib/stream/salsa20/salsa20.h12
-rw-r--r--src/lib/stream/shake_cipher/shake_cipher.cpp8
-rw-r--r--src/lib/stream/shake_cipher/shake_cipher.h10
-rw-r--r--src/lib/stream/stream_cipher.h14
-rw-r--r--src/lib/tls/credentials_manager.cpp2
-rw-r--r--src/lib/tls/credentials_manager.h2
-rw-r--r--src/lib/tls/msg_cert_req.cpp22
-rw-r--r--src/lib/tls/msg_cert_status.cpp12
-rw-r--r--src/lib/tls/msg_cert_verify.cpp10
-rw-r--r--src/lib/tls/msg_certificate.cpp18
-rw-r--r--src/lib/tls/msg_client_hello.cpp42
-rw-r--r--src/lib/tls/msg_client_kex.cpp58
-rw-r--r--src/lib/tls/msg_finished.cpp14
-rw-r--r--src/lib/tls/msg_hello_verify.cpp10
-rw-r--r--src/lib/tls/msg_server_hello.cpp32
-rw-r--r--src/lib/tls/msg_server_kex.cpp28
-rw-r--r--src/lib/tls/msg_session_ticket.cpp14
-rw-r--r--src/lib/tls/sessions_sql/tls_session_manager_sql.cpp20
-rw-r--r--src/lib/tls/sessions_sql/tls_session_manager_sql.h6
-rw-r--r--src/lib/tls/tls_alert.cpp12
-rw-r--r--src/lib/tls/tls_alert.h4
-rw-r--r--src/lib/tls/tls_blocking.cpp8
-rw-r--r--src/lib/tls/tls_blocking.h15
-rw-r--r--src/lib/tls/tls_callbacks.h12
-rw-r--r--src/lib/tls/tls_cbc/tls_cbc.cpp72
-rw-r--r--src/lib/tls/tls_cbc/tls_cbc.h30
-rw-r--r--src/lib/tls/tls_channel.cpp70
-rw-r--r--src/lib/tls/tls_channel.h50
-rw-r--r--src/lib/tls/tls_ciphersuite.cpp4
-rw-r--r--src/lib/tls/tls_ciphersuite.h12
-rw-r--r--src/lib/tls/tls_client.cpp10
-rw-r--r--src/lib/tls/tls_client.h2
-rw-r--r--src/lib/tls/tls_extensions.cpp172
-rw-r--r--src/lib/tls/tls_extensions.h92
-rw-r--r--src/lib/tls/tls_handshake_hash.cpp2
-rw-r--r--src/lib/tls/tls_handshake_hash.h10
-rw-r--r--src/lib/tls/tls_handshake_io.cpp126
-rw-r--r--src/lib/tls/tls_handshake_io.h112
-rw-r--r--src/lib/tls/tls_handshake_msg.h2
-rw-r--r--src/lib/tls/tls_handshake_state.cpp14
-rw-r--r--src/lib/tls/tls_handshake_state.h10
-rw-r--r--src/lib/tls/tls_messages.h172
-rw-r--r--src/lib/tls/tls_policy.cpp14
-rw-r--r--src/lib/tls/tls_policy.h16
-rw-r--r--src/lib/tls/tls_reader.h34
-rw-r--r--src/lib/tls/tls_record.cpp78
-rw-r--r--src/lib/tls/tls_record.h52
-rw-r--r--src/lib/tls/tls_seq_numbers.h62
-rw-r--r--src/lib/tls/tls_server.cpp34
-rw-r--r--src/lib/tls/tls_server.h12
-rw-r--r--src/lib/tls/tls_server_info.h8
-rw-r--r--src/lib/tls/tls_session.cpp42
-rw-r--r--src/lib/tls/tls_session.h46
-rw-r--r--src/lib/tls/tls_session_key.cpp18
-rw-r--r--src/lib/tls/tls_session_key.h6
-rw-r--r--src/lib/tls/tls_session_manager.h16
-rw-r--r--src/lib/tls/tls_session_manager_memory.cpp4
-rw-r--r--src/lib/tls/tls_version.cpp4
-rw-r--r--src/lib/tls/tls_version.h12
-rw-r--r--src/lib/utils/bit_ops.h2
-rw-r--r--src/lib/utils/bswap.h16
-rw-r--r--src/lib/utils/calendar.h14
-rw-r--r--src/lib/utils/charset.cpp16
-rw-r--r--src/lib/utils/charset.h4
-rw-r--r--src/lib/utils/cpuid.cpp36
-rw-r--r--src/lib/utils/cpuid.h2
-rw-r--r--src/lib/utils/ct_utils.h4
-rw-r--r--src/lib/utils/data_src.cpp20
-rw-r--r--src/lib/utils/data_src.h24
-rw-r--r--src/lib/utils/database.h6
-rw-r--r--src/lib/utils/datastor/datastor.cpp19
-rw-r--r--src/lib/utils/datastor/datastor.h10
-rw-r--r--src/lib/utils/donna128.h36
-rw-r--r--src/lib/utils/http_util/http_util.cpp14
-rw-r--r--src/lib/utils/http_util/http_util.h12
-rw-r--r--src/lib/utils/loadstor.h204
-rw-r--r--src/lib/utils/locking_allocator/locking_allocator.cpp4
-rw-r--r--src/lib/utils/locking_allocator/locking_allocator.h2
-rw-r--r--src/lib/utils/mem_ops.cpp2
-rw-r--r--src/lib/utils/mem_ops.h16
-rw-r--r--src/lib/utils/mul128.h22
-rw-r--r--src/lib/utils/os_utils.cpp4
-rw-r--r--src/lib/utils/parsing.cpp20
-rw-r--r--src/lib/utils/parsing.h10
-rw-r--r--src/lib/utils/simd/simd_32.h18
-rw-r--r--src/lib/utils/sqlite3/sqlite3.cpp8
-rw-r--r--src/lib/utils/sqlite3/sqlite3.h6
-rw-r--r--src/lib/utils/stl_util.h6
-rw-r--r--src/lib/utils/types.h5
-rw-r--r--src/lib/utils/version.cpp14
-rw-r--r--src/lib/utils/version.h14
-rw-r--r--src/lib/x509/certstor.cpp12
-rw-r--r--src/lib/x509/certstor.h8
-rw-r--r--src/lib/x509/certstor_sql/certstor_sql.cpp12
-rw-r--r--src/lib/x509/certstor_sql/certstor_sql.h4
-rw-r--r--src/lib/x509/crl_ent.cpp2
-rw-r--r--src/lib/x509/crl_ent.h4
-rw-r--r--src/lib/x509/name_constraint.cpp12
-rw-r--r--src/lib/x509/ocsp.cpp4
-rw-r--r--src/lib/x509/ocsp.h18
-rw-r--r--src/lib/x509/ocsp_types.h6
-rw-r--r--src/lib/x509/pkcs10.cpp4
-rw-r--r--src/lib/x509/pkcs10.h4
-rw-r--r--src/lib/x509/x509_ca.cpp10
-rw-r--r--src/lib/x509/x509_ca.h8
-rw-r--r--src/lib/x509/x509_crl.cpp14
-rw-r--r--src/lib/x509/x509_crl.h6
-rw-r--r--src/lib/x509/x509_ext.cpp66
-rw-r--r--src/lib/x509/x509_ext.h72
-rw-r--r--src/lib/x509/x509_obj.cpp12
-rw-r--r--src/lib/x509/x509_obj.h14
-rw-r--r--src/lib/x509/x509cert.cpp42
-rw-r--r--src/lib/x509/x509cert.h22
-rw-r--r--src/lib/x509/x509opt.cpp2
-rw-r--r--src/lib/x509/x509path.cpp2
-rw-r--r--src/lib/x509/x509self.cpp6
-rw-r--r--src/lib/x509/x509self.h2
545 files changed, 5338 insertions, 5334 deletions
diff --git a/src/lib/asn1/alg_id.cpp b/src/lib/asn1/alg_id.cpp
index 75ea78c18..0b84d2137 100644
--- a/src/lib/asn1/alg_id.cpp
+++ b/src/lib/asn1/alg_id.cpp
@@ -16,14 +16,14 @@ namespace Botan {
* Create an AlgorithmIdentifier
*/
AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
- const std::vector<byte>& param) : oid(alg_id), parameters(param)
+ const std::vector<uint8_t>& param) : oid(alg_id), parameters(param)
{}
/*
* Create an AlgorithmIdentifier
*/
AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
- const std::vector<byte>& param) : oid(OIDS::lookup(alg_id)), parameters(param)
+ const std::vector<uint8_t>& param) : oid(OIDS::lookup(alg_id)), parameters(param)
{}
/*
@@ -32,10 +32,10 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
Encoding_Option option) : oid(alg_id), parameters()
{
- const byte DER_NULL[] = { 0x05, 0x00 };
+ const uint8_t DER_NULL[] = { 0x05, 0x00 };
if(option == USE_NULL_PARAM)
- parameters += std::pair<const byte*, size_t>(DER_NULL, sizeof(DER_NULL));
+ parameters += std::pair<const uint8_t*, size_t>(DER_NULL, sizeof(DER_NULL));
}
/*
@@ -44,10 +44,10 @@ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
Encoding_Option option) : oid(OIDS::lookup(alg_id)), parameters()
{
- const byte DER_NULL[] = { 0x05, 0x00 };
+ const uint8_t DER_NULL[] = { 0x05, 0x00 };
if(option == USE_NULL_PARAM)
- parameters += std::pair<const byte*, size_t>(DER_NULL, sizeof(DER_NULL));
+ parameters += std::pair<const uint8_t*, size_t>(DER_NULL, sizeof(DER_NULL));
}
/*
@@ -55,7 +55,7 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
*/
namespace {
-bool param_null_or_empty(const std::vector<byte>& p)
+bool param_null_or_empty(const std::vector<uint8_t>& p)
{
if(p.size() == 2 && (p[0] == 0x05) && (p[1] == 0x00))
return true;
diff --git a/src/lib/asn1/alg_id.h b/src/lib/asn1/alg_id.h
index 3b6c3f7ec..2cd0b350a 100644
--- a/src/lib/asn1/alg_id.h
+++ b/src/lib/asn1/alg_id.h
@@ -29,14 +29,14 @@ class BOTAN_DLL AlgorithmIdentifier final : public ASN1_Object
AlgorithmIdentifier(const OID&, Encoding_Option);
AlgorithmIdentifier(const std::string&, Encoding_Option);
- AlgorithmIdentifier(const OID&, const std::vector<byte>&);
- AlgorithmIdentifier(const std::string&, const std::vector<byte>&);
+ AlgorithmIdentifier(const OID&, const std::vector<uint8_t>&);
+ AlgorithmIdentifier(const std::string&, const std::vector<uint8_t>&);
// public member variable:
OID oid;
// public member variable:
- std::vector<byte> parameters;
+ std::vector<uint8_t> parameters;
};
/*
diff --git a/src/lib/asn1/asn1_alt_name.cpp b/src/lib/asn1/asn1_alt_name.cpp
index bd23bdff1..7bd4cd494 100644
--- a/src/lib/asn1/asn1_alt_name.cpp
+++ b/src/lib/asn1/asn1_alt_name.cpp
@@ -137,8 +137,8 @@ void encode_entries(DER_Encoder& encoder,
}
else if(type == "IP")
{
- const u32bit ip = string_to_ipv4(i->second);
- byte ip_buf[4] = { 0 };
+ const uint32_t ip = string_to_ipv4(i->second);
+ uint8_t ip_buf[4] = { 0 };
store_be(ip, ip_buf);
encoder.add_object(tagging, CONTEXT_SPECIFIC, ip_buf, 4);
}
@@ -230,7 +230,7 @@ void AlternativeName::decode_from(BER_Decoder& source)
{
if(obj.value.size() == 4)
{
- const u32bit ip = load_be<u32bit>(&obj.value[0], 0);
+ const uint32_t ip = load_be<uint32_t>(&obj.value[0], 0);
add_attribute("IP", ipv4_to_string(ip));
}
}
diff --git a/src/lib/asn1/asn1_attribute.cpp b/src/lib/asn1/asn1_attribute.cpp
index bd7e5bf11..3093f5025 100644
--- a/src/lib/asn1/asn1_attribute.cpp
+++ b/src/lib/asn1/asn1_attribute.cpp
@@ -15,14 +15,14 @@ namespace Botan {
/*
* Create an Attribute
*/
-Attribute::Attribute(const OID& attr_oid, const std::vector<byte>& attr_value) : oid(attr_oid), parameters(attr_value)
+Attribute::Attribute(const OID& attr_oid, const std::vector<uint8_t>& attr_value) : oid(attr_oid), parameters(attr_value)
{}
/*
* Create an Attribute
*/
Attribute::Attribute(const std::string& attr_oid,
- const std::vector<byte>& attr_value) : oid(OIDS::lookup(attr_oid)), parameters(attr_value)
+ const std::vector<uint8_t>& attr_value) : oid(OIDS::lookup(attr_oid)), parameters(attr_value)
{}
/*
diff --git a/src/lib/asn1/asn1_attribute.h b/src/lib/asn1/asn1_attribute.h
index 737d84b81..e6bcc5209 100644
--- a/src/lib/asn1/asn1_attribute.h
+++ b/src/lib/asn1/asn1_attribute.h
@@ -27,11 +27,11 @@ class BOTAN_DLL Attribute final : public ASN1_Object
OID oid;
// public member variable:
- std::vector<byte> parameters;
+ std::vector<uint8_t> parameters;
Attribute() {}
- Attribute(const OID&, const std::vector<byte>&);
- Attribute(const std::string&, const std::vector<byte>&);
+ Attribute(const OID&, const std::vector<uint8_t>&);
+ Attribute(const std::string&, const std::vector<uint8_t>&);
};
}
diff --git a/src/lib/asn1/asn1_obj.cpp b/src/lib/asn1/asn1_obj.cpp
index 7bf2d92ca..4ccb11c3f 100644
--- a/src/lib/asn1/asn1_obj.cpp
+++ b/src/lib/asn1/asn1_obj.cpp
@@ -32,7 +32,7 @@ namespace ASN1 {
/*
* Put some arbitrary bytes into a SEQUENCE
*/
-std::vector<byte> put_in_sequence(const std::vector<byte>& contents)
+std::vector<uint8_t> put_in_sequence(const std::vector<uint8_t>& contents)
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -54,14 +54,14 @@ std::string to_string(const BER_Object& obj)
*/
bool maybe_BER(DataSource& source)
{
- byte first_byte;
- if(!source.peek_byte(first_byte))
+ uint8_t first_u8;
+ if(!source.peek_byte(first_u8))
{
- BOTAN_ASSERT_EQUAL(source.read_byte(first_byte), 0, "Expected EOF");
+ BOTAN_ASSERT_EQUAL(source.read_byte(first_u8), 0, "Expected EOF");
throw Stream_IO_Error("ASN1::maybe_BER: Source was empty");
}
- if(first_byte == (SEQUENCE | CONSTRUCTED))
+ if(first_u8 == (SEQUENCE | CONSTRUCTED))
return true;
return false;
}
diff --git a/src/lib/asn1/asn1_obj.h b/src/lib/asn1/asn1_obj.h
index 3e119dc01..5e09da2fd 100644
--- a/src/lib/asn1/asn1_obj.h
+++ b/src/lib/asn1/asn1_obj.h
@@ -88,7 +88,7 @@ class BOTAN_DLL BER_Object
ASN1_Tag type_tag, class_tag;
// public member variable:
- secure_vector<byte> value;
+ secure_vector<uint8_t> value;
};
/*
@@ -98,7 +98,7 @@ class DataSource;
namespace ASN1 {
-std::vector<byte> put_in_sequence(const std::vector<byte>& val);
+std::vector<uint8_t> put_in_sequence(const std::vector<uint8_t>& val);
std::string to_string(const BER_Object& obj);
/**
diff --git a/src/lib/asn1/asn1_oid.cpp b/src/lib/asn1/asn1_oid.cpp
index 5b0a557d2..d9436e6d9 100644
--- a/src/lib/asn1/asn1_oid.cpp
+++ b/src/lib/asn1/asn1_oid.cpp
@@ -75,7 +75,7 @@ bool OID::operator==(const OID& oid) const
/*
* Append another component to the OID
*/
-OID& OID::operator+=(u32bit component)
+OID& OID::operator+=(uint32_t component)
{
m_id.push_back(component);
return (*this);
@@ -84,7 +84,7 @@ OID& OID::operator+=(u32bit component)
/*
* Append another component to the OID
*/
-OID operator+(const OID& oid, u32bit component)
+OID operator+(const OID& oid, uint32_t component)
{
OID new_oid(oid);
new_oid += component;
@@ -104,8 +104,8 @@ bool operator!=(const OID& a, const OID& b)
*/
bool operator<(const OID& a, const OID& b)
{
- const std::vector<u32bit>& oid1 = a.get_id();
- const std::vector<u32bit>& oid2 = b.get_id();
+ const std::vector<uint32_t>& oid1 = a.get_id();
+ const std::vector<uint32_t>& oid2 = b.get_id();
if(oid1.size() < oid2.size())
return true;
@@ -129,7 +129,7 @@ void OID::encode_into(DER_Encoder& der) const
if(m_id.size() < 2)
throw Invalid_Argument("OID::encode_into: OID is invalid");
- std::vector<byte> encoding;
+ std::vector<uint8_t> encoding;
encoding.push_back(40 * m_id[0] + m_id[1]);
for(size_t i = 2; i != m_id.size(); ++i)
@@ -171,7 +171,7 @@ void OID::decode_from(BER_Decoder& decoder)
size_t i = 0;
while(i != obj.value.size() - 1)
{
- u32bit component = 0;
+ uint32_t component = 0;
while(i != obj.value.size() - 1)
{
++i;
diff --git a/src/lib/asn1/asn1_oid.h b/src/lib/asn1/asn1_oid.h
index 6fbd876ec..0275b58a9 100644
--- a/src/lib/asn1/asn1_oid.h
+++ b/src/lib/asn1/asn1_oid.h
@@ -33,7 +33,7 @@ class BOTAN_DLL OID final : public ASN1_Object
* Get this OID as list (vector) of its components.
* @return vector representing this OID
*/
- const std::vector<u32bit>& get_id() const { return m_id; }
+ const std::vector<uint32_t>& get_id() const { return m_id; }
/**
* Get this OID as a string
@@ -57,7 +57,7 @@ class BOTAN_DLL OID final : public ASN1_Object
* @param new_comp the new component to add to the end of this OID
* @return reference to *this
*/
- OID& operator+=(u32bit new_comp);
+ OID& operator+=(uint32_t new_comp);
/**
* Construct an OID from a string.
@@ -65,7 +65,7 @@ class BOTAN_DLL OID final : public ASN1_Object
*/
OID(const std::string& str = "");
private:
- std::vector<u32bit> m_id;
+ std::vector<uint32_t> m_id;
};
/**
@@ -73,7 +73,7 @@ class BOTAN_DLL OID final : public ASN1_Object
* @param oid the OID to add the new component to
* @param new_comp the new component to add
*/
-OID BOTAN_DLL operator+(const OID& oid, u32bit new_comp);
+OID BOTAN_DLL operator+(const OID& oid, uint32_t new_comp);
/**
* Compare two OIDs.
diff --git a/src/lib/asn1/asn1_str.cpp b/src/lib/asn1/asn1_str.cpp
index c378d5dfe..81012f284 100644
--- a/src/lib/asn1/asn1_str.cpp
+++ b/src/lib/asn1/asn1_str.cpp
@@ -21,7 +21,7 @@ namespace {
ASN1_Tag choose_encoding(const std::string& str,
const std::string& type)
{
- static const byte IS_PRINTABLE[256] = {
+ static const uint8_t IS_PRINTABLE[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
@@ -47,7 +47,7 @@ ASN1_Tag choose_encoding(const std::string& str,
for(size_t i = 0; i != str.size(); ++i)
{
- if(!IS_PRINTABLE[static_cast<byte>(str[i])])
+ if(!IS_PRINTABLE[static_cast<uint8_t>(str[i])])
{
if(type == "utf8") return UTF8_STRING;
if(type == "latin1") return T61_STRING;
diff --git a/src/lib/asn1/asn1_time.cpp b/src/lib/asn1/asn1_time.cpp
index b091c4160..ef259740b 100644
--- a/src/lib/asn1/asn1_time.cpp
+++ b/src/lib/asn1/asn1_time.cpp
@@ -62,7 +62,7 @@ std::string X509_Time::to_string() const
if(time_is_set() == false)
throw Invalid_State("X509_Time::as_string: No time set");
- u32bit full_year = m_year;
+ uint32_t full_year = m_year;
if(m_tag == UTC_TIME)
{
@@ -86,7 +86,7 @@ std::string X509_Time::to_string() const
factor_i * m_minute +
m_second) + "Z";
- u32bit desired_size = (m_tag == UTC_TIME) ? 13 : 15;
+ uint32_t desired_size = (m_tag == UTC_TIME) ? 13 : 15;
while(repr.size() < desired_size)
repr = "0" + repr;
@@ -117,12 +117,12 @@ bool X509_Time::time_is_set() const
return (m_year != 0);
}
-s32bit X509_Time::cmp(const X509_Time& other) const
+int32_t X509_Time::cmp(const X509_Time& other) const
{
if(time_is_set() == false)
throw Invalid_State("X509_Time::cmp: No time set");
- const s32bit EARLIER = -1, LATER = 1, SAME_TIME = 0;
+ const int32_t EARLIER = -1, LATER = 1, SAME_TIME = 0;
if(m_year < other.m_year) return EARLIER;
if(m_year > other.m_year) return LATER;
diff --git a/src/lib/asn1/asn1_time.h b/src/lib/asn1/asn1_time.h
index ee30221ee..a2a526558 100644
--- a/src/lib/asn1/asn1_time.h
+++ b/src/lib/asn1/asn1_time.h
@@ -35,7 +35,7 @@ class BOTAN_DLL X509_Time final : public ASN1_Object
bool time_is_set() const;
/// Compare this time against another
- s32bit cmp(const X509_Time& other) const;
+ int32_t cmp(const X509_Time& other) const;
/// Create an invalid X509_Time
X509_Time() {}
@@ -53,12 +53,12 @@ class BOTAN_DLL X509_Time final : public ASN1_Object
void set_to(const std::string& t_spec, ASN1_Tag);
bool passes_sanity_check() const;
- u32bit m_year = 0;
- u32bit m_month = 0;
- u32bit m_day = 0;
- u32bit m_hour = 0;
- u32bit m_minute = 0;
- u32bit m_second = 0;
+ uint32_t m_year = 0;
+ uint32_t m_month = 0;
+ uint32_t m_day = 0;
+ uint32_t m_hour = 0;
+ uint32_t m_minute = 0;
+ uint32_t m_second = 0;
ASN1_Tag m_tag = NO_OBJECT;
};
diff --git a/src/lib/asn1/ber_dec.cpp b/src/lib/asn1/ber_dec.cpp
index 81c04aa6a..7b2147600 100644
--- a/src/lib/asn1/ber_dec.cpp
+++ b/src/lib/asn1/ber_dec.cpp
@@ -20,7 +20,7 @@ namespace {
*/
size_t decode_tag(DataSource* ber, ASN1_Tag& type_tag, ASN1_Tag& class_tag)
{
- byte b;
+ uint8_t b;
if(!ber->read_byte(b))
{
class_tag = type_tag = NO_OBJECT;
@@ -62,7 +62,7 @@ size_t find_eoc(DataSource*);
*/
size_t decode_length(DataSource* ber, size_t& field_size)
{
- byte b;
+ uint8_t b;
if(!ber->read_byte(b))
throw BER_Decoding_Error("Length field not found");
field_size = 1;
@@ -101,7 +101,7 @@ size_t decode_length(DataSource* ber)
*/
size_t find_eoc(DataSource* ber)
{
- secure_vector<byte> buffer(DEFAULT_BUFFERSIZE), data;
+ secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE), data;
while(true)
{
@@ -175,19 +175,19 @@ BER_Decoder& BER_Decoder::verify_end()
/*
* Save all the bytes remaining in the source
*/
-BER_Decoder& BER_Decoder::raw_bytes(secure_vector<byte>& out)
+BER_Decoder& BER_Decoder::raw_bytes(secure_vector<uint8_t>& out)
{
out.clear();
- byte buf;
+ uint8_t buf;
while(m_source->read_byte(buf))
out.push_back(buf);
return (*this);
}
-BER_Decoder& BER_Decoder::raw_bytes(std::vector<byte>& out)
+BER_Decoder& BER_Decoder::raw_bytes(std::vector<uint8_t>& out)
{
out.clear();
- byte buf;
+ uint8_t buf;
while(m_source->read_byte(buf))
out.push_back(buf);
return (*this);
@@ -198,7 +198,7 @@ BER_Decoder& BER_Decoder::raw_bytes(std::vector<byte>& out)
*/
BER_Decoder& BER_Decoder::discard_remaining()
{
- byte buf;
+ uint8_t buf;
while(m_source->read_byte(buf))
;
return (*this);
@@ -292,7 +292,7 @@ BER_Decoder::BER_Decoder(DataSource& src)
/*
* BER_Decoder Constructor
*/
-BER_Decoder::BER_Decoder(const byte data[], size_t length)
+BER_Decoder::BER_Decoder(const uint8_t data[], size_t length)
{
m_source = new DataSource_Memory(data, length);
m_owns = true;
@@ -303,7 +303,7 @@ BER_Decoder::BER_Decoder(const byte data[], size_t length)
/*
* BER_Decoder Constructor
*/
-BER_Decoder::BER_Decoder(const secure_vector<byte>& data)
+BER_Decoder::BER_Decoder(const secure_vector<uint8_t>& data)
{
m_source = new DataSource_Memory(data);
m_owns = true;
@@ -314,7 +314,7 @@ BER_Decoder::BER_Decoder(const secure_vector<byte>& data)
/*
* BER_Decoder Constructor
*/
-BER_Decoder::BER_Decoder(const std::vector<byte>& data)
+BER_Decoder::BER_Decoder(const std::vector<uint8_t>& data)
{
m_source = new DataSource_Memory(data.data(), data.size());
m_owns = true;
@@ -396,15 +396,15 @@ BER_Decoder& BER_Decoder::decode(BigInt& out)
BER_Decoder& BER_Decoder::decode_octet_string_bigint(BigInt& out)
{
- secure_vector<byte> out_vec;
+ secure_vector<uint8_t> out_vec;
decode(out_vec, OCTET_STRING);
out = BigInt::decode(out_vec.data(), out_vec.size());
return (*this);
}
-std::vector<byte> BER_Decoder::get_next_octet_string()
+std::vector<uint8_t> BER_Decoder::get_next_octet_string()
{
- std::vector<byte> out_vec;
+ std::vector<uint8_t> out_vec;
decode(out_vec, OCTET_STRING);
return out_vec;
}
@@ -447,7 +447,7 @@ BER_Decoder& BER_Decoder::decode(size_t& out,
/*
* Decode a small BER encoded INTEGER
*/
-u64bit BER_Decoder::decode_constrained_integer(ASN1_Tag type_tag,
+uint64_t BER_Decoder::decode_constrained_integer(ASN1_Tag type_tag,
ASN1_Tag class_tag,
size_t T_bytes)
{
@@ -460,7 +460,7 @@ u64bit BER_Decoder::decode_constrained_integer(ASN1_Tag type_tag,
if(integer.bits() > 8*T_bytes)
throw BER_Decoding_Error("Decoded integer value larger than expected");
- u64bit out = 0;
+ uint64_t out = 0;
for(size_t i = 0; i != 8; ++i)
out = (out << 8) | integer.byte_at(7-i);
@@ -503,7 +503,7 @@ BER_Decoder& BER_Decoder::decode(BigInt& out,
/*
* BER decode a BIT STRING or OCTET STRING
*/
-BER_Decoder& BER_Decoder::decode(secure_vector<byte>& out, ASN1_Tag real_type)
+BER_Decoder& BER_Decoder::decode(secure_vector<uint8_t>& out, ASN1_Tag real_type)
{
return decode(out, real_type, real_type, UNIVERSAL);
}
@@ -511,7 +511,7 @@ BER_Decoder& BER_Decoder::decode(secure_vector<byte>& out, ASN1_Tag real_type)
/*
* BER decode a BIT STRING or OCTET STRING
*/
-BER_Decoder& BER_Decoder::decode(std::vector<byte>& out, ASN1_Tag real_type)
+BER_Decoder& BER_Decoder::decode(std::vector<uint8_t>& out, ASN1_Tag real_type)
{
return decode(out, real_type, real_type, UNIVERSAL);
}
@@ -519,7 +519,7 @@ BER_Decoder& BER_Decoder::decode(std::vector<byte>& out, ASN1_Tag real_type)
/*
* BER decode a BIT STRING or OCTET STRING
*/
-BER_Decoder& BER_Decoder::decode(secure_vector<byte>& buffer,
+BER_Decoder& BER_Decoder::decode(secure_vector<uint8_t>& buffer,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -544,7 +544,7 @@ BER_Decoder& BER_Decoder::decode(secure_vector<byte>& buffer,
return (*this);
}
-BER_Decoder& BER_Decoder::decode(std::vector<byte>& buffer,
+BER_Decoder& BER_Decoder::decode(std::vector<uint8_t>& buffer,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
diff --git a/src/lib/asn1/ber_dec.h b/src/lib/asn1/ber_dec.h
index 8c1491851..810896880 100644
--- a/src/lib/asn1/ber_dec.h
+++ b/src/lib/asn1/ber_dec.h
@@ -21,7 +21,7 @@ class BOTAN_DLL BER_Decoder
public:
BER_Object get_next_object();
- std::vector<byte> get_next_octet_string();
+ std::vector<uint8_t> get_next_octet_string();
void push_back(const BER_Object& obj);
@@ -34,15 +34,15 @@ class BOTAN_DLL BER_Decoder
BER_Decoder& get_next(BER_Object& ber);
- BER_Decoder& raw_bytes(secure_vector<byte>& v);
- BER_Decoder& raw_bytes(std::vector<byte>& v);
+ BER_Decoder& raw_bytes(secure_vector<uint8_t>& v);
+ BER_Decoder& raw_bytes(std::vector<uint8_t>& v);
BER_Decoder& decode_null();
BER_Decoder& decode(bool& v);
BER_Decoder& decode(size_t& v);
BER_Decoder& decode(class BigInt& v);
- BER_Decoder& decode(std::vector<byte>& v, ASN1_Tag type_tag);
- BER_Decoder& decode(secure_vector<byte>& v, ASN1_Tag type_tag);
+ BER_Decoder& decode(std::vector<uint8_t>& v, ASN1_Tag type_tag);
+ BER_Decoder& decode(secure_vector<uint8_t>& v, ASN1_Tag type_tag);
BER_Decoder& decode(bool& v,
ASN1_Tag type_tag,
@@ -56,12 +56,12 @@ class BOTAN_DLL BER_Decoder
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- BER_Decoder& decode(std::vector<byte>& v,
+ BER_Decoder& decode(std::vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- BER_Decoder& decode(secure_vector<byte>& v,
+ BER_Decoder& decode(secure_vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
@@ -72,7 +72,7 @@ class BOTAN_DLL BER_Decoder
BER_Decoder& decode_octet_string_bigint(class BigInt& b);
- u64bit decode_constrained_integer(ASN1_Tag type_tag,
+ uint64_t decode_constrained_integer(ASN1_Tag type_tag,
ASN1_Tag class_tag,
size_t T_bytes);
@@ -127,9 +127,9 @@ class BOTAN_DLL BER_Decoder
* Decode an OPTIONAL string type
*/
template<typename Alloc>
- BER_Decoder& decode_optional_string(std::vector<byte, Alloc>& out,
+ BER_Decoder& decode_optional_string(std::vector<uint8_t, Alloc>& out,
ASN1_Tag real_type,
- u16bit type_no,
+ uint16_t type_no,
ASN1_Tag class_tag = CONTEXT_SPECIFIC)
{
BER_Object obj = get_next_object();
@@ -159,11 +159,11 @@ class BOTAN_DLL BER_Decoder
explicit BER_Decoder(DataSource&);
- BER_Decoder(const byte[], size_t);
+ BER_Decoder(const uint8_t[], size_t);
- explicit BER_Decoder(const secure_vector<byte>&);
+ explicit BER_Decoder(const secure_vector<uint8_t>&);
- explicit BER_Decoder(const std::vector<byte>& vec);
+ explicit BER_Decoder(const std::vector<uint8_t>& vec);
BER_Decoder(const BER_Decoder&);
~BER_Decoder();
diff --git a/src/lib/asn1/der_enc.cpp b/src/lib/asn1/der_enc.cpp
index c5c2b4803..071e330ff 100644
--- a/src/lib/asn1/der_enc.cpp
+++ b/src/lib/asn1/der_enc.cpp
@@ -20,15 +20,15 @@ namespace {
/*
* DER encode an ASN.1 type tag
*/
-secure_vector<byte> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag)
+secure_vector<uint8_t> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag)
{
if((class_tag | 0xE0) != 0xE0)
throw Encoding_Error("DER_Encoder: Invalid class tag " +
std::to_string(class_tag));
- secure_vector<byte> encoded_tag;
+ secure_vector<uint8_t> encoded_tag;
if(type_tag <= 30)
- encoded_tag.push_back(static_cast<byte>(type_tag | class_tag));
+ encoded_tag.push_back(static_cast<uint8_t>(type_tag | class_tag));
else
{
size_t blocks = high_bit(type_tag) + 6;
@@ -48,18 +48,18 @@ secure_vector<byte> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag)
/*
* DER encode an ASN.1 length field
*/
-secure_vector<byte> encode_length(size_t length)
+secure_vector<uint8_t> encode_length(size_t length)
{
- secure_vector<byte> encoded_length;
+ secure_vector<uint8_t> encoded_length;
if(length <= 127)
- encoded_length.push_back(static_cast<byte>(length));
+ encoded_length.push_back(static_cast<uint8_t>(length));
else
{
- const size_t top_byte = significant_bytes(length);
+ const size_t bytes_needed = significant_bytes(length);
- encoded_length.push_back(static_cast<byte>(0x80 | top_byte));
+ encoded_length.push_back(static_cast<uint8_t>(0x80 | bytes_needed));
- for(size_t i = sizeof(length) - top_byte; i != sizeof(length); ++i)
+ for(size_t i = sizeof(length) - bytes_needed; i < sizeof(length); ++i)
encoded_length.push_back(get_byte(i, length));
}
return encoded_length;
@@ -70,7 +70,7 @@ secure_vector<byte> encode_length(size_t length)
/*
* Return the encoded SEQUENCE/SET
*/
-secure_vector<byte> DER_Encoder::DER_Sequence::get_contents()
+secure_vector<uint8_t> DER_Encoder::DER_Sequence::get_contents()
{
const ASN1_Tag real_class_tag = ASN1_Tag(m_class_tag | CONSTRUCTED);
@@ -82,7 +82,7 @@ secure_vector<byte> DER_Encoder::DER_Sequence::get_contents()
m_set_contents.clear();
}
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
result += encode_tag(m_type_tag, real_class_tag);
result += encode_length(m_contents.size());
result += m_contents;
@@ -94,10 +94,10 @@ secure_vector<byte> DER_Encoder::DER_Sequence::get_contents()
/*
* Add an encoded value to the SEQUENCE/SET
*/
-void DER_Encoder::DER_Sequence::add_bytes(const byte data[], size_t length)
+void DER_Encoder::DER_Sequence::add_bytes(const uint8_t data[], size_t length)
{
if(m_type_tag == SET)
- m_set_contents.push_back(secure_vector<byte>(data, data + length));
+ m_set_contents.push_back(secure_vector<uint8_t>(data, data + length));
else
m_contents += std::make_pair(data, length);
}
@@ -121,12 +121,12 @@ DER_Encoder::DER_Sequence::DER_Sequence(ASN1_Tag t1, ASN1_Tag t2) :
/*
* Return the encoded contents
*/
-secure_vector<byte> DER_Encoder::get_contents()
+secure_vector<uint8_t> DER_Encoder::get_contents()
{
if(m_subsequences.size() != 0)
throw Invalid_State("DER_Encoder: Sequence hasn't been marked done");
- secure_vector<byte> output;
+ secure_vector<uint8_t> output;
std::swap(output, m_contents);
return output;
}
@@ -149,7 +149,7 @@ DER_Encoder& DER_Encoder::end_cons()
if(m_subsequences.empty())
throw Invalid_State("DER_Encoder::end_cons: No such sequence");
- secure_vector<byte> seq = m_subsequences[m_subsequences.size()-1].get_contents();
+ secure_vector<uint8_t> seq = m_subsequences[m_subsequences.size()-1].get_contents();
m_subsequences.pop_back();
raw_bytes(seq);
return (*this);
@@ -158,7 +158,7 @@ DER_Encoder& DER_Encoder::end_cons()
/*
* Start a new ASN.1 EXPLICIT encoding
*/
-DER_Encoder& DER_Encoder::start_explicit(u16bit type_no)
+DER_Encoder& DER_Encoder::start_explicit(uint16_t type_no)
{
ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
@@ -179,12 +179,12 @@ DER_Encoder& DER_Encoder::end_explicit()
/*
* Write raw bytes into the stream
*/
-DER_Encoder& DER_Encoder::raw_bytes(const secure_vector<byte>& val)
+DER_Encoder& DER_Encoder::raw_bytes(const secure_vector<uint8_t>& val)
{
return raw_bytes(val.data(), val.size());
}
-DER_Encoder& DER_Encoder::raw_bytes(const std::vector<byte>& val)
+DER_Encoder& DER_Encoder::raw_bytes(const std::vector<uint8_t>& val)
{
return raw_bytes(val.data(), val.size());
}
@@ -192,7 +192,7 @@ DER_Encoder& DER_Encoder::raw_bytes(const std::vector<byte>& val)
/*
* Write raw bytes into the stream
*/
-DER_Encoder& DER_Encoder::raw_bytes(const byte bytes[], size_t length)
+DER_Encoder& DER_Encoder::raw_bytes(const uint8_t bytes[], size_t length)
{
if(m_subsequences.size())
m_subsequences[m_subsequences.size()-1].add_bytes(bytes, length);
@@ -237,7 +237,7 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n)
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const secure_vector<byte>& bytes,
+DER_Encoder& DER_Encoder::encode(const secure_vector<uint8_t>& bytes,
ASN1_Tag real_type)
{
return encode(bytes.data(), bytes.size(),
@@ -247,7 +247,7 @@ DER_Encoder& DER_Encoder::encode(const secure_vector<byte>& bytes,
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const std::vector<byte>& bytes,
+DER_Encoder& DER_Encoder::encode(const std::vector<uint8_t>& bytes,
ASN1_Tag real_type)
{
return encode(bytes.data(), bytes.size(),
@@ -257,7 +257,7 @@ DER_Encoder& DER_Encoder::encode(const std::vector<byte>& bytes,
/*
* Encode this object
*/
-DER_Encoder& DER_Encoder::encode(const byte bytes[], size_t length,
+DER_Encoder& DER_Encoder::encode(const uint8_t bytes[], size_t length,
ASN1_Tag real_type)
{
return encode(bytes, length, real_type, real_type, UNIVERSAL);
@@ -269,7 +269,7 @@ DER_Encoder& DER_Encoder::encode(const byte bytes[], size_t length,
DER_Encoder& DER_Encoder::encode(bool is_true,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
- byte val = is_true ? 0xFF : 0x00;
+ uint8_t val = is_true ? 0xFF : 0x00;
return add_object(type_tag, class_tag, &val, 1);
}
@@ -292,7 +292,7 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n,
return add_object(type_tag, class_tag, 0);
bool extra_zero = (n.bits() % 8 == 0);
- secure_vector<byte> contents(extra_zero + n.bytes());
+ secure_vector<uint8_t> contents(extra_zero + n.bytes());
BigInt::encode(&contents[extra_zero], n);
if(n < 0)
{
@@ -309,7 +309,7 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n,
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const secure_vector<byte>& bytes,
+DER_Encoder& DER_Encoder::encode(const secure_vector<uint8_t>& bytes,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -320,7 +320,7 @@ DER_Encoder& DER_Encoder::encode(const secure_vector<byte>& bytes,
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const std::vector<byte>& bytes,
+DER_Encoder& DER_Encoder::encode(const std::vector<uint8_t>& bytes,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -331,7 +331,7 @@ DER_Encoder& DER_Encoder::encode(const std::vector<byte>& bytes,
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const byte bytes[], size_t length,
+DER_Encoder& DER_Encoder::encode(const uint8_t bytes[], size_t length,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -340,7 +340,7 @@ DER_Encoder& DER_Encoder::encode(const byte bytes[], size_t length,
if(real_type == BIT_STRING)
{
- secure_vector<byte> encoded;
+ secure_vector<uint8_t> encoded;
encoded.push_back(0);
encoded += std::make_pair(bytes, length);
return add_object(type_tag, class_tag, encoded);
@@ -379,9 +379,9 @@ DER_Encoder& DER_Encoder::encode(const ASN1_Object& obj)
* Write the encoding of the byte(s)
*/
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- const byte rep[], size_t length)
+ const uint8_t rep[], size_t length)
{
- secure_vector<byte> buffer;
+ secure_vector<uint8_t> buffer;
buffer += encode_tag(type_tag, class_tag);
buffer += encode_length(length);
buffer += std::make_pair(rep, length);
@@ -395,7 +395,7 @@ DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
const std::string& rep_str)
{
- const byte* rep = reinterpret_cast<const byte*>(rep_str.data());
+ const uint8_t* rep = reinterpret_cast<const uint8_t*>(rep_str.data());
const size_t rep_len = rep_str.size();
return add_object(type_tag, class_tag, rep, rep_len);
}
@@ -404,7 +404,7 @@ DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
* Write the encoding of the byte
*/
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag,
- ASN1_Tag class_tag, byte rep)
+ ASN1_Tag class_tag, uint8_t rep)
{
return add_object(type_tag, class_tag, &rep, 1);
}
diff --git a/src/lib/asn1/der_enc.h b/src/lib/asn1/der_enc.h
index 78cb4c38d..22a8741c6 100644
--- a/src/lib/asn1/der_enc.h
+++ b/src/lib/asn1/der_enc.h
@@ -22,29 +22,29 @@ class ASN1_Object;
class BOTAN_DLL DER_Encoder
{
public:
- secure_vector<byte> get_contents();
+ secure_vector<uint8_t> get_contents();
- std::vector<byte> get_contents_unlocked()
+ std::vector<uint8_t> get_contents_unlocked()
{ return unlock(get_contents()); }
DER_Encoder& start_cons(ASN1_Tag type_tag,
ASN1_Tag class_tag = UNIVERSAL);
DER_Encoder& end_cons();
- DER_Encoder& start_explicit(u16bit type_tag);
+ DER_Encoder& start_explicit(uint16_t type_tag);
DER_Encoder& end_explicit();
- DER_Encoder& raw_bytes(const byte val[], size_t len);
- DER_Encoder& raw_bytes(const secure_vector<byte>& val);
- DER_Encoder& raw_bytes(const std::vector<byte>& val);
+ DER_Encoder& raw_bytes(const uint8_t val[], size_t len);
+ DER_Encoder& raw_bytes(const secure_vector<uint8_t>& val);
+ DER_Encoder& raw_bytes(const std::vector<uint8_t>& val);
DER_Encoder& encode_null();
DER_Encoder& encode(bool b);
DER_Encoder& encode(size_t s);
DER_Encoder& encode(const BigInt& n);
- DER_Encoder& encode(const secure_vector<byte>& v, ASN1_Tag real_type);
- DER_Encoder& encode(const std::vector<byte>& v, ASN1_Tag real_type);
- DER_Encoder& encode(const byte val[], size_t len, ASN1_Tag real_type);
+ DER_Encoder& encode(const secure_vector<uint8_t>& v, ASN1_Tag real_type);
+ DER_Encoder& encode(const std::vector<uint8_t>& v, ASN1_Tag real_type);
+ DER_Encoder& encode(const uint8_t val[], size_t len, ASN1_Tag real_type);
DER_Encoder& encode(bool b,
ASN1_Tag type_tag,
@@ -58,17 +58,17 @@ class BOTAN_DLL DER_Encoder
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- DER_Encoder& encode(const std::vector<byte>& v,
+ DER_Encoder& encode(const std::vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- DER_Encoder& encode(const secure_vector<byte>& v,
+ DER_Encoder& encode(const secure_vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- DER_Encoder& encode(const byte v[], size_t len,
+ DER_Encoder& encode(const uint8_t v[], size_t len,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
@@ -94,16 +94,16 @@ class BOTAN_DLL DER_Encoder
DER_Encoder& encode_if(bool pred, const ASN1_Object& obj);
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- const byte rep[], size_t length);
+ const uint8_t rep[], size_t length);
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- const std::vector<byte>& rep)
+ const std::vector<uint8_t>& rep)
{
return add_object(type_tag, class_tag, rep.data(), rep.size());
}
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- const secure_vector<byte>& rep)
+ const secure_vector<uint8_t>& rep)
{
return add_object(type_tag, class_tag, rep.data(), rep.size());
}
@@ -112,23 +112,23 @@ class BOTAN_DLL DER_Encoder
const std::string& str);
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- byte val);
+ uint8_t val);
private:
class DER_Sequence
{
public:
ASN1_Tag tag_of() const;
- secure_vector<byte> get_contents();
- void add_bytes(const byte[], size_t);
+ secure_vector<uint8_t> get_contents();
+ void add_bytes(const uint8_t[], size_t);
DER_Sequence(ASN1_Tag, ASN1_Tag);
private:
ASN1_Tag m_type_tag, m_class_tag;
- secure_vector<byte> m_contents;
- std::vector< secure_vector<byte> > m_set_contents;
+ secure_vector<uint8_t> m_contents;
+ std::vector< secure_vector<uint8_t> > m_set_contents;
};
- secure_vector<byte> m_contents;
+ secure_vector<uint8_t> m_contents;
std::vector<DER_Sequence> m_subsequences;
};
diff --git a/src/lib/asn1/x509_dn.cpp b/src/lib/asn1/x509_dn.cpp
index e9a4731b3..e5cd2b8cc 100644
--- a/src/lib/asn1/x509_dn.cpp
+++ b/src/lib/asn1/x509_dn.cpp
@@ -108,7 +108,7 @@ std::vector<std::string> X509_DN::get_attribute(const std::string& attr) const
/*
* Return the BER encoded data, if any
*/
-std::vector<byte> X509_DN::get_bits() const
+std::vector<uint8_t> X509_DN::get_bits() const
{
return m_dn_bits;
}
@@ -249,7 +249,7 @@ void X509_DN::encode_into(DER_Encoder& der) const
*/
void X509_DN::decode_from(BER_Decoder& source)
{
- std::vector<byte> bits;
+ std::vector<uint8_t> bits;
source.start_cons(SEQUENCE)
.raw_bytes(bits)
diff --git a/src/lib/asn1/x509_dn.h b/src/lib/asn1/x509_dn.h
index 92dd7a3d2..8add8d64c 100644
--- a/src/lib/asn1/x509_dn.h
+++ b/src/lib/asn1/x509_dn.h
@@ -35,7 +35,7 @@ class BOTAN_DLL X509_DN final : public ASN1_Object
static std::string deref_info_field(const std::string&);
- std::vector<byte> get_bits() const;
+ std::vector<uint8_t> get_bits() const;
bool empty() const { return m_dn_info.empty(); }
@@ -44,7 +44,7 @@ class BOTAN_DLL X509_DN final : public ASN1_Object
explicit X509_DN(const std::multimap<std::string, std::string>&);
private:
std::multimap<OID, ASN1_String> m_dn_info;
- std::vector<byte> m_dn_bits;
+ std::vector<uint8_t> m_dn_bits;
};
bool BOTAN_DLL operator==(const X509_DN&, const X509_DN&);
diff --git a/src/lib/base/buf_comp.h b/src/lib/base/buf_comp.h
index 264b16bd0..ca5ecd4ff 100644
--- a/src/lib/base/buf_comp.h
+++ b/src/lib/base/buf_comp.h
@@ -31,13 +31,13 @@ class BOTAN_DLL Buffered_Computation
* @param in the input to process as a byte array
* @param length of param in in bytes
*/
- void update(const byte in[], size_t length) { add_data(in, length); }
+ void update(const uint8_t in[], size_t length) { add_data(in, length); }
/**
* Add new input to process.
* @param in the input to process as a secure_vector
*/
- void update(const secure_vector<byte>& in)
+ void update(const secure_vector<uint8_t>& in)
{
add_data(in.data(), in.size());
}
@@ -46,7 +46,7 @@ class BOTAN_DLL Buffered_Computation
* Add new input to process.
* @param in the input to process as a std::vector
*/
- void update(const std::vector<byte>& in)
+ void update(const std::vector<uint8_t>& in)
{
add_data(in.data(), in.size());
}
@@ -59,7 +59,7 @@ class BOTAN_DLL Buffered_Computation
{
for(size_t i = 0; i != sizeof(T); ++i)
{
- byte b = get_byte(i, in);
+ uint8_t b = get_byte(i, in);
add_data(&b, 1);
}
}
@@ -67,19 +67,18 @@ class BOTAN_DLL Buffered_Computation
/**
* Add new input to process.
* @param str the input to process as a std::string. Will be interpreted
- * as a byte array based on
- * the strings encoding.
+ * as a byte array based on the strings encoding.
*/
void update(const std::string& str)
{
- add_data(reinterpret_cast<const byte*>(str.data()), str.size());
+ add_data(reinterpret_cast<const uint8_t*>(str.data()), str.size());
}
/**
* Process a single byte.
* @param in the byte to process
*/
- void update(byte in) { add_data(&in, 1); }
+ void update(uint8_t in) { add_data(&in, 1); }
/**
* Complete the computation and retrieve the
@@ -87,29 +86,29 @@ class BOTAN_DLL Buffered_Computation
* @param out The byte array to be filled with the result.
* Must be of length output_length()
*/
- void final(byte out[]) { final_result(out); }
+ void final(uint8_t out[]) { final_result(out); }
/**
* Complete the computation and retrieve the
* final result.
* @return secure_vector holding the result
*/
- secure_vector<byte> final()
+ secure_vector<uint8_t> final()
{
- secure_vector<byte> output(output_length());
+ secure_vector<uint8_t> output(output_length());
final_result(output.data());
return output;
}
- std::vector<byte> final_stdvec()
+ std::vector<uint8_t> final_stdvec()
{
- std::vector<byte> output(output_length());
+ std::vector<uint8_t> output(output_length());
final_result(output.data());
return output;
}
template<typename Alloc>
- void final(std::vector<byte, Alloc>& out)
+ void final(std::vector<uint8_t, Alloc>& out)
{
out.resize(output_length());
final_result(out.data());
@@ -122,7 +121,7 @@ class BOTAN_DLL Buffered_Computation
* @param length the length of the byte array
* @result the result of the call to final()
*/
- secure_vector<byte> process(const byte in[], size_t length)
+ secure_vector<uint8_t> process(const uint8_t in[], size_t length)
{
add_data(in, length);
return final();
@@ -134,7 +133,7 @@ class BOTAN_DLL Buffered_Computation
* @param in the input to process
* @result the result of the call to final()
*/
- secure_vector<byte> process(const secure_vector<byte>& in)
+ secure_vector<uint8_t> process(const secure_vector<uint8_t>& in)
{
add_data(in.data(), in.size());
return final();
@@ -146,7 +145,7 @@ class BOTAN_DLL Buffered_Computation
* @param in the input to process
* @result the result of the call to final()
*/
- secure_vector<byte> process(const std::vector<byte>& in)
+ secure_vector<uint8_t> process(const std::vector<uint8_t>& in)
{
add_data(in.data(), in.size());
return final();
@@ -158,7 +157,7 @@ class BOTAN_DLL Buffered_Computation
* @param in the input to process as a string
* @result the result of the call to final()
*/
- secure_vector<byte> process(const std::string& in)
+ secure_vector<uint8_t> process(const std::string& in)
{
update(in);
return final();
@@ -171,13 +170,13 @@ class BOTAN_DLL Buffered_Computation
* @param input is an input buffer
* @param length is the length of input in bytes
*/
- virtual void add_data(const byte input[], size_t length) = 0;
+ virtual void add_data(const uint8_t input[], size_t length) = 0;
/**
* Write the final output to out
* @param out is an output buffer of output_length()
*/
- virtual void final_result(byte out[]) = 0;
+ virtual void final_result(uint8_t out[]) = 0;
};
}
diff --git a/src/lib/base/sym_algo.h b/src/lib/base/sym_algo.h
index a3f301b37..b573beaef 100644
--- a/src/lib/base/sym_algo.h
+++ b/src/lib/base/sym_algo.h
@@ -69,7 +69,7 @@ class BOTAN_DLL SymmetricAlgorithm
}
template<typename Alloc>
- void set_key(const std::vector<byte, Alloc>& key)
+ void set_key(const std::vector<uint8_t, Alloc>& key)
{
set_key(key.data(), key.size());
}
@@ -79,7 +79,7 @@ class BOTAN_DLL SymmetricAlgorithm
* @param key the to be set as a byte array.
* @param length in bytes of key param
*/
- void set_key(const byte key[], size_t length)
+ void set_key(const uint8_t key[], size_t length)
{
if(!valid_keylength(length))
throw Invalid_Key_Length(name(), length);
@@ -97,7 +97,7 @@ class BOTAN_DLL SymmetricAlgorithm
* @param key the key
* @param length of key
*/
- virtual void key_schedule(const byte key[], size_t length) = 0;
+ virtual void key_schedule(const uint8_t key[], size_t length) = 0;
};
}
diff --git a/src/lib/base/symkey.cpp b/src/lib/base/symkey.cpp
index d5a02a45d..a012773ff 100644
--- a/src/lib/base/symkey.cpp
+++ b/src/lib/base/symkey.cpp
@@ -33,7 +33,7 @@ OctetString::OctetString(const std::string& hex_string)
/*
* Create an OctetString from a byte string
*/
-OctetString::OctetString(const byte in[], size_t n)
+OctetString::OctetString(const uint8_t in[], size_t n)
{
m_data.assign(in, in + n);
}
@@ -43,7 +43,7 @@ OctetString::OctetString(const byte in[], size_t n)
*/
void OctetString::set_odd_parity()
{
- const byte ODD_PARITY[256] = {
+ const uint8_t ODD_PARITY[256] = {
0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07, 0x08, 0x08, 0x0B, 0x0B,
0x0D, 0x0D, 0x0E, 0x0E, 0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16,
0x19, 0x19, 0x1A, 0x1A, 0x1C, 0x1C, 0x1F, 0x1F, 0x20, 0x20, 0x23, 0x23,
@@ -110,7 +110,7 @@ bool operator!=(const OctetString& s1, const OctetString& s2)
*/
OctetString operator+(const OctetString& k1, const OctetString& k2)
{
- secure_vector<byte> out;
+ secure_vector<uint8_t> out;
out += k1.bits_of();
out += k2.bits_of();
return OctetString(out);
@@ -121,7 +121,7 @@ OctetString operator+(const OctetString& k1, const OctetString& k2)
*/
OctetString operator^(const OctetString& k1, const OctetString& k2)
{
- secure_vector<byte> out(std::max(k1.length(), k2.length()));
+ secure_vector<uint8_t> out(std::max(k1.length(), k2.length()));
copy_mem(out.data(), k1.begin(), k1.length());
xor_buf(out.data(), k2.begin(), k2.length());
diff --git a/src/lib/base/symkey.h b/src/lib/base/symkey.h
index c780e5239..dc523f82e 100644
--- a/src/lib/base/symkey.h
+++ b/src/lib/base/symkey.h
@@ -26,19 +26,19 @@ class BOTAN_DLL OctetString
size_t size() const { return m_data.size(); }
/**
- * @return this object as a secure_vector<byte>
+ * @return this object as a secure_vector<uint8_t>
*/
- secure_vector<byte> bits_of() const { return m_data; }
+ secure_vector<uint8_t> bits_of() const { return m_data; }
/**
* @return start of this string
*/
- const byte* begin() const { return m_data.data(); }
+ const uint8_t* begin() const { return m_data.data(); }
/**
* @return end of this string
*/
- const byte* end() const { return begin() + m_data.size(); }
+ const uint8_t* end() const { return begin() + m_data.size(); }
/**
* @return this encoded as hex
@@ -75,22 +75,22 @@ class BOTAN_DLL OctetString
* @param in is an array
* @param len is the length of in in bytes
*/
- OctetString(const byte in[], size_t len);
+ OctetString(const uint8_t in[], size_t len);
/**
* Create a new OctetString
* @param in a bytestring
*/
- OctetString(const secure_vector<byte>& in) : m_data(in) {}
+ OctetString(const secure_vector<uint8_t>& in) : m_data(in) {}
/**
* Create a new OctetString
* @param in a bytestring
*/
- OctetString(const std::vector<byte>& in) : m_data(in.begin(), in.end()) {}
+ OctetString(const std::vector<uint8_t>& in) : m_data(in.begin(), in.end()) {}
private:
- secure_vector<byte> m_data;
+ secure_vector<uint8_t> m_data;
};
/**
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp
index f0e66bc1b..6b9d56665 100644
--- a/src/lib/block/aes/aes.cpp
+++ b/src/lib/block/aes/aes.cpp
@@ -47,7 +47,7 @@ namespace Botan {
namespace {
-const byte SE[256] = {
+const uint8_t SE[256] = {
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B,
0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26,
@@ -71,7 +71,7 @@ const byte SE[256] = {
0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F,
0xB0, 0x54, 0xBB, 0x16 };
-const byte SD[256] = {
+const uint8_t SD[256] = {
0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E,
0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32,
@@ -95,24 +95,24 @@ const byte SD[256] = {
0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63,
0x55, 0x21, 0x0C, 0x7D };
-inline byte xtime(byte s) { return (s << 1) ^ ((s >> 7) * 0x1B); }
-inline byte xtime4(byte s) { return xtime(xtime(s)); }
-inline byte xtime8(byte s) { return xtime(xtime(xtime(s))); }
+inline uint8_t xtime(uint8_t s) { return (s << 1) ^ ((s >> 7) * 0x1B); }
+inline uint8_t xtime4(uint8_t s) { return xtime(xtime(s)); }
+inline uint8_t xtime8(uint8_t s) { return xtime(xtime(xtime(s))); }
-inline byte xtime3(byte s) { return xtime(s) ^ s; }
-inline byte xtime9(byte s) { return xtime8(s) ^ s; }
-inline byte xtime11(byte s) { return xtime8(s) ^ xtime(s) ^ s; }
-inline byte xtime13(byte s) { return xtime8(s) ^ xtime4(s) ^ s; }
-inline byte xtime14(byte s) { return xtime8(s) ^ xtime4(s) ^ xtime(s); }
+inline uint8_t xtime3(uint8_t s) { return xtime(s) ^ s; }
+inline uint8_t xtime9(uint8_t s) { return xtime8(s) ^ s; }
+inline uint8_t xtime11(uint8_t s) { return xtime8(s) ^ xtime(s) ^ s; }
+inline uint8_t xtime13(uint8_t s) { return xtime8(s) ^ xtime4(s) ^ s; }
+inline uint8_t xtime14(uint8_t s) { return xtime8(s) ^ xtime4(s) ^ xtime(s); }
-const std::vector<u32bit>& AES_TE()
+const std::vector<uint32_t>& AES_TE()
{
auto compute_TE = []() {
- std::vector<u32bit> TE(1024);
+ std::vector<uint32_t> TE(1024);
for(size_t i = 0; i != 256; ++i)
{
- const byte s = SE[i];
- const u32bit x = make_u32bit(xtime(s), s, s, xtime3(s));
+ const uint8_t s = SE[i];
+ const uint32_t x = make_uint32(xtime(s), s, s, xtime3(s));
TE[i] = x;
TE[i+256] = rotate_right(x, 8);
@@ -122,18 +122,18 @@ const std::vector<u32bit>& AES_TE()
return TE;
};
- static const std::vector<u32bit> TE = compute_TE();
+ static const std::vector<uint32_t> TE = compute_TE();
return TE;
}
-const std::vector<u32bit>& AES_TD()
+const std::vector<uint32_t>& AES_TD()
{
auto compute_TD = []() {
- std::vector<u32bit> TD(1024);
+ std::vector<uint32_t> TD(1024);
for(size_t i = 0; i != 256; ++i)
{
- const byte s = SD[i];
- const u32bit x = make_u32bit(xtime14(s), xtime9(s), xtime13(s), xtime11(s));
+ const uint8_t s = SD[i];
+ const uint32_t x = make_uint32(xtime14(s), xtime9(s), xtime13(s), xtime11(s));
TD[i] = x;
TD[i+256] = rotate_right(x, 8);
@@ -142,27 +142,27 @@ const std::vector<u32bit>& AES_TD()
}
return TD;
};
- static const std::vector<u32bit> TD = compute_TD();
+ static const std::vector<uint32_t> TD = compute_TD();
return TD;
}
/*
* AES Encryption
*/
-void aes_encrypt_n(const byte in[], byte out[],
+void aes_encrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks,
- const secure_vector<u32bit>& EK,
- const secure_vector<byte>& ME)
+ const secure_vector<uint32_t>& EK,
+ const secure_vector<uint8_t>& ME)
{
BOTAN_ASSERT(EK.size() && ME.size() == 16, "Key was set");
const size_t cache_line_size = CPUID::cache_line_size();
- const std::vector<u32bit>& TE = AES_TE();
+ const std::vector<uint32_t>& TE = AES_TE();
// Hit every cache line of TE
- u32bit Z = 0;
- for(size_t i = 0; i < TE.size(); i += cache_line_size / sizeof(u32bit))
+ uint32_t Z = 0;
+ for(size_t i = 0; i < TE.size(); i += cache_line_size / sizeof(uint32_t))
{
Z |= TE[i];
}
@@ -170,7 +170,7 @@ void aes_encrypt_n(const byte in[], byte out[],
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit T0, T1, T2, T3;
+ uint32_t T0, T1, T2, T3;
load_be(in + 16*i, T0, T1, T2, T3);
T0 ^= EK[0];
@@ -188,22 +188,22 @@ void aes_encrypt_n(const byte in[], byte out[],
* vulnerable.
*/
- u32bit B0 = TE[get_byte(0, T0)] ^
+ uint32_t B0 = TE[get_byte(0, T0)] ^
rotate_right(TE[get_byte(1, T1)], 8) ^
rotate_right(TE[get_byte(2, T2)], 16) ^
rotate_right(TE[get_byte(3, T3)], 24) ^ EK[4];
- u32bit B1 = TE[get_byte(0, T1)] ^
+ uint32_t B1 = TE[get_byte(0, T1)] ^
rotate_right(TE[get_byte(1, T2)], 8) ^
rotate_right(TE[get_byte(2, T3)], 16) ^
rotate_right(TE[get_byte(3, T0)], 24) ^ EK[5];
- u32bit B2 = TE[get_byte(0, T2)] ^
+ uint32_t B2 = TE[get_byte(0, T2)] ^
rotate_right(TE[get_byte(1, T3)], 8) ^
rotate_right(TE[get_byte(2, T0)], 16) ^
rotate_right(TE[get_byte(3, T1)], 24) ^ EK[6];
- u32bit B3 = TE[get_byte(0, T3)] ^
+ uint32_t B3 = TE[get_byte(0, T3)] ^
rotate_right(TE[get_byte(1, T0)], 8) ^
rotate_right(TE[get_byte(2, T1)], 16) ^
rotate_right(TE[get_byte(3, T2)], 24) ^ EK[7];
@@ -251,17 +251,17 @@ void aes_encrypt_n(const byte in[], byte out[],
/*
* AES Decryption
*/
-void aes_decrypt_n(const byte in[], byte out[], size_t blocks,
- const secure_vector<u32bit>& DK,
- const secure_vector<byte>& MD)
+void aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks,
+ const secure_vector<uint32_t>& DK,
+ const secure_vector<uint8_t>& MD)
{
BOTAN_ASSERT(DK.size() && MD.size() == 16, "Key was set");
const size_t cache_line_size = CPUID::cache_line_size();
- const std::vector<u32bit>& TD = AES_TD();
+ const std::vector<uint32_t>& TD = AES_TD();
- u32bit Z = 0;
- for(size_t i = 0; i < TD.size(); i += cache_line_size / sizeof(u32bit))
+ uint32_t Z = 0;
+ for(size_t i = 0; i < TD.size(); i += cache_line_size / sizeof(uint32_t))
{
Z |= TD[i];
}
@@ -269,29 +269,29 @@ void aes_decrypt_n(const byte in[], byte out[], size_t blocks,
for(size_t i = 0; i != blocks; ++i)
{
- u32bit T0 = load_be<u32bit>(in, 0) ^ DK[0];
- u32bit T1 = load_be<u32bit>(in, 1) ^ DK[1];
- u32bit T2 = load_be<u32bit>(in, 2) ^ DK[2];
- u32bit T3 = load_be<u32bit>(in, 3) ^ DK[3];
+ uint32_t T0 = load_be<uint32_t>(in, 0) ^ DK[0];
+ uint32_t T1 = load_be<uint32_t>(in, 1) ^ DK[1];
+ uint32_t T2 = load_be<uint32_t>(in, 2) ^ DK[2];
+ uint32_t T3 = load_be<uint32_t>(in, 3) ^ DK[3];
T0 ^= Z;
- u32bit B0 = TD[get_byte(0, T0)] ^
+ uint32_t B0 = TD[get_byte(0, T0)] ^
rotate_right(TD[get_byte(1, T3)], 8) ^
rotate_right(TD[get_byte(2, T2)], 16) ^
rotate_right(TD[get_byte(3, T1)], 24) ^ DK[4];
- u32bit B1 = TD[get_byte(0, T1)] ^
+ uint32_t B1 = TD[get_byte(0, T1)] ^
rotate_right(TD[get_byte(1, T0)], 8) ^
rotate_right(TD[get_byte(2, T3)], 16) ^
rotate_right(TD[get_byte(3, T2)], 24) ^ DK[5];
- u32bit B2 = TD[get_byte(0, T2)] ^
+ uint32_t B2 = TD[get_byte(0, T2)] ^
rotate_right(TD[get_byte(1, T1)], 8) ^
rotate_right(TD[get_byte(2, T0)], 16) ^
rotate_right(TD[get_byte(3, T3)], 24) ^ DK[6];
- u32bit B3 = TD[get_byte(0, T3)] ^
+ uint32_t B3 = TD[get_byte(0, T3)] ^
rotate_right(TD[get_byte(1, T2)], 8) ^
rotate_right(TD[get_byte(2, T1)], 16) ^
rotate_right(TD[get_byte(3, T0)], 24) ^ DK[7];
@@ -339,19 +339,19 @@ void aes_decrypt_n(const byte in[], byte out[], size_t blocks,
}
}
-void aes_key_schedule(const byte key[], size_t length,
- secure_vector<u32bit>& EK,
- secure_vector<u32bit>& DK,
- secure_vector<byte>& ME,
- secure_vector<byte>& MD)
+void aes_key_schedule(const uint8_t key[], size_t length,
+ secure_vector<uint32_t>& EK,
+ secure_vector<uint32_t>& DK,
+ secure_vector<uint8_t>& ME,
+ secure_vector<uint8_t>& MD)
{
- static const u32bit RC[10] = {
+ static const uint32_t RC[10] = {
0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000,
0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000 };
const size_t rounds = (length / 4) + 6;
- secure_vector<u32bit> XEK(length + 32), XDK(length + 32);
+ secure_vector<uint32_t> XEK(length + 32), XDK(length + 32);
const size_t X = length / 4;
@@ -359,12 +359,12 @@ void aes_key_schedule(const byte key[], size_t length,
BOTAN_ASSERT(X == 4 || X == 6 || X == 8, "Valid AES key size");
for(size_t i = 0; i != X; ++i)
- XEK[i] = load_be<u32bit>(key, i);
+ XEK[i] = load_be<uint32_t>(key, i);
for(size_t i = X; i < 4*(rounds+1); i += X)
{
XEK[i] = XEK[i-X] ^ RC[(i-X)/X] ^
- make_u32bit(SE[get_byte(1, XEK[i-1])],
+ make_uint32(SE[get_byte(1, XEK[i-1])],
SE[get_byte(2, XEK[i-1])],
SE[get_byte(3, XEK[i-1])],
SE[get_byte(0, XEK[i-1])]);
@@ -374,7 +374,7 @@ void aes_key_schedule(const byte key[], size_t length,
XEK[i+j] = XEK[i+j-X];
if(X == 8 && j == 4)
- XEK[i+j] ^= make_u32bit(SE[get_byte(0, XEK[i+j-1])],
+ XEK[i+j] ^= make_uint32(SE[get_byte(0, XEK[i+j-1])],
SE[get_byte(1, XEK[i+j-1])],
SE[get_byte(2, XEK[i+j-1])],
SE[get_byte(3, XEK[i+j-1])]);
@@ -383,7 +383,7 @@ void aes_key_schedule(const byte key[], size_t length,
}
}
- const std::vector<u32bit>& TD = AES_TD();
+ const std::vector<uint32_t>& TD = AES_TD();
for(size_t i = 0; i != 4*(rounds+1); i += 4)
{
@@ -439,7 +439,7 @@ std::string AES_128::provider() const { return aes_provider(); }
std::string AES_192::provider() const { return aes_provider(); }
std::string AES_256::provider() const { return aes_provider(); }
-void AES_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -458,7 +458,7 @@ void AES_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
aes_encrypt_n(in, out, blocks, m_EK, m_ME);
}
-void AES_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -477,7 +477,7 @@ void AES_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
aes_decrypt_n(in, out, blocks, m_DK, m_MD);
}
-void AES_128::key_schedule(const byte key[], size_t length)
+void AES_128::key_schedule(const uint8_t key[], size_t length)
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -504,7 +504,7 @@ void AES_128::clear()
zap(m_MD);
}
-void AES_192::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -523,7 +523,7 @@ void AES_192::encrypt_n(const byte in[], byte out[], size_t blocks) const
aes_encrypt_n(in, out, blocks, m_EK, m_ME);
}
-void AES_192::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -542,7 +542,7 @@ void AES_192::decrypt_n(const byte in[], byte out[], size_t blocks) const
aes_decrypt_n(in, out, blocks, m_DK, m_MD);
}
-void AES_192::key_schedule(const byte key[], size_t length)
+void AES_192::key_schedule(const uint8_t key[], size_t length)
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -569,7 +569,7 @@ void AES_192::clear()
zap(m_MD);
}
-void AES_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -588,7 +588,7 @@ void AES_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
aes_encrypt_n(in, out, blocks, m_EK, m_ME);
}
-void AES_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -607,7 +607,7 @@ void AES_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
aes_decrypt_n(in, out, blocks, m_DK, m_MD);
}
-void AES_256::key_schedule(const byte key[], size_t length)
+void AES_256::key_schedule(const uint8_t key[], size_t length)
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
diff --git a/src/lib/block/aes/aes.h b/src/lib/block/aes/aes.h
index 6bd38cada..52f877e36 100644
--- a/src/lib/block/aes/aes.h
+++ b/src/lib/block/aes/aes.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -27,22 +27,22 @@ class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
std::string name() const override { return "AES-128"; }
BlockCipher* clone() const override { return new AES_128; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
#if defined(BOTAN_HAS_AES_SSSE3)
- void ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_key_schedule(const byte key[], size_t length);
+ void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_key_schedule(const uint8_t key[], size_t length);
#endif
#if defined(BOTAN_HAS_AES_NI)
- void aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_key_schedule(const byte key[], size_t length);
+ void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_key_schedule(const uint8_t key[], size_t length);
#endif
- secure_vector<u32bit> m_EK, m_DK;
- secure_vector<byte> m_ME, m_MD;
+ secure_vector<uint32_t> m_EK, m_DK;
+ secure_vector<uint8_t> m_ME, m_MD;
};
/**
@@ -51,8 +51,8 @@ class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -61,21 +61,21 @@ class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
BlockCipher* clone() const override { return new AES_192; }
private:
#if defined(BOTAN_HAS_AES_SSSE3)
- void ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_key_schedule(const byte key[], size_t length);
+ void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_key_schedule(const uint8_t key[], size_t length);
#endif
#if defined(BOTAN_HAS_AES_NI)
- void aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_key_schedule(const byte key[], size_t length);
+ void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_key_schedule(const uint8_t key[], size_t length);
#endif
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u32bit> m_EK, m_DK;
- secure_vector<byte> m_ME, m_MD;
+ secure_vector<uint32_t> m_EK, m_DK;
+ secure_vector<uint8_t> m_ME, m_MD;
};
/**
@@ -84,8 +84,8 @@ class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
class BOTAN_DLL AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -95,21 +95,21 @@ class BOTAN_DLL AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
BlockCipher* clone() const override { return new AES_256; }
private:
#if defined(BOTAN_HAS_AES_SSSE3)
- void ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_key_schedule(const byte key[], size_t length);
+ void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_key_schedule(const uint8_t key[], size_t length);
#endif
#if defined(BOTAN_HAS_AES_NI)
- void aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_key_schedule(const byte key[], size_t length);
+ void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_key_schedule(const uint8_t key[], size_t length);
#endif
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u32bit> m_EK, m_DK;
- secure_vector<byte> m_ME, m_MD;
+ secure_vector<uint32_t> m_EK, m_DK;
+ secure_vector<uint8_t> m_ME, m_MD;
};
}
diff --git a/src/lib/block/aes/aes_ni/aes_ni.cpp b/src/lib/block/aes/aes_ni/aes_ni.cpp
index 7518a6cf2..52f4e44a2 100644
--- a/src/lib/block/aes/aes_ni/aes_ni.cpp
+++ b/src/lib/block/aes/aes_ni/aes_ni.cpp
@@ -25,7 +25,7 @@ __m128i aes_128_key_expansion(__m128i key, __m128i key_with_rcon)
BOTAN_FUNC_ISA("ssse3")
void aes_192_key_expansion(__m128i* K1, __m128i* K2, __m128i key2_with_rcon,
- u32bit out[], bool last)
+ uint32_t out[], bool last)
{
__m128i key1 = *K1;
__m128i key2 = *K2;
@@ -107,7 +107,7 @@ __m128i aes_256_key_expansion(__m128i key, __m128i key2)
* AES-128 Encryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_128::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -184,7 +184,7 @@ void AES_128::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-128 Decryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_128::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -261,7 +261,7 @@ void AES_128::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-128 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_128::aesni_key_schedule(const byte key[], size_t)
+void AES_128::aesni_key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(44);
m_DK.resize(44);
@@ -314,7 +314,7 @@ void AES_128::aesni_key_schedule(const byte key[], size_t)
* AES-192 Encryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_192::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -397,7 +397,7 @@ void AES_192::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-192 Decryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_192::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -480,7 +480,7 @@ void AES_192::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-192 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_192::aesni_key_schedule(const byte key[], size_t)
+void AES_192::aesni_key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(52);
m_DK.resize(52);
@@ -530,7 +530,7 @@ void AES_192::aesni_key_schedule(const byte key[], size_t)
* AES-256 Encryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_256::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -619,7 +619,7 @@ void AES_256::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-256 Decryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_256::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -708,7 +708,7 @@ void AES_256::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-256 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_256::aesni_key_schedule(const byte key[], size_t)
+void AES_256::aesni_key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(60);
m_DK.resize(60);
diff --git a/src/lib/block/aes/aes_ssse3/aes_ssse3.cpp b/src/lib/block/aes/aes_ssse3/aes_ssse3.cpp
index d8c7e7314..6dcf1e794 100644
--- a/src/lib/block/aes/aes_ssse3/aes_ssse3.cpp
+++ b/src/lib/block/aes/aes_ssse3/aes_ssse3.cpp
@@ -65,7 +65,7 @@ __m128i aes_schedule_transform(__m128i input,
}
BOTAN_FUNC_ISA("ssse3")
-__m128i aes_schedule_mangle(__m128i k, byte round_no)
+__m128i aes_schedule_mangle(__m128i k, uint8_t round_no)
{
__m128i t = _mm_shuffle_epi8(_mm_xor_si128(k, _mm_set1_epi8(0x5B)),
mc_forward[0]);
@@ -88,7 +88,7 @@ __m128i aes_schedule_192_smear(__m128i x, __m128i y)
}
BOTAN_FUNC_ISA("ssse3")
-__m128i aes_schedule_mangle_dec(__m128i k, byte round_no)
+__m128i aes_schedule_mangle_dec(__m128i k, uint8_t round_no)
{
const __m128i dsk[8] = {
_mm_set_epi32(0x4AED9334, 0x82255BFC, 0xB6116FC8, 0x7ED9A700),
@@ -117,7 +117,7 @@ __m128i aes_schedule_mangle_dec(__m128i k, byte round_no)
}
BOTAN_FUNC_ISA("ssse3")
-__m128i aes_schedule_mangle_last(__m128i k, byte round_no)
+__m128i aes_schedule_mangle_last(__m128i k, uint8_t round_no)
{
const __m128i out_tr1 = _mm_set_epi32(
0xF7974121, 0xDEBE6808, 0xFF9F4929, 0xD6B66000);
@@ -315,7 +315,7 @@ __m128i aes_ssse3_decrypt(__m128i B, const __m128i* keys, size_t rounds)
x = _mm_xor_si128(x, K);
x = _mm_xor_si128(x, y);
- const u32bit which_sr = ((((rounds - 1) << 4) ^ 48) & 48) / 16;
+ const uint32_t which_sr = ((((rounds - 1) << 4) ^ 48) & 48) / 16;
return _mm_shuffle_epi8(x, sr[which_sr]);
}
@@ -346,7 +346,7 @@ __m128i aes_ssse3_decrypt(__m128i B, const __m128i* keys, size_t rounds)
* AES-128 Encryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_128::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -369,7 +369,7 @@ void AES_128::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-128 Decryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_128::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -392,7 +392,7 @@ void AES_128::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-128 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_128::ssse3_key_schedule(const byte keyb[], size_t)
+void AES_128::ssse3_key_schedule(const uint8_t keyb[], size_t)
{
__m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81,
0x1F8391B9, 0xAF9DEEB6);
@@ -431,7 +431,7 @@ void AES_128::ssse3_key_schedule(const byte keyb[], size_t)
* AES-192 Encryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_192::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -454,7 +454,7 @@ void AES_192::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-192 Decryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_192::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -477,7 +477,7 @@ void AES_192::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-192 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_192::ssse3_key_schedule(const byte keyb[], size_t)
+void AES_192::ssse3_key_schedule(const uint8_t keyb[], size_t)
{
__m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81,
0x1F8391B9, 0xAF9DEEB6);
@@ -545,7 +545,7 @@ void AES_192::ssse3_key_schedule(const byte keyb[], size_t)
* AES-256 Encryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_256::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -568,7 +568,7 @@ void AES_256::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-256 Decryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_256::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -591,7 +591,7 @@ void AES_256::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-256 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_256::ssse3_key_schedule(const byte keyb[], size_t)
+void AES_256::ssse3_key_schedule(const uint8_t keyb[], size_t)
{
__m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81,
0x1F8391B9, 0xAF9DEEB6);
diff --git a/src/lib/block/block_cipher.h b/src/lib/block/block_cipher.h
index 2062160bc..ec080dbf0 100644
--- a/src/lib/block/block_cipher.h
+++ b/src/lib/block/block_cipher.h
@@ -77,7 +77,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out The byte array designated to hold the encrypted block.
* Must be of length block_size().
*/
- void encrypt(const byte in[], byte out[]) const
+ void encrypt(const uint8_t in[], uint8_t out[]) const
{ encrypt_n(in, out, 1); }
/**
@@ -87,7 +87,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out The byte array designated to hold the decrypted block.
* Must be of length block_size().
*/
- void decrypt(const byte in[], byte out[]) const
+ void decrypt(const uint8_t in[], uint8_t out[]) const
{ decrypt_n(in, out, 1); }
/**
@@ -96,7 +96,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* Must be of length block_size(). Will hold the result when the function
* has finished.
*/
- void encrypt(byte block[]) const { encrypt_n(block, block, 1); }
+ void encrypt(uint8_t block[]) const { encrypt_n(block, block, 1); }
/**
* Decrypt a block.
@@ -104,14 +104,14 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* Must be of length block_size(). Will hold the result when the function
* has finished.
*/
- void decrypt(byte block[]) const { decrypt_n(block, block, 1); }
+ void decrypt(uint8_t block[]) const { decrypt_n(block, block, 1); }
/**
* Encrypt one or more blocks
* @param block the input/output buffer (multiple of block_size())
*/
template<typename Alloc>
- void encrypt(std::vector<byte, Alloc>& block) const
+ void encrypt(std::vector<uint8_t, Alloc>& block) const
{
return encrypt_n(block.data(), block.data(), block.size() / block_size());
}
@@ -121,7 +121,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param block the input/output buffer (multiple of block_size())
*/
template<typename Alloc>
- void decrypt(std::vector<byte, Alloc>& block) const
+ void decrypt(std::vector<uint8_t, Alloc>& block) const
{
return decrypt_n(block.data(), block.data(), block.size() / block_size());
}
@@ -132,8 +132,8 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out the output buffer (same size as in)
*/
template<typename Alloc, typename Alloc2>
- void encrypt(const std::vector<byte, Alloc>& in,
- std::vector<byte, Alloc2>& out) const
+ void encrypt(const std::vector<uint8_t, Alloc>& in,
+ std::vector<uint8_t, Alloc2>& out) const
{
return encrypt_n(in.data(), out.data(), in.size() / block_size());
}
@@ -144,8 +144,8 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out the output buffer (same size as in)
*/
template<typename Alloc, typename Alloc2>
- void decrypt(const std::vector<byte, Alloc>& in,
- std::vector<byte, Alloc2>& out) const
+ void decrypt(const std::vector<uint8_t, Alloc>& in,
+ std::vector<uint8_t, Alloc2>& out) const
{
return decrypt_n(in.data(), out.data(), in.size() / block_size());
}
@@ -156,7 +156,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out the output buffer (same size as in)
* @param blocks the number of blocks to process
*/
- virtual void encrypt_n(const byte in[], byte out[],
+ virtual void encrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks) const = 0;
/**
@@ -165,7 +165,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out the output buffer (same size as in)
* @param blocks the number of blocks to process
*/
- virtual void decrypt_n(const byte in[], byte out[],
+ virtual void decrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks) const = 0;
/**
diff --git a/src/lib/block/blowfish/blowfish.cpp b/src/lib/block/blowfish/blowfish.cpp
index 69d345baa..17ac00a1f 100644
--- a/src/lib/block/blowfish/blowfish.cpp
+++ b/src/lib/block/blowfish/blowfish.cpp
@@ -12,12 +12,12 @@ namespace Botan {
namespace {
-const u32bit P_INIT[18] = {
+const uint32_t P_INIT[18] = {
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0,
0x082EFA98, 0xEC4E6C89, 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917, 0x9216D5D9, 0x8979FB1B };
-const u32bit S_INIT[1024] = {
+const uint32_t S_INIT[1024] = {
0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, 0xB8E1AFED, 0x6A267E96,
0xBA7C9045, 0xF12C7F99, 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E, 0x0D95748F, 0x728EB658,
@@ -195,16 +195,16 @@ const u32bit S_INIT[1024] = {
/*
* Blowfish Encryption
*/
-void Blowfish::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Blowfish::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u32bit* S1 = &m_S[0];
- const u32bit* S2 = &m_S[256];
- const u32bit* S3 = &m_S[512];
- const u32bit* S4 = &m_S[768];
+ const uint32_t* S1 = &m_S[0];
+ const uint32_t* S2 = &m_S[256];
+ const uint32_t* S3 = &m_S[512];
+ const uint32_t* S4 = &m_S[768];
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*i, L, R);
for(size_t j = 0; j != 16; j += 2)
@@ -227,16 +227,16 @@ void Blowfish::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Blowfish Decryption
*/
-void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Blowfish::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u32bit* S1 = &m_S[0];
- const u32bit* S2 = &m_S[256];
- const u32bit* S3 = &m_S[512];
- const u32bit* S4 = &m_S[768];
+ const uint32_t* S1 = &m_S[0];
+ const uint32_t* S2 = &m_S[256];
+ const uint32_t* S3 = &m_S[512];
+ const uint32_t* S4 = &m_S[768];
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*i, L, R);
for(size_t j = 17; j != 1; j -= 2)
@@ -259,7 +259,7 @@ void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Blowfish Key Schedule
*/
-void Blowfish::key_schedule(const byte key[], size_t length)
+void Blowfish::key_schedule(const uint8_t key[], size_t length)
{
m_P.resize(18);
copy_mem(m_P.data(), P_INIT, 18);
@@ -267,20 +267,20 @@ void Blowfish::key_schedule(const byte key[], size_t length)
m_S.resize(1024);
copy_mem(m_S.data(), S_INIT, 1024);
- const byte null_salt[16] = { 0 };
+ const uint8_t null_salt[16] = { 0 };
key_expansion(key, length, null_salt);
}
-void Blowfish::key_expansion(const byte key[],
+void Blowfish::key_expansion(const uint8_t key[],
size_t length,
- const byte salt[16])
+ const uint8_t salt[16])
{
for(size_t i = 0, j = 0; i != 18; ++i, j += 4)
- m_P[i] ^= make_u32bit(key[(j ) % length], key[(j+1) % length],
+ m_P[i] ^= make_uint32(key[(j ) % length], key[(j+1) % length],
key[(j+2) % length], key[(j+3) % length]);
- u32bit L = 0, R = 0;
+ uint32_t L = 0, R = 0;
generate_sbox(m_P, L, R, salt, 0);
generate_sbox(m_S, L, R, salt, 2);
}
@@ -288,8 +288,8 @@ void Blowfish::key_expansion(const byte key[],
/*
* Modified key schedule used for bcrypt password hashing
*/
-void Blowfish::eks_key_schedule(const byte key[], size_t length,
- const byte salt[16], size_t workfactor)
+void Blowfish::eks_key_schedule(const uint8_t key[], size_t length,
+ const uint8_t salt[16], size_t workfactor)
{
// Truncate longer passwords to the 56 byte limit Blowfish enforces
length = std::min<size_t>(length, 55);
@@ -314,7 +314,7 @@ void Blowfish::eks_key_schedule(const byte key[], size_t length,
key_expansion(key, length, salt);
- const byte null_salt[16] = { 0 };
+ const uint8_t null_salt[16] = { 0 };
const size_t rounds = static_cast<size_t>(1) << workfactor;
for(size_t r = 0; r != rounds; ++r)
@@ -327,20 +327,20 @@ void Blowfish::eks_key_schedule(const byte key[], size_t length,
/*
* Generate one of the Sboxes
*/
-void Blowfish::generate_sbox(secure_vector<u32bit>& box,
- u32bit& L, u32bit& R,
- const byte salt[16],
+void Blowfish::generate_sbox(secure_vector<uint32_t>& box,
+ uint32_t& L, uint32_t& R,
+ const uint8_t salt[16],
size_t salt_off) const
{
- const u32bit* S1 = &m_S[0];
- const u32bit* S2 = &m_S[256];
- const u32bit* S3 = &m_S[512];
- const u32bit* S4 = &m_S[768];
+ const uint32_t* S1 = &m_S[0];
+ const uint32_t* S2 = &m_S[256];
+ const uint32_t* S3 = &m_S[512];
+ const uint32_t* S4 = &m_S[768];
for(size_t i = 0; i != box.size(); i += 2)
{
- L ^= load_be<u32bit>(salt, (i + salt_off) % 4);
- R ^= load_be<u32bit>(salt, (i + salt_off + 1) % 4);
+ L ^= load_be<uint32_t>(salt, (i + salt_off) % 4);
+ R ^= load_be<uint32_t>(salt, (i + salt_off + 1) % 4);
for(size_t j = 0; j != 16; j += 2)
{
@@ -353,7 +353,7 @@ void Blowfish::generate_sbox(secure_vector<u32bit>& box,
S3[get_byte(2, R)]) + S4[get_byte(3, R)];
}
- u32bit T = R; R = L ^ m_P[16]; L = T ^ m_P[17];
+ uint32_t T = R; R = L ^ m_P[16]; L = T ^ m_P[17];
box[i] = L;
box[i+1] = R;
}
diff --git a/src/lib/block/blowfish/blowfish.h b/src/lib/block/blowfish/blowfish.h
index 5aa35f337..690b9c400 100644
--- a/src/lib/block/blowfish/blowfish.h
+++ b/src/lib/block/blowfish/blowfish.h
@@ -18,31 +18,31 @@ namespace Botan {
class BOTAN_DLL Blowfish final : public Block_Cipher_Fixed_Params<8, 1, 56>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
/**
* Modified EKSBlowfish key schedule, used for bcrypt password hashing
*/
- void eks_key_schedule(const byte key[], size_t key_length,
- const byte salt[16], size_t workfactor);
+ void eks_key_schedule(const uint8_t key[], size_t key_length,
+ const uint8_t salt[16], size_t workfactor);
void clear() override;
std::string name() const override { return "Blowfish"; }
BlockCipher* clone() const override { return new Blowfish; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- void key_expansion(const byte key[],
+ void key_expansion(const uint8_t key[],
size_t key_length,
- const byte salt[16]);
+ const uint8_t salt[16]);
- void generate_sbox(secure_vector<u32bit>& box,
- u32bit& L, u32bit& R,
- const byte salt[16],
+ void generate_sbox(secure_vector<uint32_t>& box,
+ uint32_t& L, uint32_t& R,
+ const uint8_t salt[16],
size_t salt_off) const;
- secure_vector<u32bit> m_S, m_P;
+ secure_vector<uint32_t> m_S, m_P;
};
}
diff --git a/src/lib/block/camellia/camellia.cpp b/src/lib/block/camellia/camellia.cpp
index 5ac13b9ab..c4a186738 100644
--- a/src/lib/block/camellia/camellia.cpp
+++ b/src/lib/block/camellia/camellia.cpp
@@ -12,7 +12,7 @@ namespace Botan {
namespace {
-const u64bit Camellia_SBOX1[256] = {
+const uint64_t Camellia_SBOX1[256] = {
0x7070700070000070, 0x8282820082000082, 0x2C2C2C002C00002C, 0xECECEC00EC0000EC,
0xB3B3B300B30000B3, 0x2727270027000027, 0xC0C0C000C00000C0, 0xE5E5E500E50000E5,
0xE4E4E400E40000E4, 0x8585850085000085, 0x5757570057000057, 0x3535350035000035,
@@ -78,7 +78,7 @@ const u64bit Camellia_SBOX1[256] = {
0x1515150015000015, 0xE3E3E300E30000E3, 0xADADAD00AD0000AD, 0xF4F4F400F40000F4,
0x7777770077000077, 0xC7C7C700C70000C7, 0x8080800080000080, 0x9E9E9E009E00009E };
-const u64bit Camellia_SBOX2[256] = {
+const uint64_t Camellia_SBOX2[256] = {
0x00E0E0E0E0E00000, 0x0005050505050000, 0x0058585858580000, 0x00D9D9D9D9D90000,
0x0067676767670000, 0x004E4E4E4E4E0000, 0x0081818181810000, 0x00CBCBCBCBCB0000,
0x00C9C9C9C9C90000, 0x000B0B0B0B0B0000, 0x00AEAEAEAEAE0000, 0x006A6A6A6A6A0000,
@@ -144,7 +144,7 @@ const u64bit Camellia_SBOX2[256] = {
0x002A2A2A2A2A0000, 0x00C7C7C7C7C70000, 0x005B5B5B5B5B0000, 0x00E9E9E9E9E90000,
0x00EEEEEEEEEE0000, 0x008F8F8F8F8F0000, 0x0001010101010000, 0x003D3D3D3D3D0000 };
-const u64bit Camellia_SBOX3[256] = {
+const uint64_t Camellia_SBOX3[256] = {
0x3800383800383800, 0x4100414100414100, 0x1600161600161600, 0x7600767600767600,
0xD900D9D900D9D900, 0x9300939300939300, 0x6000606000606000, 0xF200F2F200F2F200,
0x7200727200727200, 0xC200C2C200C2C200, 0xAB00ABAB00ABAB00, 0x9A009A9A009A9A00,
@@ -210,7 +210,7 @@ const u64bit Camellia_SBOX3[256] = {
0x8A008A8A008A8A00, 0xF100F1F100F1F100, 0xD600D6D600D6D600, 0x7A007A7A007A7A00,
0xBB00BBBB00BBBB00, 0xE300E3E300E3E300, 0x4000404000404000, 0x4F004F4F004F4F00 };
-const u64bit Camellia_SBOX4[256] = {
+const uint64_t Camellia_SBOX4[256] = {
0x7070007000007070, 0x2C2C002C00002C2C, 0xB3B300B30000B3B3, 0xC0C000C00000C0C0,
0xE4E400E40000E4E4, 0x5757005700005757, 0xEAEA00EA0000EAEA, 0xAEAE00AE0000AEAE,
0x2323002300002323, 0x6B6B006B00006B6B, 0x4545004500004545, 0xA5A500A50000A5A5,
@@ -276,7 +276,7 @@ const u64bit Camellia_SBOX4[256] = {
0x2828002800002828, 0x7B7B007B00007B7B, 0xC9C900C90000C9C9, 0xC1C100C10000C1C1,
0xE3E300E30000E3E3, 0xF4F400F40000F4F4, 0xC7C700C70000C7C7, 0x9E9E009E00009E9E };
-const u64bit Camellia_SBOX5[256] = {
+const uint64_t Camellia_SBOX5[256] = {
0x00E0E0E000E0E0E0, 0x0005050500050505, 0x0058585800585858, 0x00D9D9D900D9D9D9,
0x0067676700676767, 0x004E4E4E004E4E4E, 0x0081818100818181, 0x00CBCBCB00CBCBCB,
0x00C9C9C900C9C9C9, 0x000B0B0B000B0B0B, 0x00AEAEAE00AEAEAE, 0x006A6A6A006A6A6A,
@@ -342,7 +342,7 @@ const u64bit Camellia_SBOX5[256] = {
0x002A2A2A002A2A2A, 0x00C7C7C700C7C7C7, 0x005B5B5B005B5B5B, 0x00E9E9E900E9E9E9,
0x00EEEEEE00EEEEEE, 0x008F8F8F008F8F8F, 0x0001010100010101, 0x003D3D3D003D3D3D };
-const u64bit Camellia_SBOX6[256] = {
+const uint64_t Camellia_SBOX6[256] = {
0x3800383838003838, 0x4100414141004141, 0x1600161616001616, 0x7600767676007676,
0xD900D9D9D900D9D9, 0x9300939393009393, 0x6000606060006060, 0xF200F2F2F200F2F2,
0x7200727272007272, 0xC200C2C2C200C2C2, 0xAB00ABABAB00ABAB, 0x9A009A9A9A009A9A,
@@ -408,7 +408,7 @@ const u64bit Camellia_SBOX6[256] = {
0x8A008A8A8A008A8A, 0xF100F1F1F100F1F1, 0xD600D6D6D600D6D6, 0x7A007A7A7A007A7A,
0xBB00BBBBBB00BBBB, 0xE300E3E3E300E3E3, 0x4000404040004040, 0x4F004F4F4F004F4F };
-const u64bit Camellia_SBOX7[256] = {
+const uint64_t Camellia_SBOX7[256] = {
0x7070007070700070, 0x2C2C002C2C2C002C, 0xB3B300B3B3B300B3, 0xC0C000C0C0C000C0,
0xE4E400E4E4E400E4, 0x5757005757570057, 0xEAEA00EAEAEA00EA, 0xAEAE00AEAEAE00AE,
0x2323002323230023, 0x6B6B006B6B6B006B, 0x4545004545450045, 0xA5A500A5A5A500A5,
@@ -474,7 +474,7 @@ const u64bit Camellia_SBOX7[256] = {
0x2828002828280028, 0x7B7B007B7B7B007B, 0xC9C900C9C9C900C9, 0xC1C100C1C1C100C1,
0xE3E300E3E3E300E3, 0xF4F400F4F4F400F4, 0xC7C700C7C7C700C7, 0x9E9E009E9E9E009E };
-const u64bit Camellia_SBOX8[256] = {
+const uint64_t Camellia_SBOX8[256] = {
0x7070700070707000, 0x8282820082828200, 0x2C2C2C002C2C2C00, 0xECECEC00ECECEC00,
0xB3B3B300B3B3B300, 0x2727270027272700, 0xC0C0C000C0C0C000, 0xE5E5E500E5E5E500,
0xE4E4E400E4E4E400, 0x8585850085858500, 0x5757570057575700, 0x3535350035353500,
@@ -546,9 +546,9 @@ namespace Camellia_F {
* We use the slow byte-wise version of F in the first and last rounds
* to help protect against timing attacks
*/
-u64bit F_SLOW(u64bit v, u64bit K)
+uint64_t F_SLOW(uint64_t v, uint64_t K)
{
- static const byte SBOX[256] = {
+ static const uint8_t SBOX[256] = {
0x70, 0x82, 0x2C, 0xEC, 0xB3, 0x27, 0xC0, 0xE5, 0xE4, 0x85, 0x57,
0x35, 0xEA, 0x0C, 0xAE, 0x41, 0x23, 0xEF, 0x6B, 0x93, 0x45, 0x19,
0xA5, 0x21, 0xED, 0x0E, 0x4F, 0x4E, 0x1D, 0x65, 0x92, 0xBD, 0x86,
@@ -574,32 +574,32 @@ u64bit F_SLOW(u64bit v, u64bit K)
0xD3, 0x7B, 0xBB, 0xC9, 0x43, 0xC1, 0x15, 0xE3, 0xAD, 0xF4, 0x77,
0xC7, 0x80, 0x9E };
- const u64bit x = v ^ K;
-
- const byte t1 = SBOX[get_byte(0, x)];
- const byte t2 = rotate_left(SBOX[get_byte(1, x)], 1);
- const byte t3 = rotate_left(SBOX[get_byte(2, x)], 7);
- const byte t4 = SBOX[rotate_left(get_byte(3, x), 1)];
- const byte t5 = rotate_left(SBOX[get_byte(4, x)], 1);
- const byte t6 = rotate_left(SBOX[get_byte(5, x)], 7);
- const byte t7 = SBOX[rotate_left(get_byte(6, x), 1)];
- const byte t8 = SBOX[get_byte(7, x)];
-
- const byte y1 = t1 ^ t3 ^ t4 ^ t6 ^ t7 ^ t8;
- const byte y2 = t1 ^ t2 ^ t4 ^ t5 ^ t7 ^ t8;
- const byte y3 = t1 ^ t2 ^ t3 ^ t5 ^ t6 ^ t8;
- const byte y4 = t2 ^ t3 ^ t4 ^ t5 ^ t6 ^ t7;
- const byte y5 = t1 ^ t2 ^ t6 ^ t7 ^ t8;
- const byte y6 = t2 ^ t3 ^ t5 ^ t7 ^ t8;
- const byte y7 = t3 ^ t4 ^ t5 ^ t6 ^ t8;
- const byte y8 = t1 ^ t4 ^ t5 ^ t6 ^ t7;
-
- return make_u64bit(y1, y2, y3, y4, y5, y6, y7, y8);
+ const uint64_t x = v ^ K;
+
+ const uint8_t t1 = SBOX[get_byte(0, x)];
+ const uint8_t t2 = rotate_left(SBOX[get_byte(1, x)], 1);
+ const uint8_t t3 = rotate_left(SBOX[get_byte(2, x)], 7);
+ const uint8_t t4 = SBOX[rotate_left(get_byte(3, x), 1)];
+ const uint8_t t5 = rotate_left(SBOX[get_byte(4, x)], 1);
+ const uint8_t t6 = rotate_left(SBOX[get_byte(5, x)], 7);
+ const uint8_t t7 = SBOX[rotate_left(get_byte(6, x), 1)];
+ const uint8_t t8 = SBOX[get_byte(7, x)];
+
+ const uint8_t y1 = t1 ^ t3 ^ t4 ^ t6 ^ t7 ^ t8;
+ const uint8_t y2 = t1 ^ t2 ^ t4 ^ t5 ^ t7 ^ t8;
+ const uint8_t y3 = t1 ^ t2 ^ t3 ^ t5 ^ t6 ^ t8;
+ const uint8_t y4 = t2 ^ t3 ^ t4 ^ t5 ^ t6 ^ t7;
+ const uint8_t y5 = t1 ^ t2 ^ t6 ^ t7 ^ t8;
+ const uint8_t y6 = t2 ^ t3 ^ t5 ^ t7 ^ t8;
+ const uint8_t y7 = t3 ^ t4 ^ t5 ^ t6 ^ t8;
+ const uint8_t y8 = t1 ^ t4 ^ t5 ^ t6 ^ t7;
+
+ return make_uint64(y1, y2, y3, y4, y5, y6, y7, y8);
}
-inline u64bit F(u64bit v, u64bit K)
+inline uint64_t F(uint64_t v, uint64_t K)
{
- const u64bit x = v ^ K;
+ const uint64_t x = v ^ K;
return Camellia_SBOX1[get_byte(0, x)] ^
Camellia_SBOX2[get_byte(1, x)] ^
@@ -611,46 +611,46 @@ inline u64bit F(u64bit v, u64bit K)
Camellia_SBOX8[get_byte(7, x)];
}
-inline u64bit FL(u64bit v, u64bit K)
+inline uint64_t FL(uint64_t v, uint64_t K)
{
- u32bit x1 = (v >> 32);
- u32bit x2 = (v & 0xFFFFFFFF);
+ uint32_t x1 = (v >> 32);
+ uint32_t x2 = (v & 0xFFFFFFFF);
- const u32bit k1 = (K >> 32);
- const u32bit k2 = (K & 0xFFFFFFFF);
+ const uint32_t k1 = (K >> 32);
+ const uint32_t k2 = (K & 0xFFFFFFFF);
x2 ^= rotate_left(x1 & k1, 1);
x1 ^= (x2 | k2);
- return ((static_cast<u64bit>(x1) << 32) | x2);
+ return ((static_cast<uint64_t>(x1) << 32) | x2);
}
-inline u64bit FLINV(u64bit v, u64bit K)
+inline uint64_t FLINV(uint64_t v, uint64_t K)
{
- u32bit x1 = (v >> 32);
- u32bit x2 = (v & 0xFFFFFFFF);
+ uint32_t x1 = (v >> 32);
+ uint32_t x2 = (v & 0xFFFFFFFF);
- const u32bit k1 = (K >> 32);
- const u32bit k2 = (K & 0xFFFFFFFF);
+ const uint32_t k1 = (K >> 32);
+ const uint32_t k2 = (K & 0xFFFFFFFF);
x1 ^= (x2 | k2);
x2 ^= rotate_left(x1 & k1, 1);
- return ((static_cast<u64bit>(x1) << 32) | x2);
+ return ((static_cast<uint64_t>(x1) << 32) | x2);
}
/*
* Camellia Encryption
*/
-void encrypt(const byte in[], byte out[], size_t blocks,
- const secure_vector<u64bit>& SK, const size_t rounds)
+void encrypt(const uint8_t in[], uint8_t out[], size_t blocks,
+ const secure_vector<uint64_t>& SK, const size_t rounds)
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit D1, D2;
+ uint64_t D1, D2;
load_be(in + 16*i, D1, D2);
- const u64bit* K = SK.data();
+ const uint64_t* K = SK.data();
D1 ^= *K++;
D2 ^= *K++;
@@ -683,15 +683,15 @@ void encrypt(const byte in[], byte out[], size_t blocks,
/*
* Camellia Decryption
*/
-void decrypt(const byte in[], byte out[], size_t blocks,
- const secure_vector<u64bit>& SK, const size_t rounds)
+void decrypt(const uint8_t in[], uint8_t out[], size_t blocks,
+ const secure_vector<uint64_t>& SK, const size_t rounds)
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit D1, D2;
+ uint64_t D1, D2;
load_be(in + 16*i, D1, D2);
- const u64bit* K = &SK[SK.size()-1];
+ const uint64_t* K = &SK[SK.size()-1];
D2 ^= *K--;
D1 ^= *K--;
@@ -721,12 +721,12 @@ void decrypt(const byte in[], byte out[], size_t blocks,
}
}
-u64bit left_rot_hi(u64bit h, u64bit l, size_t shift)
+uint64_t left_rot_hi(uint64_t h, uint64_t l, size_t shift)
{
return (h << shift) | ((l >> (64-shift)));
}
-u64bit left_rot_lo(u64bit h, u64bit l, size_t shift)
+uint64_t left_rot_lo(uint64_t h, uint64_t l, size_t shift)
{
return (h >> (64-shift)) | (l << shift);
}
@@ -734,24 +734,24 @@ u64bit left_rot_lo(u64bit h, u64bit l, size_t shift)
/*
* Camellia Key Schedule
*/
-void key_schedule(secure_vector<u64bit>& SK, const byte key[], size_t length)
+void key_schedule(secure_vector<uint64_t>& SK, const uint8_t key[], size_t length)
{
- const u64bit Sigma1 = 0xA09E667F3BCC908B;
- const u64bit Sigma2 = 0xB67AE8584CAA73B2;
- const u64bit Sigma3 = 0xC6EF372FE94F82BE;
- const u64bit Sigma4 = 0x54FF53A5F1D36F1C;
- const u64bit Sigma5 = 0x10E527FADE682D1D;
- const u64bit Sigma6 = 0xB05688C2B3E6C1FD;
-
- const u64bit KL_H = load_be<u64bit>(key, 0);
- const u64bit KL_L = load_be<u64bit>(key, 1);
-
- const u64bit KR_H = (length >= 24) ? load_be<u64bit>(key, 2) : 0;
- const u64bit KR_L =
- (length == 32) ? load_be<u64bit>(key, 3) : ((length == 24) ? ~KR_H : 0);
-
- u64bit D1 = KL_H ^ KR_H;
- u64bit D2 = KL_L ^ KR_L;
+ const uint64_t Sigma1 = 0xA09E667F3BCC908B;
+ const uint64_t Sigma2 = 0xB67AE8584CAA73B2;
+ const uint64_t Sigma3 = 0xC6EF372FE94F82BE;
+ const uint64_t Sigma4 = 0x54FF53A5F1D36F1C;
+ const uint64_t Sigma5 = 0x10E527FADE682D1D;
+ const uint64_t Sigma6 = 0xB05688C2B3E6C1FD;
+
+ const uint64_t KL_H = load_be<uint64_t>(key, 0);
+ const uint64_t KL_L = load_be<uint64_t>(key, 1);
+
+ const uint64_t KR_H = (length >= 24) ? load_be<uint64_t>(key, 2) : 0;
+ const uint64_t KR_L =
+ (length == 32) ? load_be<uint64_t>(key, 3) : ((length == 24) ? ~KR_H : 0);
+
+ uint64_t D1 = KL_H ^ KR_H;
+ uint64_t D2 = KL_L ^ KR_L;
D2 ^= F(D1, Sigma1);
D1 ^= F(D2, Sigma2);
D1 ^= KL_H;
@@ -759,16 +759,16 @@ void key_schedule(secure_vector<u64bit>& SK, const byte key[], size_t length)
D2 ^= F(D1, Sigma3);
D1 ^= F(D2, Sigma4);
- const u64bit KA_H = D1;
- const u64bit KA_L = D2;
+ const uint64_t KA_H = D1;
+ const uint64_t KA_L = D2;
D1 = KA_H ^ KR_H;
D2 = KA_L ^ KR_L;
D2 ^= F(D1, Sigma5);
D1 ^= F(D2, Sigma6);
- const u64bit KB_H = D1;
- const u64bit KB_L = D2;
+ const uint64_t KB_H = D1;
+ const uint64_t KB_L = D2;
if(length == 16)
{
@@ -852,47 +852,47 @@ void key_schedule(secure_vector<u64bit>& SK, const byte key[], size_t length)
}
-void Camellia_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_128::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::encrypt(in, out, blocks, m_SK, 9);
}
-void Camellia_192::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_192::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::encrypt(in, out, blocks, m_SK, 12);
}
-void Camellia_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_256::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::encrypt(in, out, blocks, m_SK, 12);
}
-void Camellia_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_128::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::decrypt(in, out, blocks, m_SK, 9);
}
-void Camellia_192::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_192::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::decrypt(in, out, blocks, m_SK, 12);
}
-void Camellia_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_256::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::decrypt(in, out, blocks, m_SK, 12);
}
-void Camellia_128::key_schedule(const byte key[], size_t length)
+void Camellia_128::key_schedule(const uint8_t key[], size_t length)
{
Camellia_F::key_schedule(m_SK, key, length);
}
-void Camellia_192::key_schedule(const byte key[], size_t length)
+void Camellia_192::key_schedule(const uint8_t key[], size_t length)
{
Camellia_F::key_schedule(m_SK, key, length);
}
-void Camellia_256::key_schedule(const byte key[], size_t length)
+void Camellia_256::key_schedule(const uint8_t key[], size_t length)
{
Camellia_F::key_schedule(m_SK, key, length);
}
diff --git a/src/lib/block/camellia/camellia.h b/src/lib/block/camellia/camellia.h
index 71aa95ac6..736315f3a 100644
--- a/src/lib/block/camellia/camellia.h
+++ b/src/lib/block/camellia/camellia.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL Camellia_128 final : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "Camellia-128"; }
BlockCipher* clone() const override { return new Camellia_128; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u64bit> m_SK;
+ secure_vector<uint64_t> m_SK;
};
/**
@@ -36,16 +36,16 @@ class BOTAN_DLL Camellia_128 final : public Block_Cipher_Fixed_Params<16, 16>
class BOTAN_DLL Camellia_192 final : public Block_Cipher_Fixed_Params<16, 24>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "Camellia-192"; }
BlockCipher* clone() const override { return new Camellia_192; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u64bit> m_SK;
+ secure_vector<uint64_t> m_SK;
};
/**
@@ -54,16 +54,16 @@ class BOTAN_DLL Camellia_192 final : public Block_Cipher_Fixed_Params<16, 24>
class BOTAN_DLL Camellia_256 final : public Block_Cipher_Fixed_Params<16, 32>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "Camellia-256"; }
BlockCipher* clone() const override { return new Camellia_256; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u64bit> m_SK;
+ secure_vector<uint64_t> m_SK;
};
}
diff --git a/src/lib/block/cascade/cascade.cpp b/src/lib/block/cascade/cascade.cpp
index 98e862de9..e54d3e5b5 100644
--- a/src/lib/block/cascade/cascade.cpp
+++ b/src/lib/block/cascade/cascade.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-void Cascade_Cipher::encrypt_n(const byte in[], byte out[],
+void Cascade_Cipher::encrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks) const
{
size_t c1_blocks = blocks * (block_size() / m_cipher1->block_size());
@@ -19,7 +19,7 @@ void Cascade_Cipher::encrypt_n(const byte in[], byte out[],
m_cipher2->encrypt_n(out, out, c2_blocks);
}
-void Cascade_Cipher::decrypt_n(const byte in[], byte out[],
+void Cascade_Cipher::decrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks) const
{
size_t c1_blocks = blocks * (block_size() / m_cipher1->block_size());
@@ -29,9 +29,9 @@ void Cascade_Cipher::decrypt_n(const byte in[], byte out[],
m_cipher1->decrypt_n(out, out, c1_blocks);
}
-void Cascade_Cipher::key_schedule(const byte key[], size_t)
+void Cascade_Cipher::key_schedule(const uint8_t key[], size_t)
{
- const byte* key2 = key + m_cipher1->maximum_keylength();
+ const uint8_t* key2 = key + m_cipher1->maximum_keylength();
m_cipher1->set_key(key , m_cipher1->maximum_keylength());
m_cipher2->set_key(key2, m_cipher2->maximum_keylength());
diff --git a/src/lib/block/cascade/cascade.h b/src/lib/block/cascade/cascade.h
index aa7bd0421..1ab81b9b5 100644
--- a/src/lib/block/cascade/cascade.h
+++ b/src/lib/block/cascade/cascade.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Cascade_Cipher final : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
size_t block_size() const override { return m_block; }
@@ -43,7 +43,7 @@ class BOTAN_DLL Cascade_Cipher final : public BlockCipher
Cascade_Cipher(const Cascade_Cipher&) = delete;
Cascade_Cipher& operator=(const Cascade_Cipher&) = delete;
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
size_t m_block;
std::unique_ptr<BlockCipher> m_cipher1, m_cipher2;
diff --git a/src/lib/block/cast/cast128.cpp b/src/lib/block/cast/cast128.cpp
index 96c4f45a7..d955dfeef 100644
--- a/src/lib/block/cast/cast128.cpp
+++ b/src/lib/block/cast/cast128.cpp
@@ -16,9 +16,9 @@ namespace {
/*
* CAST-128 Round Type 1
*/
-inline void R1(u32bit& L, u32bit R, u32bit MK, byte RK)
+inline void R1(uint32_t& L, uint32_t R, uint32_t MK, uint8_t RK)
{
- u32bit T = rotate_left(MK + R, RK);
+ uint32_t T = rotate_left(MK + R, RK);
L ^= (CAST_SBOX1[get_byte(0, T)] ^ CAST_SBOX2[get_byte(1, T)]) -
CAST_SBOX3[get_byte(2, T)] + CAST_SBOX4[get_byte(3, T)];
}
@@ -26,9 +26,9 @@ inline void R1(u32bit& L, u32bit R, u32bit MK, byte RK)
/*
* CAST-128 Round Type 2
*/
-inline void R2(u32bit& L, u32bit R, u32bit MK, byte RK)
+inline void R2(uint32_t& L, uint32_t R, uint32_t MK, uint8_t RK)
{
- u32bit T = rotate_left(MK ^ R, RK);
+ uint32_t T = rotate_left(MK ^ R, RK);
L ^= (CAST_SBOX1[get_byte(0, T)] - CAST_SBOX2[get_byte(1, T)] +
CAST_SBOX3[get_byte(2, T)]) ^ CAST_SBOX4[get_byte(3, T)];
}
@@ -36,9 +36,9 @@ inline void R2(u32bit& L, u32bit R, u32bit MK, byte RK)
/*
* CAST-128 Round Type 3
*/
-inline void R3(u32bit& L, u32bit R, u32bit MK, byte RK)
+inline void R3(uint32_t& L, uint32_t R, uint32_t MK, uint8_t RK)
{
- u32bit T = rotate_left(MK - R, RK);
+ uint32_t T = rotate_left(MK - R, RK);
L ^= ((CAST_SBOX1[get_byte(0, T)] + CAST_SBOX2[get_byte(1, T)]) ^
CAST_SBOX3[get_byte(2, T)]) - CAST_SBOX4[get_byte(3, T)];
}
@@ -48,11 +48,11 @@ inline void R3(u32bit& L, u32bit R, u32bit MK, byte RK)
/*
* CAST-128 Encryption
*/
-void CAST_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void CAST_128::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*i, L, R);
R1(L, R, m_MK[ 0], m_RK[ 0]);
@@ -79,11 +79,11 @@ void CAST_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* CAST-128 Decryption
*/
-void CAST_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void CAST_128::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*i, L, R);
R1(L, R, m_MK[15], m_RK[15]);
@@ -110,18 +110,18 @@ void CAST_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* CAST-128 Key Schedule
*/
-void CAST_128::key_schedule(const byte key[], size_t length)
+void CAST_128::key_schedule(const uint8_t key[], size_t length)
{
m_MK.resize(48);
m_RK.resize(48);
- secure_vector<u32bit> X(4);
+ secure_vector<uint32_t> X(4);
for(size_t i = 0; i != length; ++i)
X[i/4] = (X[i/4] << 8) + key[i];
cast_ks(m_MK, X);
- secure_vector<u32bit> RK32(48);
+ secure_vector<uint32_t> RK32(48);
cast_ks(RK32, X);
for(size_t i = 0; i != 16; ++i)
@@ -137,10 +137,10 @@ void CAST_128::clear()
/*
* S-Box Based Key Expansion
*/
-void CAST_128::cast_ks(secure_vector<u32bit>& K,
- secure_vector<u32bit>& X)
+void CAST_128::cast_ks(secure_vector<uint32_t>& K,
+ secure_vector<uint32_t>& X)
{
- static const u32bit S5[256] = {
+ static const uint32_t S5[256] = {
0x7EC90C04, 0x2C6E74B9, 0x9B0E66DF, 0xA6337911, 0xB86A7FFF, 0x1DD358F5,
0x44DD9D44, 0x1731167F, 0x08FBF1FA, 0xE7F511CC, 0xD2051B00, 0x735ABA00,
0x2AB722D8, 0x386381CB, 0xACF6243A, 0x69BEFD7A, 0xE6A2E77F, 0xF0C720CD,
@@ -185,7 +185,7 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K,
0x34010718, 0xBB30CAB8, 0xE822FE15, 0x88570983, 0x750E6249, 0xDA627E55,
0x5E76FFA8, 0xB1534546, 0x6D47DE08, 0xEFE9E7D4 };
- static const u32bit S6[256] = {
+ static const uint32_t S6[256] = {
0xF6FA8F9D, 0x2CAC6CE1, 0x4CA34867, 0xE2337F7C, 0x95DB08E7, 0x016843B4,
0xECED5CBC, 0x325553AC, 0xBF9F0960, 0xDFA1E2ED, 0x83F0579D, 0x63ED86B9,
0x1AB6A6B8, 0xDE5EBE39, 0xF38FF732, 0x8989B138, 0x33F14961, 0xC01937BD,
@@ -230,7 +230,7 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K,
0xB0E93524, 0xBEBB8FBD, 0xA2D762CF, 0x49C92F54, 0x38B5F331, 0x7128A454,
0x48392905, 0xA65B1DB8, 0x851C97BD, 0xD675CF2F };
- static const u32bit S7[256] = {
+ static const uint32_t S7[256] = {
0x85E04019, 0x332BF567, 0x662DBFFF, 0xCFC65693, 0x2A8D7F6F, 0xAB9BC912,
0xDE6008A1, 0x2028DA1F, 0x0227BCE7, 0x4D642916, 0x18FAC300, 0x50F18B82,
0x2CB2CB11, 0xB232E75C, 0x4B3695F2, 0xB28707DE, 0xA05FBCF6, 0xCD4181E9,
@@ -275,7 +275,7 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K,
0xC3C0BDAE, 0x4958C24C, 0x518F36B2, 0x84B1D370, 0x0FEDCE83, 0x878DDADA,
0xF2A279C7, 0x94E01BE8, 0x90716F4B, 0x954B8AA3 };
- static const u32bit S8[256] = {
+ static const uint32_t S8[256] = {
0xE216300D, 0xBBDDFFFC, 0xA7EBDABD, 0x35648095, 0x7789F8B7, 0xE6C1121B,
0x0E241600, 0x052CE8B5, 0x11A9CFB0, 0xE5952F11, 0xECE7990A, 0x9386D174,
0x2A42931C, 0x76E38111, 0xB12DEF3A, 0x37DDDDFC, 0xDE9ADEB1, 0x0A0CC32C,
@@ -323,13 +323,13 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K,
class ByteReader
{
public:
- byte operator()(size_t i) { return (m_X[i/4] >> (8*(3 - (i%4)))); }
- explicit ByteReader(const u32bit* x) : m_X(x) {}
+ uint8_t operator()(size_t i) { return (m_X[i/4] >> (8*(3 - (i%4)))); }
+ explicit ByteReader(const uint32_t* x) : m_X(x) {}
private:
- const u32bit* m_X;
+ const uint32_t* m_X;
};
- secure_vector<u32bit> Z(4);
+ secure_vector<uint32_t> Z(4);
ByteReader x(X.data()), z(Z.data());
Z[0] = X[0] ^ S5[x(13)] ^ S6[x(15)] ^ S7[x(12)] ^ S8[x(14)] ^ S7[x( 8)];
diff --git a/src/lib/block/cast/cast128.h b/src/lib/block/cast/cast128.h
index 2782e96b9..96e543aed 100644
--- a/src/lib/block/cast/cast128.h
+++ b/src/lib/block/cast/cast128.h
@@ -18,21 +18,21 @@ namespace Botan {
class BOTAN_DLL CAST_128 final : public Block_Cipher_Fixed_Params<8, 11, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "CAST-128"; }
BlockCipher* clone() const override { return new CAST_128; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- static void cast_ks(secure_vector<u32bit>& ks,
- secure_vector<u32bit>& user_key);
+ static void cast_ks(secure_vector<uint32_t>& ks,
+ secure_vector<uint32_t>& user_key);
- secure_vector<u32bit> m_MK;
- secure_vector<byte> m_RK;
+ secure_vector<uint32_t> m_MK;
+ secure_vector<uint8_t> m_RK;
};
}
diff --git a/src/lib/block/cast/cast256.cpp b/src/lib/block/cast/cast256.cpp
index 637fdfee2..a4a7dbd36 100644
--- a/src/lib/block/cast/cast256.cpp
+++ b/src/lib/block/cast/cast256.cpp
@@ -16,9 +16,9 @@ namespace {
/*
* CAST-256 Round Type 1
*/
-void round1(u32bit& out, u32bit in, u32bit mask, u32bit rot)
+void round1(uint32_t& out, uint32_t in, uint32_t mask, uint32_t rot)
{
- u32bit temp = rotate_left(mask + in, rot);
+ uint32_t temp = rotate_left(mask + in, rot);
out ^= (CAST_SBOX1[get_byte(0, temp)] ^ CAST_SBOX2[get_byte(1, temp)]) -
CAST_SBOX3[get_byte(2, temp)] + CAST_SBOX4[get_byte(3, temp)];
}
@@ -26,9 +26,9 @@ void round1(u32bit& out, u32bit in, u32bit mask, u32bit rot)
/*
* CAST-256 Round Type 2
*/
-void round2(u32bit& out, u32bit in, u32bit mask, u32bit rot)
+void round2(uint32_t& out, uint32_t in, uint32_t mask, uint32_t rot)
{
- u32bit temp = rotate_left(mask ^ in, rot);
+ uint32_t temp = rotate_left(mask ^ in, rot);
out ^= (CAST_SBOX1[get_byte(0, temp)] - CAST_SBOX2[get_byte(1, temp)] +
CAST_SBOX3[get_byte(2, temp)]) ^ CAST_SBOX4[get_byte(3, temp)];
}
@@ -36,9 +36,9 @@ void round2(u32bit& out, u32bit in, u32bit mask, u32bit rot)
/*
* CAST-256 Round Type 3
*/
-void round3(u32bit& out, u32bit in, u32bit mask, u32bit rot)
+void round3(uint32_t& out, uint32_t in, uint32_t mask, uint32_t rot)
{
- u32bit temp = rotate_left(mask - in, rot);
+ uint32_t temp = rotate_left(mask - in, rot);
out ^= ((CAST_SBOX1[get_byte(0, temp)] + CAST_SBOX2[get_byte(1, temp)]) ^
CAST_SBOX3[get_byte(2, temp)]) - CAST_SBOX4[get_byte(3, temp)];
}
@@ -48,14 +48,14 @@ void round3(u32bit& out, u32bit in, u32bit mask, u32bit rot)
/*
* CAST-256 Encryption
*/
-void CAST_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void CAST_256::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit A = load_be<u32bit>(in, 0);
- u32bit B = load_be<u32bit>(in, 1);
- u32bit C = load_be<u32bit>(in, 2);
- u32bit D = load_be<u32bit>(in, 3);
+ uint32_t A = load_be<uint32_t>(in, 0);
+ uint32_t B = load_be<uint32_t>(in, 1);
+ uint32_t C = load_be<uint32_t>(in, 2);
+ uint32_t D = load_be<uint32_t>(in, 3);
round1(C, D, m_MK[ 0], m_RK[ 0]); round2(B, C, m_MK[ 1], m_RK[ 1]);
round3(A, B, m_MK[ 2], m_RK[ 2]); round1(D, A, m_MK[ 3], m_RK[ 3]);
@@ -92,14 +92,14 @@ void CAST_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* CAST-256 Decryption
*/
-void CAST_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void CAST_256::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit A = load_be<u32bit>(in, 0);
- u32bit B = load_be<u32bit>(in, 1);
- u32bit C = load_be<u32bit>(in, 2);
- u32bit D = load_be<u32bit>(in, 3);
+ uint32_t A = load_be<uint32_t>(in, 0);
+ uint32_t B = load_be<uint32_t>(in, 1);
+ uint32_t C = load_be<uint32_t>(in, 2);
+ uint32_t D = load_be<uint32_t>(in, 3);
round1(C, D, m_MK[44], m_RK[44]); round2(B, C, m_MK[45], m_RK[45]);
round3(A, B, m_MK[46], m_RK[46]); round1(D, A, m_MK[47], m_RK[47]);
@@ -136,9 +136,9 @@ void CAST_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* CAST-256 Key Schedule
*/
-void CAST_256::key_schedule(const byte key[], size_t length)
+void CAST_256::key_schedule(const uint8_t key[], size_t length)
{
- static const u32bit KEY_MASK[192] = {
+ static const uint32_t KEY_MASK[192] = {
0x5A827999, 0xC95C653A, 0x383650DB, 0xA7103C7C, 0x15EA281D, 0x84C413BE,
0xF39DFF5F, 0x6277EB00, 0xD151D6A1, 0x402BC242, 0xAF05ADE3, 0x1DDF9984,
0x8CB98525, 0xFB9370C6, 0x6A6D5C67, 0xD9474808, 0x482133A9, 0xB6FB1F4A,
@@ -172,7 +172,7 @@ void CAST_256::key_schedule(const byte key[], size_t length)
0x4BBC26CD, 0xBA96126E, 0x296FFE0F, 0x9849E9B0, 0x0723D551, 0x75FDC0F2,
0xE4D7AC93, 0x53B19834, 0xC28B83D5, 0x31656F76, 0xA03F5B17, 0x0F1946B8 };
- static const byte KEY_ROT[32] = {
+ static const uint8_t KEY_ROT[32] = {
0x13, 0x04, 0x15, 0x06, 0x17, 0x08, 0x19, 0x0A, 0x1B, 0x0C,
0x1D, 0x0E, 0x1F, 0x10, 0x01, 0x12, 0x03, 0x14, 0x05, 0x16,
0x07, 0x18, 0x09, 0x1A, 0x0B, 0x1C, 0x0D, 0x1E, 0x0F, 0x00,
@@ -181,11 +181,11 @@ void CAST_256::key_schedule(const byte key[], size_t length)
m_MK.resize(48);
m_RK.resize(48);
- secure_vector<u32bit> K(8);
+ secure_vector<uint32_t> K(8);
for(size_t i = 0; i != length; ++i)
K[i/4] = (K[i/4] << 8) + key[i];
- u32bit A = K[0], B = K[1], C = K[2], D = K[3],
+ uint32_t A = K[0], B = K[1], C = K[2], D = K[3],
E = K[4], F = K[5], G = K[6], H = K[7];
for(size_t i = 0; i != 48; i += 4)
diff --git a/src/lib/block/cast/cast256.h b/src/lib/block/cast/cast256.h
index 086c94331..fe35abfba 100644
--- a/src/lib/block/cast/cast256.h
+++ b/src/lib/block/cast/cast256.h
@@ -18,17 +18,17 @@ namespace Botan {
class BOTAN_DLL CAST_256 final : public Block_Cipher_Fixed_Params<16, 4, 32, 4>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "CAST-256"; }
BlockCipher* clone() const override { return new CAST_256; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u32bit> m_MK;
- secure_vector<byte> m_RK;
+ secure_vector<uint32_t> m_MK;
+ secure_vector<uint8_t> m_RK;
};
}
diff --git a/src/lib/block/cast/cast_sboxes.h b/src/lib/block/cast/cast_sboxes.h
index f73ce8142..c8d6a3a90 100644
--- a/src/lib/block/cast/cast_sboxes.h
+++ b/src/lib/block/cast/cast_sboxes.h
@@ -12,7 +12,7 @@
namespace Botan {
-const u32bit CAST_SBOX1[256] = {
+const uint32_t CAST_SBOX1[256] = {
0x30FB40D4, 0x9FA0FF0B, 0x6BECCD2F, 0x3F258C7A, 0x1E213F2F, 0x9C004DD3,
0x6003E540, 0xCF9FC949, 0xBFD4AF27, 0x88BBBDB5, 0xE2034090, 0x98D09675,
0x6E63A0E0, 0x15C361D2, 0xC2E7661D, 0x22D4FF8E, 0x28683B6F, 0xC07FD059,
@@ -57,7 +57,7 @@ const u32bit CAST_SBOX1[256] = {
0xB141AB08, 0x7CCA89B9, 0x1A69E783, 0x02CC4843, 0xA2F7C579, 0x429EF47D,
0x427B169C, 0x5AC9F049, 0xDD8F0F00, 0x5C8165BF };
-const u32bit CAST_SBOX2[256] = {
+const uint32_t CAST_SBOX2[256] = {
0x1F201094, 0xEF0BA75B, 0x69E3CF7E, 0x393F4380, 0xFE61CF7A, 0xEEC5207A,
0x55889C94, 0x72FC0651, 0xADA7EF79, 0x4E1D7235, 0xD55A63CE, 0xDE0436BA,
0x99C430EF, 0x5F0C0794, 0x18DCDB7D, 0xA1D6EFF3, 0xA0B52F7B, 0x59E83605,
@@ -102,7 +102,7 @@ const u32bit CAST_SBOX2[256] = {
0x5C038323, 0x3E5D3BB9, 0x43D79572, 0x7E6DD07C, 0x06DFDF1E, 0x6C6CC4EF,
0x7160A539, 0x73BFBE70, 0x83877605, 0x4523ECF1 };
-const u32bit CAST_SBOX3[256] = {
+const uint32_t CAST_SBOX3[256] = {
0x8DEFC240, 0x25FA5D9F, 0xEB903DBF, 0xE810C907, 0x47607FFF, 0x369FE44B,
0x8C1FC644, 0xAECECA90, 0xBEB1F9BF, 0xEEFBCAEA, 0xE8CF1950, 0x51DF07AE,
0x920E8806, 0xF0AD0548, 0xE13C8D83, 0x927010D5, 0x11107D9F, 0x07647DB9,
@@ -147,7 +147,7 @@ const u32bit CAST_SBOX3[256] = {
0x52BCE688, 0x1B03588A, 0xF7BAEFD5, 0x4142ED9C, 0xA4315C11, 0x83323EC5,
0xDFEF4636, 0xA133C501, 0xE9D3531C, 0xEE353783 };
-const u32bit CAST_SBOX4[256] = {
+const uint32_t CAST_SBOX4[256] = {
0x9DB30420, 0x1FB6E9DE, 0xA7BE7BEF, 0xD273A298, 0x4A4F7BDB, 0x64AD8C57,
0x85510443, 0xFA020ED1, 0x7E287AFF, 0xE60FB663, 0x095F35A1, 0x79EBF120,
0xFD059D43, 0x6497B7B1, 0xF3641F63, 0x241E4ADF, 0x28147F5F, 0x4FA2B8CD,
diff --git a/src/lib/block/des/des.cpp b/src/lib/block/des/des.cpp
index a55c43ec7..44f315047 100644
--- a/src/lib/block/des/des.cpp
+++ b/src/lib/block/des/des.cpp
@@ -18,12 +18,12 @@ namespace {
/*
* DES Key Schedule
*/
-void des_key_schedule(u32bit round_key[32], const byte key[8])
+void des_key_schedule(uint32_t round_key[32], const uint8_t key[8])
{
- static const byte ROT[16] = { 1, 1, 2, 2, 2, 2, 2, 2,
+ static const uint8_t ROT[16] = { 1, 1, 2, 2, 2, 2, 2, 2,
1, 2, 2, 2, 2, 2, 2, 1 };
- u32bit C = ((key[7] & 0x80) << 20) | ((key[6] & 0x80) << 19) |
+ uint32_t C = ((key[7] & 0x80) << 20) | ((key[6] & 0x80) << 19) |
((key[5] & 0x80) << 18) | ((key[4] & 0x80) << 17) |
((key[3] & 0x80) << 16) | ((key[2] & 0x80) << 15) |
((key[1] & 0x80) << 14) | ((key[0] & 0x80) << 13) |
@@ -37,7 +37,7 @@ void des_key_schedule(u32bit round_key[32], const byte key[8])
((key[1] & 0x20) ) | ((key[0] & 0x20) >> 1) |
((key[7] & 0x10) >> 1) | ((key[6] & 0x10) >> 2) |
((key[5] & 0x10) >> 3) | ((key[4] & 0x10) >> 4);
- u32bit D = ((key[7] & 0x02) << 26) | ((key[6] & 0x02) << 25) |
+ uint32_t D = ((key[7] & 0x02) << 26) | ((key[6] & 0x02) << 25) |
((key[5] & 0x02) << 24) | ((key[4] & 0x02) << 23) |
((key[3] & 0x02) << 22) | ((key[2] & 0x02) << 21) |
((key[1] & 0x02) << 20) | ((key[0] & 0x02) << 19) |
@@ -84,12 +84,12 @@ void des_key_schedule(u32bit round_key[32], const byte key[8])
/*
* DES Encryption
*/
-void des_encrypt(u32bit& L, u32bit& R,
- const u32bit round_key[32])
+void des_encrypt(uint32_t& L, uint32_t& R,
+ const uint32_t round_key[32])
{
for(size_t i = 0; i != 16; i += 2)
{
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = rotate_right(R, 4) ^ round_key[2*i];
T1 = R ^ round_key[2*i + 1];
@@ -112,12 +112,12 @@ void des_encrypt(u32bit& L, u32bit& R,
/*
* DES Decryption
*/
-void des_decrypt(u32bit& L, u32bit& R,
- const u32bit round_key[32])
+void des_decrypt(uint32_t& L, uint32_t& R,
+ const uint32_t round_key[32])
{
for(size_t i = 16; i != 0; i -= 2)
{
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = rotate_right(R, 4) ^ round_key[2*i - 2];
T1 = R ^ round_key[2*i - 1];
@@ -142,17 +142,17 @@ void des_decrypt(u32bit& L, u32bit& R,
/*
* DES Encryption
*/
-void DES::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void DES::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i < blocks; ++i)
{
- u64bit T = (DES_IPTAB1[in[8*i+0]] ) | (DES_IPTAB1[in[8*i+1]] << 1) |
+ uint64_t T = (DES_IPTAB1[in[8*i+0]] ) | (DES_IPTAB1[in[8*i+1]] << 1) |
(DES_IPTAB1[in[8*i+2]] << 2) | (DES_IPTAB1[in[8*i+3]] << 3) |
(DES_IPTAB1[in[8*i+4]] << 4) | (DES_IPTAB1[in[8*i+5]] << 5) |
(DES_IPTAB1[in[8*i+6]] << 6) | (DES_IPTAB2[in[8*i+7]] );
- u32bit L = static_cast<u32bit>(T >> 32);
- u32bit R = static_cast<u32bit>(T);
+ uint32_t L = static_cast<uint32_t>(T >> 32);
+ uint32_t R = static_cast<uint32_t>(T);
des_encrypt(L, R, m_round_key.data());
@@ -169,17 +169,17 @@ void DES::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* DES Decryption
*/
-void DES::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void DES::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i < blocks; ++i)
{
- u64bit T = (DES_IPTAB1[in[BLOCK_SIZE*i+0]] ) | (DES_IPTAB1[in[BLOCK_SIZE*i+1]] << 1) |
+ uint64_t T = (DES_IPTAB1[in[BLOCK_SIZE*i+0]] ) | (DES_IPTAB1[in[BLOCK_SIZE*i+1]] << 1) |
(DES_IPTAB1[in[BLOCK_SIZE*i+2]] << 2) | (DES_IPTAB1[in[BLOCK_SIZE*i+3]] << 3) |
(DES_IPTAB1[in[BLOCK_SIZE*i+4]] << 4) | (DES_IPTAB1[in[BLOCK_SIZE*i+5]] << 5) |
(DES_IPTAB1[in[BLOCK_SIZE*i+6]] << 6) | (DES_IPTAB2[in[BLOCK_SIZE*i+7]] );
- u32bit L = static_cast<u32bit>(T >> 32);
- u32bit R = static_cast<u32bit>(T);
+ uint32_t L = static_cast<uint32_t>(T >> 32);
+ uint32_t R = static_cast<uint32_t>(T);
des_decrypt(L, R, m_round_key.data());
@@ -197,7 +197,7 @@ void DES::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* DES Key Schedule
*/
-void DES::key_schedule(const byte key[], size_t)
+void DES::key_schedule(const uint8_t key[], size_t)
{
m_round_key.resize(32);
des_key_schedule(m_round_key.data(), key);
@@ -211,17 +211,17 @@ void DES::clear()
/*
* TripleDES Encryption
*/
-void TripleDES::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void TripleDES::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
+ uint64_t T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
(DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) |
(DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) |
(DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] );
- u32bit L = static_cast<u32bit>(T >> 32);
- u32bit R = static_cast<u32bit>(T);
+ uint32_t L = static_cast<uint32_t>(T >> 32);
+ uint32_t R = static_cast<uint32_t>(T);
des_encrypt(L, R, &m_round_key[0]);
des_decrypt(R, L, &m_round_key[32]);
@@ -244,17 +244,17 @@ void TripleDES::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* TripleDES Decryption
*/
-void TripleDES::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void TripleDES::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
+ uint64_t T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
(DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) |
(DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) |
(DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] );
- u32bit L = static_cast<u32bit>(T >> 32);
- u32bit R = static_cast<u32bit>(T);
+ uint32_t L = static_cast<uint32_t>(T >> 32);
+ uint32_t R = static_cast<uint32_t>(T);
des_decrypt(L, R, &m_round_key[64]);
des_encrypt(R, L, &m_round_key[32]);
@@ -277,7 +277,7 @@ void TripleDES::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* TripleDES Key Schedule
*/
-void TripleDES::key_schedule(const byte key[], size_t length)
+void TripleDES::key_schedule(const uint8_t key[], size_t length)
{
m_round_key.resize(3*32);
des_key_schedule(&m_round_key[0], key);
diff --git a/src/lib/block/des/des.h b/src/lib/block/des/des.h
index ff31421d2..f0c32be29 100644
--- a/src/lib/block/des/des.h
+++ b/src/lib/block/des/des.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL DES final : public Block_Cipher_Fixed_Params<8, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "DES"; }
BlockCipher* clone() const override { return new DES; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u32bit> m_round_key;
+ secure_vector<uint32_t> m_round_key;
};
/**
@@ -36,34 +36,34 @@ class BOTAN_DLL DES final : public Block_Cipher_Fixed_Params<8, 8>
class BOTAN_DLL TripleDES final : public Block_Cipher_Fixed_Params<8, 16, 24, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "TripleDES"; }
BlockCipher* clone() const override { return new TripleDES; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u32bit> m_round_key;
+ secure_vector<uint32_t> m_round_key;
};
/*
* DES Tables
*/
-extern const u32bit DES_SPBOX1[256];
-extern const u32bit DES_SPBOX2[256];
-extern const u32bit DES_SPBOX3[256];
-extern const u32bit DES_SPBOX4[256];
-extern const u32bit DES_SPBOX5[256];
-extern const u32bit DES_SPBOX6[256];
-extern const u32bit DES_SPBOX7[256];
-extern const u32bit DES_SPBOX8[256];
+extern const uint32_t DES_SPBOX1[256];
+extern const uint32_t DES_SPBOX2[256];
+extern const uint32_t DES_SPBOX3[256];
+extern const uint32_t DES_SPBOX4[256];
+extern const uint32_t DES_SPBOX5[256];
+extern const uint32_t DES_SPBOX6[256];
+extern const uint32_t DES_SPBOX7[256];
+extern const uint32_t DES_SPBOX8[256];
-extern const u64bit DES_IPTAB1[256];
-extern const u64bit DES_IPTAB2[256];
-extern const u64bit DES_FPTAB1[256];
-extern const u64bit DES_FPTAB2[256];
+extern const uint64_t DES_IPTAB1[256];
+extern const uint64_t DES_IPTAB2[256];
+extern const uint64_t DES_FPTAB1[256];
+extern const uint64_t DES_FPTAB2[256];
}
diff --git a/src/lib/block/des/des_tab.cpp b/src/lib/block/des/des_tab.cpp
index 0f8179995..c64b6baf6 100644
--- a/src/lib/block/des/des_tab.cpp
+++ b/src/lib/block/des/des_tab.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-const u32bit DES_SPBOX1[256] = {
+const uint32_t DES_SPBOX1[256] = {
0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404,
0x00000004, 0x00010000, 0x00000400, 0x01010400, 0x01010404, 0x00000400,
0x01000404, 0x01010004, 0x01000000, 0x00000004, 0x00000404, 0x01000400,
@@ -54,7 +54,7 @@ const u32bit DES_SPBOX1[256] = {
0x00010404, 0x01010400, 0x00000404, 0x01000400, 0x01000400, 0x00000000,
0x00010004, 0x00010400, 0x00000000, 0x01010004 };
-const u32bit DES_SPBOX2[256] = {
+const uint32_t DES_SPBOX2[256] = {
0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020,
0x80100020, 0x80008020, 0x80000020, 0x80108020, 0x80108000, 0x80000000,
0x80008000, 0x00100000, 0x00000020, 0x80100020, 0x00108000, 0x00100020,
@@ -99,7 +99,7 @@ const u32bit DES_SPBOX2[256] = {
0x80000020, 0x00100020, 0x00108000, 0x00000000, 0x80008000, 0x00008020,
0x80000000, 0x80100020, 0x80108020, 0x00108000 };
-const u32bit DES_SPBOX3[256] = {
+const uint32_t DES_SPBOX3[256] = {
0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000,
0x00020208, 0x08000200, 0x00020008, 0x08000008, 0x08000008, 0x00020000,
0x08020208, 0x00020008, 0x08020000, 0x00000208, 0x08000000, 0x00000008,
@@ -144,7 +144,7 @@ const u32bit DES_SPBOX3[256] = {
0x00020200, 0x08000008, 0x08020000, 0x08000208, 0x00000208, 0x08020000,
0x00020208, 0x00000008, 0x08020008, 0x00020200 };
-const u32bit DES_SPBOX4[256] = {
+const uint32_t DES_SPBOX4[256] = {
0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081,
0x00800001, 0x00002001, 0x00000000, 0x00802000, 0x00802000, 0x00802081,
0x00000081, 0x00000000, 0x00800080, 0x00800001, 0x00000001, 0x00002000,
@@ -189,7 +189,7 @@ const u32bit DES_SPBOX4[256] = {
0x00802080, 0x00800081, 0x00002001, 0x00002080, 0x00800000, 0x00802001,
0x00000080, 0x00800000, 0x00002000, 0x00802080 };
-const u32bit DES_SPBOX5[256] = {
+const uint32_t DES_SPBOX5[256] = {
0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100,
0x40000000, 0x02080000, 0x40080100, 0x00080000, 0x02000100, 0x40080100,
0x42000100, 0x42080000, 0x00080100, 0x40000000, 0x02000000, 0x40080000,
@@ -234,7 +234,7 @@ const u32bit DES_SPBOX5[256] = {
0x40080000, 0x42000000, 0x00080100, 0x02000100, 0x40000100, 0x00080000,
0x00000000, 0x40080000, 0x02080100, 0x40000100 };
-const u32bit DES_SPBOX6[256] = {
+const uint32_t DES_SPBOX6[256] = {
0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010,
0x20404010, 0x00400000, 0x20004000, 0x00404010, 0x00400000, 0x20000010,
0x00400010, 0x20004000, 0x20000000, 0x00004010, 0x00000000, 0x00400010,
@@ -279,7 +279,7 @@ const u32bit DES_SPBOX6[256] = {
0x20400000, 0x00404010, 0x00004000, 0x00400010, 0x20004010, 0x00000000,
0x20404000, 0x20000000, 0x00400010, 0x20004010 };
-const u32bit DES_SPBOX7[256] = {
+const uint32_t DES_SPBOX7[256] = {
0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802,
0x00200802, 0x04200800, 0x04200802, 0x00200000, 0x00000000, 0x04000002,
0x00000002, 0x04000000, 0x04200002, 0x00000802, 0x04000800, 0x00200802,
@@ -324,7 +324,7 @@ const u32bit DES_SPBOX7[256] = {
0x00000002, 0x04200802, 0x00000000, 0x00200802, 0x04200000, 0x00000800,
0x04000002, 0x04000800, 0x00000800, 0x00200002 };
-const u32bit DES_SPBOX8[256] = {
+const uint32_t DES_SPBOX8[256] = {
0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040,
0x00000040, 0x10000000, 0x00040040, 0x10040000, 0x10041040, 0x00041000,
0x10041000, 0x00041040, 0x00001000, 0x00000040, 0x10040000, 0x10000040,
@@ -369,7 +369,7 @@ const u32bit DES_SPBOX8[256] = {
0x10001040, 0x00000000, 0x10041040, 0x00041000, 0x00041000, 0x00001040,
0x00001040, 0x00040040, 0x10000000, 0x10041000 };
-const u64bit DES_IPTAB1[256] = {
+const uint64_t DES_IPTAB1[256] = {
0x0000000000000000, 0x0000000200000000, 0x0000000000000002, 0x0000000200000002,
0x0000020000000000, 0x0000020200000000, 0x0000020000000002, 0x0000020200000002,
0x0000000000000200, 0x0000000200000200, 0x0000000000000202, 0x0000000200000202,
@@ -435,7 +435,7 @@ const u64bit DES_IPTAB1[256] = {
0x0202000002020200, 0x0202000202020200, 0x0202000002020202, 0x0202000202020202,
0x0202020002020200, 0x0202020202020200, 0x0202020002020202, 0x0202020202020202 };
-const u64bit DES_IPTAB2[256] = {
+const uint64_t DES_IPTAB2[256] = {
0x0000000000000000, 0x0000010000000000, 0x0000000000000100, 0x0000010000000100,
0x0001000000000000, 0x0001010000000000, 0x0001000000000100, 0x0001010000000100,
0x0000000000010000, 0x0000010000010000, 0x0000000000010100, 0x0000010000010100,
@@ -501,7 +501,7 @@ const u64bit DES_IPTAB2[256] = {
0x0100000101010001, 0x0100010101010001, 0x0100000101010101, 0x0100010101010101,
0x0101000101010001, 0x0101010101010001, 0x0101000101010101, 0x0101010101010101 };
-const u64bit DES_FPTAB1[256] = {
+const uint64_t DES_FPTAB1[256] = {
0x0000000000000000, 0x0000000100000000, 0x0000000004000000, 0x0000000104000000,
0x0000000000040000, 0x0000000100040000, 0x0000000004040000, 0x0000000104040000,
0x0000000000000400, 0x0000000100000400, 0x0000000004000400, 0x0000000104000400,
@@ -567,7 +567,7 @@ const u64bit DES_FPTAB1[256] = {
0x0404040000000404, 0x0404040100000404, 0x0404040004000404, 0x0404040104000404,
0x0404040000040404, 0x0404040100040404, 0x0404040004040404, 0x0404040104040404 };
-const u64bit DES_FPTAB2[256] = {
+const uint64_t DES_FPTAB2[256] = {
0x0000000000000000, 0x0000004000000000, 0x0000000001000000, 0x0000004001000000,
0x0000000000010000, 0x0000004000010000, 0x0000000001010000, 0x0000004001010000,
0x0000000000000100, 0x0000004000000100, 0x0000000001000100, 0x0000004001000100,
diff --git a/src/lib/block/des/desx.cpp b/src/lib/block/des/desx.cpp
index 76a50f9a2..7c9995523 100644
--- a/src/lib/block/des/desx.cpp
+++ b/src/lib/block/des/desx.cpp
@@ -12,7 +12,7 @@ namespace Botan {
/*
* DESX Encryption
*/
-void DESX::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void DESX::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
@@ -28,7 +28,7 @@ void DESX::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* DESX Decryption
*/
-void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void DESX::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
@@ -44,7 +44,7 @@ void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* DESX Key Schedule
*/
-void DESX::key_schedule(const byte key[], size_t)
+void DESX::key_schedule(const uint8_t key[], size_t)
{
m_K1.assign(key, key + 8);
m_des.set_key(key + 8, 8);
diff --git a/src/lib/block/des/desx.h b/src/lib/block/des/desx.h
index f3c9ac99a..7bc7d047f 100644
--- a/src/lib/block/des/desx.h
+++ b/src/lib/block/des/desx.h
@@ -18,15 +18,15 @@ namespace Botan {
class BOTAN_DLL DESX final : public Block_Cipher_Fixed_Params<8, 24>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "DESX"; }
BlockCipher* clone() const override { return new DESX; }
private:
- void key_schedule(const byte[], size_t) override;
- secure_vector<byte> m_K1, m_K2;
+ void key_schedule(const uint8_t[], size_t) override;
+ secure_vector<uint8_t> m_K1, m_K2;
DES m_des;
};
diff --git a/src/lib/block/gost_28147/gost_28147.cpp b/src/lib/block/gost_28147/gost_28147.cpp
index 5fa232478..f73ac5910 100644
--- a/src/lib/block/gost_28147/gost_28147.cpp
+++ b/src/lib/block/gost_28147/gost_28147.cpp
@@ -10,9 +10,9 @@
namespace Botan {
-byte GOST_28147_89_Params::sbox_entry(size_t row, size_t col) const
+uint8_t GOST_28147_89_Params::sbox_entry(size_t row, size_t col) const
{
- byte x = m_sboxes[4 * col + (row / 2)];
+ uint8_t x = m_sboxes[4 * col + (row / 2)];
return (row % 2 == 0) ? (x >> 4) : (x & 0x0F);
}
@@ -22,7 +22,7 @@ GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : m_name(n)
// Encoded in the packed fromat from RFC 4357
// GostR3411_94_TestParamSet (OID 1.2.643.2.2.31.0)
- static const byte GOST_R_3411_TEST_PARAMS[64] = {
+ static const uint8_t GOST_R_3411_TEST_PARAMS[64] = {
0x4E, 0x57, 0x64, 0xD1, 0xAB, 0x8D, 0xCB, 0xBF, 0x94, 0x1A, 0x7A,
0x4D, 0x2C, 0xD1, 0x10, 0x10, 0xD6, 0xA0, 0x57, 0x35, 0x8D, 0x38,
0xF2, 0xF7, 0x0F, 0x49, 0xD1, 0x5A, 0xEA, 0x2F, 0x8D, 0x94, 0x62,
@@ -31,7 +31,7 @@ GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : m_name(n)
0x8B, 0x55, 0x95, 0xBF, 0x28, 0x39, 0xB3, 0x2E, 0xCC };
// GostR3411-94-CryptoProParamSet (OID 1.2.643.2.2.31.1)
- static const byte GOST_R_3411_CRYPTOPRO_PARAMS[64] = {
+ static const uint8_t GOST_R_3411_CRYPTOPRO_PARAMS[64] = {
0xA5, 0x74, 0x77, 0xD1, 0x4F, 0xFA, 0x66, 0xE3, 0x54, 0xC7, 0x42,
0x4A, 0x60, 0xEC, 0xB4, 0x19, 0x82, 0x90, 0x9D, 0x75, 0x1D, 0x4F,
0xC9, 0x0B, 0x3B, 0x12, 0x2F, 0x54, 0x79, 0x08, 0xA0, 0xAF, 0xD1,
@@ -56,7 +56,7 @@ GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : m_SBOX(1024)
for(size_t i = 0; i != 4; ++i)
for(size_t j = 0; j != 256; ++j)
{
- const u32bit T = (param.sbox_entry(2*i , j % 16)) |
+ const uint32_t T = (param.sbox_entry(2*i , j % 16)) |
(param.sbox_entry(2*i+1, j / 16) << 4);
m_SBOX[256*i+j] = rotate_left(T, (11+8*i) % 32);
}
@@ -86,13 +86,13 @@ std::string GOST_28147_89::name() const
*/
#define GOST_2ROUND(N1, N2, R1, R2) \
do { \
- u32bit T0 = N1 + m_EK[R1]; \
+ uint32_t T0 = N1 + m_EK[R1]; \
N2 ^= m_SBOX[get_byte(3, T0)] | \
m_SBOX[get_byte(2, T0)+256] | \
m_SBOX[get_byte(1, T0)+512] | \
m_SBOX[get_byte(0, T0)+768]; \
\
- u32bit T1 = N2 + m_EK[R2]; \
+ uint32_t T1 = N2 + m_EK[R2]; \
N1 ^= m_SBOX[get_byte(3, T1)] | \
m_SBOX[get_byte(2, T1)+256] | \
m_SBOX[get_byte(1, T1)+512] | \
@@ -102,12 +102,12 @@ std::string GOST_28147_89::name() const
/*
* GOST Encryption
*/
-void GOST_28147_89::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void GOST_28147_89::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit N1 = load_le<u32bit>(in, 0);
- u32bit N2 = load_le<u32bit>(in, 1);
+ uint32_t N1 = load_le<uint32_t>(in, 0);
+ uint32_t N2 = load_le<uint32_t>(in, 1);
for(size_t j = 0; j != 3; ++j)
{
@@ -132,12 +132,12 @@ void GOST_28147_89::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* GOST Decryption
*/
-void GOST_28147_89::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void GOST_28147_89::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit N1 = load_le<u32bit>(in, 0);
- u32bit N2 = load_le<u32bit>(in, 1);
+ uint32_t N1 = load_le<uint32_t>(in, 0);
+ uint32_t N2 = load_le<uint32_t>(in, 1);
GOST_2ROUND(N1, N2, 0, 1);
GOST_2ROUND(N1, N2, 2, 3);
@@ -161,11 +161,11 @@ void GOST_28147_89::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* GOST Key Schedule
*/
-void GOST_28147_89::key_schedule(const byte key[], size_t)
+void GOST_28147_89::key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(8);
for(size_t i = 0; i != 8; ++i)
- m_EK[i] = load_le<u32bit>(key, i);
+ m_EK[i] = load_le<uint32_t>(key, i);
}
void GOST_28147_89::clear()
diff --git a/src/lib/block/gost_28147/gost_28147.h b/src/lib/block/gost_28147/gost_28147.h
index 4105154e3..6ee1ec60e 100644
--- a/src/lib/block/gost_28147/gost_28147.h
+++ b/src/lib/block/gost_28147/gost_28147.h
@@ -26,7 +26,7 @@ class BOTAN_DLL GOST_28147_89_Params
* @param col the column
* @return sbox entry at this row/column
*/
- byte sbox_entry(size_t row, size_t col) const;
+ uint8_t sbox_entry(size_t row, size_t col) const;
/**
* @return name of this parameter set
@@ -42,7 +42,7 @@ class BOTAN_DLL GOST_28147_89_Params
*/
GOST_28147_89_Params(const std::string& name = "R3411_94_TestParam");
private:
- const byte* m_sboxes;
+ const uint8_t* m_sboxes;
std::string m_name;
};
@@ -52,8 +52,8 @@ class BOTAN_DLL GOST_28147_89_Params
class BOTAN_DLL GOST_28147_89 final : public Block_Cipher_Fixed_Params<8, 32>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -65,18 +65,18 @@ class BOTAN_DLL GOST_28147_89 final : public Block_Cipher_Fixed_Params<8, 32>
*/
explicit GOST_28147_89(const GOST_28147_89_Params& params);
private:
- explicit GOST_28147_89(const std::vector<u32bit>& other_SBOX) :
+ explicit GOST_28147_89(const std::vector<uint32_t>& other_SBOX) :
m_SBOX(other_SBOX), m_EK(8) {}
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
/*
* The sbox is not secret, this is just a larger expansion of it
* which we generate at runtime for faster execution
*/
- std::vector<u32bit> m_SBOX;
+ std::vector<uint32_t> m_SBOX;
- secure_vector<u32bit> m_EK;
+ secure_vector<uint32_t> m_EK;
};
}
diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp
index 1fe25d599..4eab6a4f3 100644
--- a/src/lib/block/idea/idea.cpp
+++ b/src/lib/block/idea/idea.cpp
@@ -17,17 +17,17 @@ namespace {
/*
* Multiplication modulo 65537
*/
-inline u16bit mul(u16bit x, u16bit y)
+inline uint16_t mul(uint16_t x, uint16_t y)
{
- const u32bit P = static_cast<u32bit>(x) * y;
+ const uint32_t P = static_cast<uint32_t>(x) * y;
- const u16bit Z_mask = static_cast<u16bit>(CT::expand_mask(P) & 0xFFFF);
+ const uint16_t Z_mask = static_cast<uint16_t>(CT::expand_mask(P) & 0xFFFF);
- const u32bit P_hi = P >> 16;
- const u32bit P_lo = P & 0xFFFF;
+ const uint32_t P_hi = P >> 16;
+ const uint32_t P_lo = P & 0xFFFF;
- const u16bit r_1 = (P_lo - P_hi) + (P_lo < P_hi);
- const u16bit r_2 = 1 - x - y;
+ const uint16_t r_1 = (P_lo - P_hi) + (P_lo < P_hi);
+ const uint16_t r_2 = 1 - x - y;
return CT::select(Z_mask, r_1, r_2);
}
@@ -43,9 +43,9 @@ inline u16bit mul(u16bit x, u16bit y)
* Do the exponentiation with a basic square and multiply: all bits are
* of exponent are 1 so we always multiply
*/
-u16bit mul_inv(u16bit x)
+uint16_t mul_inv(uint16_t x)
{
- u16bit y = x;
+ uint16_t y = x;
for(size_t i = 0; i != 15; ++i)
{
@@ -59,7 +59,7 @@ u16bit mul_inv(u16bit x)
/**
* IDEA is involutional, depending only on the key schedule
*/
-void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52])
+void idea_op(const uint8_t in[], uint8_t out[], size_t blocks, const uint16_t K[52])
{
const size_t BLOCK_SIZE = 8;
@@ -69,7 +69,7 @@ void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52])
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u16bit X1, X2, X3, X4;
+ uint16_t X1, X2, X3, X4;
load_be(in + BLOCK_SIZE*i, X1, X2, X3, X4);
for(size_t j = 0; j != 8; ++j)
@@ -79,10 +79,10 @@ void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52])
X3 += K[6*j+2];
X4 = mul(X4, K[6*j+3]);
- u16bit T0 = X3;
+ uint16_t T0 = X3;
X3 = mul(X3 ^ X1, K[6*j+4]);
- u16bit T1 = X2;
+ uint16_t T1 = X2;
X2 = mul((X2 ^ X4) + X3, K[6*j+5]);
X3 += X2;
@@ -122,7 +122,7 @@ std::string IDEA::provider() const
/*
* IDEA Encryption
*/
-void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void IDEA::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_IDEA_SSE2)
if(CPUID::has_sse2())
@@ -143,7 +143,7 @@ void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* IDEA Decryption
*/
-void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void IDEA::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_IDEA_SSE2)
if(CPUID::has_sse2())
@@ -164,7 +164,7 @@ void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* IDEA Key Schedule
*/
-void IDEA::key_schedule(const byte key[], size_t)
+void IDEA::key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(52);
m_DK.resize(52);
@@ -174,11 +174,11 @@ void IDEA::key_schedule(const byte key[], size_t)
CT::poison(m_DK.data(), 52);
for(size_t i = 0; i != 8; ++i)
- m_EK[i] = load_be<u16bit>(key, i);
+ m_EK[i] = load_be<uint16_t>(key, i);
for(size_t i = 1, j = 8, offset = 0; j != 52; i %= 8, ++i, ++j)
{
- m_EK[i+7+offset] = static_cast<u16bit>((m_EK[(i % 8) + offset] << 9) |
+ m_EK[i+7+offset] = static_cast<uint16_t>((m_EK[(i % 8) + offset] << 9) |
(m_EK[((i+1) % 8) + offset] >> 7));
offset += (i == 8) ? 8 : 0;
}
diff --git a/src/lib/block/idea/idea.h b/src/lib/block/idea/idea.h
index eb391a0c8..5a718867b 100644
--- a/src/lib/block/idea/idea.h
+++ b/src/lib/block/idea/idea.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL IDEA final : public Block_Cipher_Fixed_Params<8, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -28,12 +28,12 @@ class BOTAN_DLL IDEA final : public Block_Cipher_Fixed_Params<8, 16>
BlockCipher* clone() const override { return new IDEA; }
private:
#if defined(BOTAN_HAS_IDEA_SSE2)
- void sse2_idea_op_8(const byte in[64], byte out[64], const u16bit EK[52]) const;
+ void sse2_idea_op_8(const uint8_t in[64], uint8_t out[64], const uint16_t EK[52]) const;
#endif
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u16bit> m_EK, m_DK;
+ secure_vector<uint16_t> m_EK, m_DK;
};
}
diff --git a/src/lib/block/idea/idea_sse2/idea_sse2.cpp b/src/lib/block/idea/idea_sse2/idea_sse2.cpp
index 1e63a8332..93648cfc7 100644
--- a/src/lib/block/idea/idea_sse2/idea_sse2.cpp
+++ b/src/lib/block/idea/idea_sse2/idea_sse2.cpp
@@ -14,7 +14,7 @@ namespace Botan {
namespace {
BOTAN_FUNC_ISA("sse2")
-inline __m128i mul(__m128i X, u16bit K_16)
+inline __m128i mul(__m128i X, uint16_t K_16)
{
const __m128i zeros = _mm_set1_epi16(0);
const __m128i ones = _mm_set1_epi16(1);
@@ -134,7 +134,7 @@ void transpose_out(__m128i& B0, __m128i& B1, __m128i& B2, __m128i& B3)
* 8 wide IDEA encryption/decryption in SSE2
*/
BOTAN_FUNC_ISA("sse2")
-void IDEA::sse2_idea_op_8(const byte in[64], byte out[64], const u16bit EK[52]) const
+void IDEA::sse2_idea_op_8(const uint8_t in[64], uint8_t out[64], const uint16_t EK[52]) const
{
CT::poison(in, 64);
CT::poison(out, 64);
diff --git a/src/lib/block/kasumi/kasumi.cpp b/src/lib/block/kasumi/kasumi.cpp
index 014987bc6..92ad5dd14 100644
--- a/src/lib/block/kasumi/kasumi.cpp
+++ b/src/lib/block/kasumi/kasumi.cpp
@@ -15,7 +15,7 @@ namespace {
/*
* KASUMI S-Boxes
*/
-const byte KASUMI_SBOX_S7[128] = {
+const uint8_t KASUMI_SBOX_S7[128] = {
0x36, 0x32, 0x3E, 0x38, 0x16, 0x22, 0x5E, 0x60, 0x26, 0x06, 0x3F, 0x5D,
0x02, 0x12, 0x7B, 0x21, 0x37, 0x71, 0x27, 0x72, 0x15, 0x43, 0x41, 0x0C,
0x2F, 0x49, 0x2E, 0x1B, 0x19, 0x6F, 0x7C, 0x51, 0x35, 0x09, 0x79, 0x4F,
@@ -28,7 +28,7 @@ const byte KASUMI_SBOX_S7[128] = {
0x44, 0x1D, 0x73, 0x2C, 0x40, 0x6B, 0x6C, 0x18, 0x6E, 0x53, 0x24, 0x4E,
0x2A, 0x13, 0x0F, 0x29, 0x58, 0x77, 0x3B, 0x03 };
-const u16bit KASUMI_SBOX_S9[512] = {
+const uint16_t KASUMI_SBOX_S9[512] = {
0x00A7, 0x00EF, 0x00A1, 0x017B, 0x0187, 0x014E, 0x0009, 0x0152, 0x0026,
0x00E2, 0x0030, 0x0166, 0x01C4, 0x0181, 0x005A, 0x018D, 0x00B7, 0x00FD,
0x0093, 0x014B, 0x019F, 0x0154, 0x0033, 0x016A, 0x0132, 0x01F4, 0x0106,
@@ -90,10 +90,10 @@ const u16bit KASUMI_SBOX_S9[512] = {
/*
* KASUMI FI Function
*/
-u16bit FI(u16bit I, u16bit K)
+uint16_t FI(uint16_t I, uint16_t K)
{
- u16bit D9 = (I >> 7);
- byte D7 = (I & 0x7F);
+ uint16_t D9 = (I >> 7);
+ uint8_t D7 = (I & 0x7F);
D9 = KASUMI_SBOX_S9[D9] ^ D7;
D7 = KASUMI_SBOX_S7[D7] ^ (D9 & 0x7F);
@@ -108,21 +108,21 @@ u16bit FI(u16bit I, u16bit K)
/*
* KASUMI Encryption
*/
-void KASUMI::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void KASUMI::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u16bit B0 = load_be<u16bit>(in, 0);
- u16bit B1 = load_be<u16bit>(in, 1);
- u16bit B2 = load_be<u16bit>(in, 2);
- u16bit B3 = load_be<u16bit>(in, 3);
+ uint16_t B0 = load_be<uint16_t>(in, 0);
+ uint16_t B1 = load_be<uint16_t>(in, 1);
+ uint16_t B2 = load_be<uint16_t>(in, 2);
+ uint16_t B3 = load_be<uint16_t>(in, 3);
for(size_t j = 0; j != 8; j += 2)
{
- const u16bit* K = &m_EK[8*j];
+ const uint16_t* K = &m_EK[8*j];
- u16bit R = B1 ^ (rotate_left(B0, 1) & K[0]);
- u16bit L = B0 ^ (rotate_left(R, 1) | K[1]);
+ uint16_t R = B1 ^ (rotate_left(B0, 1) & K[0]);
+ uint16_t L = B0 ^ (rotate_left(R, 1) | K[1]);
L = FI(L ^ K[ 2], K[ 3]) ^ R;
R = FI(R ^ K[ 4], K[ 5]) ^ L;
@@ -152,20 +152,20 @@ void KASUMI::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* KASUMI Decryption
*/
-void KASUMI::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void KASUMI::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u16bit B0 = load_be<u16bit>(in, 0);
- u16bit B1 = load_be<u16bit>(in, 1);
- u16bit B2 = load_be<u16bit>(in, 2);
- u16bit B3 = load_be<u16bit>(in, 3);
+ uint16_t B0 = load_be<uint16_t>(in, 0);
+ uint16_t B1 = load_be<uint16_t>(in, 1);
+ uint16_t B2 = load_be<uint16_t>(in, 2);
+ uint16_t B3 = load_be<uint16_t>(in, 3);
for(size_t j = 0; j != 8; j += 2)
{
- const u16bit* K = &m_EK[8*(6-j)];
+ const uint16_t* K = &m_EK[8*(6-j)];
- u16bit L = B2, R = B3;
+ uint16_t L = B2, R = B3;
L = FI(L ^ K[10], K[11]) ^ R;
R = FI(R ^ K[12], K[13]) ^ L;
@@ -198,15 +198,15 @@ void KASUMI::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* KASUMI Key Schedule
*/
-void KASUMI::key_schedule(const byte key[], size_t)
+void KASUMI::key_schedule(const uint8_t key[], size_t)
{
- static const u16bit RC[] = { 0x0123, 0x4567, 0x89AB, 0xCDEF,
+ static const uint16_t RC[] = { 0x0123, 0x4567, 0x89AB, 0xCDEF,
0xFEDC, 0xBA98, 0x7654, 0x3210 };
- secure_vector<u16bit> K(16);
+ secure_vector<uint16_t> K(16);
for(size_t i = 0; i != 8; ++i)
{
- K[i] = load_be<u16bit>(key, i);
+ K[i] = load_be<uint16_t>(key, i);
K[i+8] = K[i] ^ RC[i];
}
diff --git a/src/lib/block/kasumi/kasumi.h b/src/lib/block/kasumi/kasumi.h
index 24fd83050..4c6acdadd 100644
--- a/src/lib/block/kasumi/kasumi.h
+++ b/src/lib/block/kasumi/kasumi.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL KASUMI final : public Block_Cipher_Fixed_Params<8, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "KASUMI"; }
BlockCipher* clone() const override { return new KASUMI; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u16bit> m_EK;
+ secure_vector<uint16_t> m_EK;
};
}
diff --git a/src/lib/block/lion/lion.cpp b/src/lib/block/lion/lion.cpp
index 56aa55c2f..4df22dd0b 100644
--- a/src/lib/block/lion/lion.cpp
+++ b/src/lib/block/lion/lion.cpp
@@ -13,13 +13,13 @@ namespace Botan {
/*
* Lion Encryption
*/
-void Lion::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Lion::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const size_t LEFT_SIZE = left_size();
const size_t RIGHT_SIZE = right_size();
- secure_vector<byte> buffer_vec(LEFT_SIZE);
- byte* buffer = buffer_vec.data();
+ secure_vector<uint8_t> buffer_vec(LEFT_SIZE);
+ uint8_t* buffer = buffer_vec.data();
for(size_t i = 0; i != blocks; ++i)
{
@@ -43,13 +43,13 @@ void Lion::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Lion Decryption
*/
-void Lion::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Lion::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const size_t LEFT_SIZE = left_size();
const size_t RIGHT_SIZE = right_size();
- secure_vector<byte> buffer_vec(LEFT_SIZE);
- byte* buffer = buffer_vec.data();
+ secure_vector<uint8_t> buffer_vec(LEFT_SIZE);
+ uint8_t* buffer = buffer_vec.data();
for(size_t i = 0; i != blocks; ++i)
{
@@ -73,7 +73,7 @@ void Lion::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Lion Key Schedule
*/
-void Lion::key_schedule(const byte key[], size_t length)
+void Lion::key_schedule(const uint8_t key[], size_t length)
{
clear();
diff --git a/src/lib/block/lion/lion.h b/src/lib/block/lion/lion.h
index e6ecca64f..5d82370ae 100644
--- a/src/lib/block/lion/lion.h
+++ b/src/lib/block/lion/lion.h
@@ -25,8 +25,8 @@ namespace Botan {
class BOTAN_DLL Lion final : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
size_t block_size() const override { return m_block_size; }
@@ -48,7 +48,7 @@ class BOTAN_DLL Lion final : public BlockCipher
StreamCipher* cipher,
size_t block_size);
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
size_t left_size() const { return m_hash->output_length(); }
size_t right_size() const { return m_block_size - left_size(); }
@@ -56,7 +56,7 @@ class BOTAN_DLL Lion final : public BlockCipher
const size_t m_block_size;
std::unique_ptr<HashFunction> m_hash;
std::unique_ptr<StreamCipher> m_cipher;
- secure_vector<byte> m_key1, m_key2;
+ secure_vector<uint8_t> m_key1, m_key2;
};
}
diff --git a/src/lib/block/misty1/misty1.cpp b/src/lib/block/misty1/misty1.cpp
index 7f8ac7c76..9afed9168 100644
--- a/src/lib/block/misty1/misty1.cpp
+++ b/src/lib/block/misty1/misty1.cpp
@@ -13,7 +13,7 @@ namespace Botan {
namespace {
-static const byte MISTY1_SBOX_S7[128] = {
+static const uint8_t MISTY1_SBOX_S7[128] = {
0x1B, 0x32, 0x33, 0x5A, 0x3B, 0x10, 0x17, 0x54, 0x5B, 0x1A, 0x72, 0x73,
0x6B, 0x2C, 0x66, 0x49, 0x1F, 0x24, 0x13, 0x6C, 0x37, 0x2E, 0x3F, 0x4A,
0x5D, 0x0F, 0x40, 0x56, 0x25, 0x51, 0x1C, 0x04, 0x0B, 0x46, 0x20, 0x0D,
@@ -26,7 +26,7 @@ static const byte MISTY1_SBOX_S7[128] = {
0x2D, 0x7A, 0x7F, 0x61, 0x50, 0x22, 0x11, 0x06, 0x47, 0x16, 0x52, 0x4E,
0x71, 0x3E, 0x69, 0x43, 0x34, 0x5C, 0x58, 0x7D };
-static const u16bit MISTY1_SBOX_S9[512] = {
+static const uint16_t MISTY1_SBOX_S9[512] = {
0x01C3, 0x00CB, 0x0153, 0x019F, 0x01E3, 0x00E9, 0x00FB, 0x0035, 0x0181,
0x00B9, 0x0117, 0x01EB, 0x0133, 0x0009, 0x002D, 0x00D3, 0x00C7, 0x014A,
0x0037, 0x007E, 0x00EB, 0x0164, 0x0193, 0x01D8, 0x00A3, 0x011E, 0x0055,
@@ -88,13 +88,13 @@ static const u16bit MISTY1_SBOX_S9[512] = {
/*
* MISTY1 FI Function
*/
-u16bit FI(u16bit input, u16bit key7, u16bit key9)
+uint16_t FI(uint16_t input, uint16_t key7, uint16_t key9)
{
- u16bit D9 = input >> 7, D7 = input & 0x7F;
+ uint16_t D9 = input >> 7, D7 = input & 0x7F;
D9 = MISTY1_SBOX_S9[D9] ^ D7;
D7 = (MISTY1_SBOX_S7[D7] ^ key7 ^ D9) & 0x7F;
D9 = MISTY1_SBOX_S9[D9 ^ key9] ^ D7;
- return static_cast<u16bit>((D7 << 9) | D9);
+ return static_cast<uint16_t>((D7 << 9) | D9);
}
}
@@ -102,25 +102,25 @@ u16bit FI(u16bit input, u16bit key7, u16bit key9)
/*
* MISTY1 Encryption
*/
-void MISTY1::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void MISTY1::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u16bit B0 = load_be<u16bit>(in, 0);
- u16bit B1 = load_be<u16bit>(in, 1);
- u16bit B2 = load_be<u16bit>(in, 2);
- u16bit B3 = load_be<u16bit>(in, 3);
+ uint16_t B0 = load_be<uint16_t>(in, 0);
+ uint16_t B1 = load_be<uint16_t>(in, 1);
+ uint16_t B2 = load_be<uint16_t>(in, 2);
+ uint16_t B3 = load_be<uint16_t>(in, 3);
for(size_t j = 0; j != 12; j += 3)
{
- const u16bit* RK = &m_EK[8 * j];
+ const uint16_t* RK = &m_EK[8 * j];
B1 ^= B0 & RK[0];
B0 ^= B1 | RK[1];
B3 ^= B2 & RK[2];
B2 ^= B3 | RK[3];
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = FI(B0 ^ RK[ 4], RK[ 5], RK[ 6]) ^ B1;
T1 = FI(B1 ^ RK[ 7], RK[ 8], RK[ 9]) ^ T0;
@@ -152,25 +152,25 @@ void MISTY1::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* MISTY1 Decryption
*/
-void MISTY1::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void MISTY1::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u16bit B0 = load_be<u16bit>(in, 2);
- u16bit B1 = load_be<u16bit>(in, 3);
- u16bit B2 = load_be<u16bit>(in, 0);
- u16bit B3 = load_be<u16bit>(in, 1);
+ uint16_t B0 = load_be<uint16_t>(in, 2);
+ uint16_t B1 = load_be<uint16_t>(in, 3);
+ uint16_t B2 = load_be<uint16_t>(in, 0);
+ uint16_t B3 = load_be<uint16_t>(in, 1);
for(size_t j = 0; j != 12; j += 3)
{
- const u16bit* RK = &m_DK[8 * j];
+ const uint16_t* RK = &m_DK[8 * j];
B2 ^= B3 | RK[0];
B3 ^= B2 & RK[1];
B0 ^= B1 | RK[2];
B1 ^= B0 & RK[3];
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = FI(B2 ^ RK[ 4], RK[ 5], RK[ 6]) ^ B3;
T1 = FI(B3 ^ RK[ 7], RK[ 8], RK[ 9]) ^ T0;
@@ -202,11 +202,11 @@ void MISTY1::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* MISTY1 Key Schedule
*/
-void MISTY1::key_schedule(const byte key[], size_t length)
+void MISTY1::key_schedule(const uint8_t key[], size_t length)
{
- secure_vector<u16bit> KS(32);
+ secure_vector<uint16_t> KS(32);
for(size_t i = 0; i != length / 2; ++i)
- KS[i] = load_be<u16bit>(key, i);
+ KS[i] = load_be<uint16_t>(key, i);
for(size_t i = 0; i != 8; ++i)
{
@@ -219,7 +219,7 @@ void MISTY1::key_schedule(const byte key[], size_t length)
* Precomputed indexes for the orderings of the subkeys (MISTY1 reuses
* values)
*/
- static const byte EK_ORDER[100] = {
+ static const uint8_t EK_ORDER[100] = {
0x00, 0x0E, 0x0A, 0x04, 0x00, 0x15, 0x1D, 0x02, 0x11, 0x19, 0x07, 0x13,
0x1B, 0x04, 0x01, 0x16, 0x1E, 0x03, 0x12, 0x1A, 0x00, 0x14, 0x1C, 0x05,
0x01, 0x0F, 0x0B, 0x05, 0x02, 0x17, 0x1F, 0x04, 0x13, 0x1B, 0x01, 0x15,
@@ -230,7 +230,7 @@ void MISTY1::key_schedule(const byte key[], size_t length)
0x19, 0x02, 0x07, 0x14, 0x1C, 0x01, 0x10, 0x18, 0x06, 0x12, 0x1A, 0x03,
0x04, 0x0A, 0x0E, 0x00 };
- static const byte DK_ORDER[100] = {
+ static const uint8_t DK_ORDER[100] = {
0x00, 0x0E, 0x0A, 0x04, 0x07, 0x14, 0x1C, 0x01, 0x10, 0x18, 0x06, 0x12,
0x1A, 0x03, 0x06, 0x13, 0x1B, 0x00, 0x17, 0x1F, 0x05, 0x11, 0x19, 0x02,
0x07, 0x0D, 0x09, 0x03, 0x05, 0x12, 0x1A, 0x07, 0x16, 0x1E, 0x04, 0x10,
diff --git a/src/lib/block/misty1/misty1.h b/src/lib/block/misty1/misty1.h
index 791ace6aa..865e6c935 100644
--- a/src/lib/block/misty1/misty1.h
+++ b/src/lib/block/misty1/misty1.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL MISTY1 final : public Block_Cipher_Fixed_Params<8, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "MISTY1"; }
BlockCipher* clone() const override { return new MISTY1; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u16bit> m_EK, m_DK;
+ secure_vector<uint16_t> m_EK, m_DK;
};
}
diff --git a/src/lib/block/noekeon/noekeon.cpp b/src/lib/block/noekeon/noekeon.cpp
index eac0979a4..419f5d01a 100644
--- a/src/lib/block/noekeon/noekeon.cpp
+++ b/src/lib/block/noekeon/noekeon.cpp
@@ -16,11 +16,11 @@ namespace {
/*
* Noekeon's Theta Operation
*/
-inline void theta(u32bit& A0, u32bit& A1,
- u32bit& A2, u32bit& A3,
- const u32bit EK[4])
+inline void theta(uint32_t& A0, uint32_t& A1,
+ uint32_t& A2, uint32_t& A3,
+ const uint32_t EK[4])
{
- u32bit T = A0 ^ A2;
+ uint32_t T = A0 ^ A2;
T ^= rotate_left(T, 8) ^ rotate_right(T, 8);
A1 ^= T;
A3 ^= T;
@@ -39,10 +39,10 @@ inline void theta(u32bit& A0, u32bit& A1,
/*
* Theta With Null Key
*/
-inline void theta(u32bit& A0, u32bit& A1,
- u32bit& A2, u32bit& A3)
+inline void theta(uint32_t& A0, uint32_t& A1,
+ uint32_t& A2, uint32_t& A3)
{
- u32bit T = A0 ^ A2;
+ uint32_t T = A0 ^ A2;
T ^= rotate_left(T, 8) ^ rotate_right(T, 8);
A1 ^= T;
A3 ^= T;
@@ -56,12 +56,12 @@ inline void theta(u32bit& A0, u32bit& A1,
/*
* Noekeon's Gamma S-Box Layer
*/
-inline void gamma(u32bit& A0, u32bit& A1, u32bit& A2, u32bit& A3)
+inline void gamma(uint32_t& A0, uint32_t& A1, uint32_t& A2, uint32_t& A3)
{
A1 ^= ~A3 & ~A2;
A0 ^= A2 & A1;
- u32bit T = A3;
+ uint32_t T = A3;
A3 = A0;
A0 = T;
@@ -88,7 +88,7 @@ std::string Noekeon::provider() const
/*
* Noekeon Round Constants
*/
-const byte Noekeon::RC[] = {
+const uint8_t Noekeon::RC[] = {
0x80, 0x1B, 0x36, 0x6C, 0xD8, 0xAB, 0x4D, 0x9A,
0x2F, 0x5E, 0xBC, 0x63, 0xC6, 0x97, 0x35, 0x6A,
0xD4 };
@@ -96,7 +96,7 @@ const byte Noekeon::RC[] = {
/*
* Noekeon Encryption
*/
-void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Noekeon::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_NOEKEON_SIMD)
if(CPUID::has_simd_32())
@@ -113,10 +113,10 @@ void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
for(size_t i = 0; i != blocks; ++i)
{
- u32bit A0 = load_be<u32bit>(in, 0);
- u32bit A1 = load_be<u32bit>(in, 1);
- u32bit A2 = load_be<u32bit>(in, 2);
- u32bit A3 = load_be<u32bit>(in, 3);
+ uint32_t A0 = load_be<uint32_t>(in, 0);
+ uint32_t A1 = load_be<uint32_t>(in, 1);
+ uint32_t A2 = load_be<uint32_t>(in, 2);
+ uint32_t A3 = load_be<uint32_t>(in, 3);
for(size_t j = 0; j != 16; ++j)
{
@@ -147,7 +147,7 @@ void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Noekeon Encryption
*/
-void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Noekeon::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_NOEKEON_SIMD)
if(CPUID::has_simd_32())
@@ -177,10 +177,10 @@ void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const
for(size_t i = 0; i != blocks; ++i)
{
- u32bit A0 = load_be<u32bit>(in, 0);
- u32bit A1 = load_be<u32bit>(in, 1);
- u32bit A2 = load_be<u32bit>(in, 2);
- u32bit A3 = load_be<u32bit>(in, 3);
+ uint32_t A0 = load_be<uint32_t>(in, 0);
+ uint32_t A1 = load_be<uint32_t>(in, 1);
+ uint32_t A2 = load_be<uint32_t>(in, 2);
+ uint32_t A3 = load_be<uint32_t>(in, 3);
for(size_t j = 16; j != 0; --j)
{
@@ -211,12 +211,12 @@ void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Noekeon Key Schedule
*/
-void Noekeon::key_schedule(const byte key[], size_t)
+void Noekeon::key_schedule(const uint8_t key[], size_t)
{
- u32bit A0 = load_be<u32bit>(key, 0);
- u32bit A1 = load_be<u32bit>(key, 1);
- u32bit A2 = load_be<u32bit>(key, 2);
- u32bit A3 = load_be<u32bit>(key, 3);
+ uint32_t A0 = load_be<uint32_t>(key, 0);
+ uint32_t A1 = load_be<uint32_t>(key, 1);
+ uint32_t A2 = load_be<uint32_t>(key, 2);
+ uint32_t A3 = load_be<uint32_t>(key, 3);
for(size_t i = 0; i != 16; ++i)
{
diff --git a/src/lib/block/noekeon/noekeon.h b/src/lib/block/noekeon/noekeon.h
index b0aa4218c..83af6d8d7 100644
--- a/src/lib/block/noekeon/noekeon.h
+++ b/src/lib/block/noekeon/noekeon.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Noekeon final : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
std::string provider() const override;
void clear() override;
@@ -27,17 +27,17 @@ class BOTAN_DLL Noekeon final : public Block_Cipher_Fixed_Params<16, 16>
BlockCipher* clone() const override { return new Noekeon; }
private:
#if defined(BOTAN_HAS_NOEKEON_SIMD)
- void simd_encrypt_4(const byte in[], byte out[]) const;
- void simd_decrypt_4(const byte in[], byte out[]) const;
+ void simd_encrypt_4(const uint8_t in[], uint8_t out[]) const;
+ void simd_decrypt_4(const uint8_t in[], uint8_t out[]) const;
#endif
/**
* The Noekeon round constants
*/
- static const byte RC[17];
+ static const uint8_t RC[17];
- void key_schedule(const byte[], size_t) override;
- secure_vector<u32bit> m_EK, m_DK;
+ void key_schedule(const uint8_t[], size_t) override;
+ secure_vector<uint32_t> m_EK, m_DK;
};
}
diff --git a/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp b/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp
index e37412b5f..03048ec9c 100644
--- a/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp
+++ b/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp
@@ -63,7 +63,7 @@ namespace Botan {
/*
* Noekeon Encryption
*/
-void Noekeon::simd_encrypt_4(const byte in[], byte out[]) const
+void Noekeon::simd_encrypt_4(const uint8_t in[], uint8_t out[]) const
{
const SIMD_32 K0 = SIMD_32(m_EK[0]);
const SIMD_32 K1 = SIMD_32(m_EK[1]);
@@ -108,7 +108,7 @@ void Noekeon::simd_encrypt_4(const byte in[], byte out[]) const
/*
* Noekeon Encryption
*/
-void Noekeon::simd_decrypt_4(const byte in[], byte out[]) const
+void Noekeon::simd_decrypt_4(const uint8_t in[], uint8_t out[]) const
{
const SIMD_32 K0 = SIMD_32(m_DK[0]);
const SIMD_32 K1 = SIMD_32(m_DK[1]);
diff --git a/src/lib/block/seed/seed.cpp b/src/lib/block/seed/seed.cpp
index 24afed67d..0df35383f 100644
--- a/src/lib/block/seed/seed.cpp
+++ b/src/lib/block/seed/seed.cpp
@@ -12,7 +12,7 @@ namespace Botan {
namespace {
-const u32bit SEED_S0[256] = {
+const uint32_t SEED_S0[256] = {
0x2989A1A8, 0x05858184, 0x16C6D2D4, 0x13C3D3D0, 0x14445054, 0x1D0D111C,
0x2C8CA0AC, 0x25052124, 0x1D4D515C, 0x03434340, 0x18081018, 0x1E0E121C,
0x11415150, 0x3CCCF0FC, 0x0ACAC2C8, 0x23436360, 0x28082028, 0x04444044,
@@ -57,7 +57,7 @@ const u32bit SEED_S0[256] = {
0x07070304, 0x33033330, 0x28C8E0E8, 0x1B0B1318, 0x05050104, 0x39497178,
0x10809090, 0x2A4A6268, 0x2A0A2228, 0x1A8A9298 };
-const u32bit SEED_S1[256] = {
+const uint32_t SEED_S1[256] = {
0x38380830, 0xE828C8E0, 0x2C2D0D21, 0xA42686A2, 0xCC0FCFC3, 0xDC1ECED2,
0xB03383B3, 0xB83888B0, 0xAC2F8FA3, 0x60204060, 0x54154551, 0xC407C7C3,
0x44044440, 0x6C2F4F63, 0x682B4B63, 0x581B4B53, 0xC003C3C3, 0x60224262,
@@ -102,7 +102,7 @@ const u32bit SEED_S1[256] = {
0x080A0A02, 0x84078783, 0xD819C9D1, 0x4C0C4C40, 0x80038383, 0x8C0F8F83,
0xCC0ECEC2, 0x383B0B33, 0x480A4A42, 0xB43787B3 };
-const u32bit SEED_S2[256] = {
+const uint32_t SEED_S2[256] = {
0xA1A82989, 0x81840585, 0xD2D416C6, 0xD3D013C3, 0x50541444, 0x111C1D0D,
0xA0AC2C8C, 0x21242505, 0x515C1D4D, 0x43400343, 0x10181808, 0x121C1E0E,
0x51501141, 0xF0FC3CCC, 0xC2C80ACA, 0x63602343, 0x20282808, 0x40440444,
@@ -147,7 +147,7 @@ const u32bit SEED_S2[256] = {
0x03040707, 0x33303303, 0xE0E828C8, 0x13181B0B, 0x01040505, 0x71783949,
0x90901080, 0x62682A4A, 0x22282A0A, 0x92981A8A };
-const u32bit SEED_S3[256] = {
+const uint32_t SEED_S3[256] = {
0x08303838, 0xC8E0E828, 0x0D212C2D, 0x86A2A426, 0xCFC3CC0F, 0xCED2DC1E,
0x83B3B033, 0x88B0B838, 0x8FA3AC2F, 0x40606020, 0x45515415, 0xC7C3C407,
0x44404404, 0x4F636C2F, 0x4B63682B, 0x4B53581B, 0xC3C3C003, 0x42626022,
@@ -195,7 +195,7 @@ const u32bit SEED_S3[256] = {
/*
* SEED G Function
*/
-inline u32bit SEED_G(u32bit X)
+inline uint32_t SEED_G(uint32_t X)
{
return (SEED_S0[get_byte(3, X)] ^ SEED_S1[get_byte(2, X)] ^
SEED_S2[get_byte(1, X)] ^ SEED_S3[get_byte(0, X)]);
@@ -206,18 +206,18 @@ inline u32bit SEED_G(u32bit X)
/*
* SEED Encryption
*/
-void SEED::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void SEED::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit B0 = load_be<u32bit>(in, 0);
- u32bit B1 = load_be<u32bit>(in, 1);
- u32bit B2 = load_be<u32bit>(in, 2);
- u32bit B3 = load_be<u32bit>(in, 3);
+ uint32_t B0 = load_be<uint32_t>(in, 0);
+ uint32_t B1 = load_be<uint32_t>(in, 1);
+ uint32_t B2 = load_be<uint32_t>(in, 2);
+ uint32_t B3 = load_be<uint32_t>(in, 3);
for(size_t j = 0; j != 16; j += 2)
{
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = B2 ^ m_K[2*j];
T1 = SEED_G(B2 ^ B3 ^ m_K[2*j+1]);
@@ -244,18 +244,18 @@ void SEED::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* SEED Decryption
*/
-void SEED::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void SEED::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit B0 = load_be<u32bit>(in, 0);
- u32bit B1 = load_be<u32bit>(in, 1);
- u32bit B2 = load_be<u32bit>(in, 2);
- u32bit B3 = load_be<u32bit>(in, 3);
+ uint32_t B0 = load_be<uint32_t>(in, 0);
+ uint32_t B1 = load_be<uint32_t>(in, 1);
+ uint32_t B2 = load_be<uint32_t>(in, 2);
+ uint32_t B3 = load_be<uint32_t>(in, 3);
for(size_t j = 0; j != 16; j += 2)
{
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = B2 ^ m_K[30-2*j];
T1 = SEED_G(B2 ^ B3 ^ m_K[31-2*j]);
@@ -282,19 +282,19 @@ void SEED::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* SEED Key Schedule
*/
-void SEED::key_schedule(const byte key[], size_t)
+void SEED::key_schedule(const uint8_t key[], size_t)
{
- const u32bit RC[16] = {
+ const uint32_t RC[16] = {
0x9E3779B9, 0x3C6EF373, 0x78DDE6E6, 0xF1BBCDCC,
0xE3779B99, 0xC6EF3733, 0x8DDE6E67, 0x1BBCDCCF,
0x3779B99E, 0x6EF3733C, 0xDDE6E678, 0xBBCDCCF1,
0x779B99E3, 0xEF3733C6, 0xDE6E678D, 0xBCDCCF1B
};
- secure_vector<u32bit> WK(4);
+ secure_vector<uint32_t> WK(4);
for(size_t i = 0; i != 4; ++i)
- WK[i] = load_be<u32bit>(key, i);
+ WK[i] = load_be<uint32_t>(key, i);
m_K.resize(32);
@@ -303,7 +303,7 @@ void SEED::key_schedule(const byte key[], size_t)
m_K[2*i ] = SEED_G(WK[0] + WK[2] - RC[i]);
m_K[2*i+1] = SEED_G(WK[1] - WK[3] + RC[i]) ^ m_K[2*i];
- byte T = get_byte(3, WK[0]);
+ uint8_t T = get_byte(3, WK[0]);
WK[0] = (WK[0] >> 8) | (get_byte(3, WK[1]) << 24);
WK[1] = (WK[1] >> 8) | (T << 24);
diff --git a/src/lib/block/seed/seed.h b/src/lib/block/seed/seed.h
index 45e691913..99a510e70 100644
--- a/src/lib/block/seed/seed.h
+++ b/src/lib/block/seed/seed.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL SEED final : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "SEED"; }
BlockCipher* clone() const override { return new SEED; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u32bit> m_K;
+ secure_vector<uint32_t> m_K;
};
}
diff --git a/src/lib/block/serpent/serpent.cpp b/src/lib/block/serpent/serpent.cpp
index a1326b888..93af81231 100644
--- a/src/lib/block/serpent/serpent.cpp
+++ b/src/lib/block/serpent/serpent.cpp
@@ -20,7 +20,7 @@ namespace {
/*
* Serpent's Linear Transform
*/
-inline void transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
+inline void transform(uint32_t& B0, uint32_t& B1, uint32_t& B2, uint32_t& B3)
{
B0 = rotate_left(B0, 13); B2 = rotate_left(B2, 3);
B1 ^= B0 ^ B2; B3 ^= B2 ^ (B0 << 3);
@@ -32,7 +32,7 @@ inline void transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
/*
* Serpent's Inverse Linear Transform
*/
-inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
+inline void i_transform(uint32_t& B0, uint32_t& B1, uint32_t& B2, uint32_t& B3)
{
B2 = rotate_right(B2, 22); B0 = rotate_right(B0, 5);
B2 ^= B3 ^ (B1 << 7); B0 ^= B1 ^ B3;
@@ -55,7 +55,7 @@ inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
/*
* Serpent Encryption
*/
-void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Serpent::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_SERPENT_SIMD)
if(CPUID::has_simd_32())
@@ -72,7 +72,7 @@ void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_SIMD_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit B0, B1, B2, B3;
+ uint32_t B0, B1, B2, B3;
load_le(in + 16*i, B0, B1, B2, B3);
key_xor( 0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3);
@@ -115,7 +115,7 @@ void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Serpent Decryption
*/
-void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Serpent::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_SERPENT_SIMD)
if(CPUID::has_simd_32())
@@ -132,7 +132,7 @@ void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_SIMD_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit B0, B1, B2, B3;
+ uint32_t B0, B1, B2, B3;
load_le(in + 16*i, B0, B1, B2, B3);
key_xor(32,B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3);
@@ -179,19 +179,19 @@ void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Serpent Key Schedule
*/
-void Serpent::key_schedule(const byte key[], size_t length)
+void Serpent::key_schedule(const uint8_t key[], size_t length)
{
- const u32bit PHI = 0x9E3779B9;
+ const uint32_t PHI = 0x9E3779B9;
- secure_vector<u32bit> W(140);
+ secure_vector<uint32_t> W(140);
for(size_t i = 0; i != length / 4; ++i)
- W[i] = load_le<u32bit>(key, i);
+ W[i] = load_le<uint32_t>(key, i);
- W[length / 4] |= u32bit(1) << ((length%4)*8);
+ W[length / 4] |= uint32_t(1) << ((length%4)*8);
for(size_t i = 8; i != 140; ++i)
{
- u32bit wi = W[i-8] ^ W[i-5] ^ W[i-3] ^ W[i-1] ^ PHI ^ u32bit(i-8);
+ uint32_t wi = W[i-8] ^ W[i-5] ^ W[i-3] ^ W[i-1] ^ PHI ^ uint32_t(i-8);
W[i] = rotate_left(wi, 11);
}
diff --git a/src/lib/block/serpent/serpent.h b/src/lib/block/serpent/serpent.h
index 218772e0c..4ba385fde 100644
--- a/src/lib/block/serpent/serpent.h
+++ b/src/lib/block/serpent/serpent.h
@@ -19,8 +19,8 @@ namespace Botan {
class BOTAN_DLL Serpent final : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string provider() const override;
@@ -34,33 +34,33 @@ class BOTAN_DLL Serpent final : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
/**
* Encrypt 4 blocks in parallel using SSE2 or AltiVec
*/
- void simd_encrypt_4(const byte in[64], byte out[64]) const;
+ void simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const;
/**
* Decrypt 4 blocks in parallel using SSE2 or AltiVec
*/
- void simd_decrypt_4(const byte in[64], byte out[64]) const;
+ void simd_decrypt_4(const uint8_t in[64], uint8_t out[64]) const;
#endif
/**
* For use by subclasses using SIMD, asm, etc
* @return const reference to the key schedule
*/
- const secure_vector<u32bit>& get_round_keys() const
+ const secure_vector<uint32_t>& get_round_keys() const
{ return m_round_key; }
/**
* For use by subclasses that implement the key schedule
* @param ks is the new key schedule value to set
*/
- void set_round_keys(const u32bit ks[132])
+ void set_round_keys(const uint32_t ks[132])
{
m_round_key.assign(&ks[0], &ks[132]);
}
private:
- void key_schedule(const byte key[], size_t length) override;
- secure_vector<u32bit> m_round_key;
+ void key_schedule(const uint8_t key[], size_t length) override;
+ secure_vector<uint32_t> m_round_key;
};
}
diff --git a/src/lib/block/serpent/serpent_simd/serpent_simd.cpp b/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
index 7571e5511..f69d1f6f5 100644
--- a/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
+++ b/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
@@ -57,7 +57,7 @@ namespace {
/*
* SIMD Serpent Encryption of 4 blocks in parallel
*/
-void Serpent::simd_encrypt_4(const byte in[64], byte out[64]) const
+void Serpent::simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const
{
SIMD_32 B0 = SIMD_32::load_le(in);
SIMD_32 B1 = SIMD_32::load_le(in + 16);
@@ -113,7 +113,7 @@ void Serpent::simd_encrypt_4(const byte in[64], byte out[64]) const
/*
* SIMD Serpent Decryption of 4 blocks in parallel
*/
-void Serpent::simd_decrypt_4(const byte in[64], byte out[64]) const
+void Serpent::simd_decrypt_4(const uint8_t in[64], uint8_t out[64]) const
{
SIMD_32 B0 = SIMD_32::load_le(in);
SIMD_32 B1 = SIMD_32::load_le(in + 16);
diff --git a/src/lib/block/threefish/threefish.cpp b/src/lib/block/threefish/threefish.cpp
index 2acdef020..28a144fb6 100644
--- a/src/lib/block/threefish/threefish.cpp
+++ b/src/lib/block/threefish/threefish.cpp
@@ -54,8 +54,8 @@ namespace Botan {
THREEFISH_INJECT_KEY(R2); \
} while(0)
-void Threefish_512::skein_feedfwd(const secure_vector<u64bit>& M,
- const secure_vector<u64bit>& T)
+void Threefish_512::skein_feedfwd(const secure_vector<uint64_t>& M,
+ const secure_vector<uint64_t>& T)
{
BOTAN_ASSERT(m_K.size() == 9, "Key was set");
BOTAN_ASSERT(M.size() == 8, "Single block");
@@ -64,14 +64,14 @@ void Threefish_512::skein_feedfwd(const secure_vector<u64bit>& M,
m_T[1] = T[1];
m_T[2] = T[0] ^ T[1];
- u64bit X0 = M[0];
- u64bit X1 = M[1];
- u64bit X2 = M[2];
- u64bit X3 = M[3];
- u64bit X4 = M[4];
- u64bit X5 = M[5];
- u64bit X6 = M[6];
- u64bit X7 = M[7];
+ uint64_t X0 = M[0];
+ uint64_t X1 = M[1];
+ uint64_t X2 = M[2];
+ uint64_t X3 = M[3];
+ uint64_t X4 = M[4];
+ uint64_t X5 = M[5];
+ uint64_t X6 = M[6];
+ uint64_t X7 = M[7];
THREEFISH_INJECT_KEY(0);
@@ -110,7 +110,7 @@ std::string Threefish_512::provider() const
return "base";
}
-void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Threefish_512::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_ASSERT(m_K.size() == 9, "Key was set");
BOTAN_ASSERT(m_T.size() == 3, "Tweak was set");
@@ -124,7 +124,7 @@ void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit X0, X1, X2, X3, X4, X5, X6, X7;
+ uint64_t X0, X1, X2, X3, X4, X5, X6, X7;
load_le(in + BLOCK_SIZE*i, X0, X1, X2, X3, X4, X5, X6, X7);
THREEFISH_INJECT_KEY(0);
@@ -147,7 +147,7 @@ void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const
#undef THREEFISH_INJECT_KEY
#undef THREEFISH_ROUND
-void Threefish_512::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Threefish_512::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_ASSERT(m_K.size() == 9, "Key was set");
BOTAN_ASSERT(m_T.size() == 3, "Tweak was set");
@@ -204,7 +204,7 @@ void Threefish_512::decrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit X0, X1, X2, X3, X4, X5, X6, X7;
+ uint64_t X0, X1, X2, X3, X4, X5, X6, X7;
load_le(in + BLOCK_SIZE*i, X0, X1, X2, X3, X4, X5, X6, X7);
THREEFISH_INJECT_KEY(18);
@@ -227,23 +227,23 @@ void Threefish_512::decrypt_n(const byte in[], byte out[], size_t blocks) const
#undef THREEFISH_ROUND
}
-void Threefish_512::set_tweak(const byte tweak[], size_t len)
+void Threefish_512::set_tweak(const uint8_t tweak[], size_t len)
{
if(len != 16)
throw Exception("Threefish-512 requires 128 bit tweak");
m_T.resize(3);
- m_T[0] = load_le<u64bit>(tweak, 0);
- m_T[1] = load_le<u64bit>(tweak, 1);
+ m_T[0] = load_le<uint64_t>(tweak, 0);
+ m_T[1] = load_le<uint64_t>(tweak, 1);
m_T[2] = m_T[0] ^ m_T[1];
}
-void Threefish_512::key_schedule(const byte key[], size_t)
+void Threefish_512::key_schedule(const uint8_t key[], size_t)
{
// todo: define key schedule for smaller keys
m_K.resize(9);
for(size_t i = 0; i != 8; ++i)
- m_K[i] = load_le<u64bit>(key, i);
+ m_K[i] = load_le<uint64_t>(key, i);
m_K[8] = m_K[0] ^ m_K[1] ^ m_K[2] ^ m_K[3] ^
m_K[4] ^ m_K[5] ^ m_K[6] ^ m_K[7] ^ 0x1BD11BDAA9FC1A22;
diff --git a/src/lib/block/threefish/threefish.h b/src/lib/block/threefish/threefish.h
index b02239c93..8fe690f52 100644
--- a/src/lib/block/threefish/threefish.h
+++ b/src/lib/block/threefish/threefish.h
@@ -18,36 +18,36 @@ namespace Botan {
class BOTAN_DLL Threefish_512 final : public Block_Cipher_Fixed_Params<64, 64>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
- void set_tweak(const byte tweak[], size_t len);
+ void set_tweak(const uint8_t tweak[], size_t len);
void clear() override;
std::string provider() const override;
std::string name() const override { return "Threefish-512"; }
BlockCipher* clone() const override { return new Threefish_512; }
protected:
- const secure_vector<u64bit>& get_T() const { return m_T; }
- const secure_vector<u64bit>& get_K() const { return m_K; }
+ const secure_vector<uint64_t>& get_T() const { return m_T; }
+ const secure_vector<uint64_t>& get_K() const { return m_K; }
private:
#if defined(BOTAN_HAS_THREEFISH_512_AVX2)
- void avx2_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void avx2_decrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void avx2_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void avx2_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
#endif
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
// Interface for Skein
friend class Skein_512;
- virtual void skein_feedfwd(const secure_vector<u64bit>& M,
- const secure_vector<u64bit>& T);
+ virtual void skein_feedfwd(const secure_vector<uint64_t>& M,
+ const secure_vector<uint64_t>& T);
// Private data
- secure_vector<u64bit> m_T;
- secure_vector<u64bit> m_K;
+ secure_vector<uint64_t> m_T;
+ secure_vector<uint64_t> m_K;
};
}
diff --git a/src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp b/src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp
index e4a46e3de..b8e2320ae 100644
--- a/src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp
+++ b/src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp
@@ -75,10 +75,10 @@ inline void rotate_keys(__m256i& R0, __m256i& R1, __m256i R2)
}
BOTAN_FUNC_ISA("avx2")
-void Threefish_512::avx2_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Threefish_512::avx2_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u64bit* K = &get_K()[0];
- const u64bit* T_64 = &get_T()[0];
+ const uint64_t* K = &get_K()[0];
+ const uint64_t* T_64 = &get_T()[0];
const __m256i ROTATE_1 = _mm256_set_epi64x(37,19,36,46);
const __m256i ROTATE_2 = _mm256_set_epi64x(42,14,27,33);
@@ -250,10 +250,10 @@ void Threefish_512::avx2_encrypt_n(const byte in[], byte out[], size_t blocks) c
}
BOTAN_FUNC_ISA("avx2")
-void Threefish_512::avx2_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Threefish_512::avx2_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u64bit* K = &get_K()[0];
- const u64bit* T_64 = &get_T()[0];
+ const uint64_t* K = &get_K()[0];
+ const uint64_t* T_64 = &get_T()[0];
const __m256i ROTATE_1 = _mm256_set_epi64x(37,19,36,46);
const __m256i ROTATE_2 = _mm256_set_epi64x(42,14,27,33);
diff --git a/src/lib/block/twofish/twofish.cpp b/src/lib/block/twofish/twofish.cpp
index 0b30d4080..51ef01ea9 100644
--- a/src/lib/block/twofish/twofish.cpp
+++ b/src/lib/block/twofish/twofish.cpp
@@ -17,11 +17,11 @@ namespace Botan {
/*
* Twofish Encryption
*/
-void Twofish::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Twofish::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit A, B, C, D;
+ uint32_t A, B, C, D;
load_le(in + BLOCK_SIZE*i, A, B, C, D);
A ^= m_RK[0];
@@ -31,7 +31,7 @@ void Twofish::encrypt_n(const byte in[], byte out[], size_t blocks) const
for(size_t j = 0; j != 16; j += 2)
{
- u32bit X, Y;
+ uint32_t X, Y;
X = m_SB[ get_byte(3, A)] ^ m_SB[256+get_byte(2, A)] ^
m_SB[512+get_byte(1, A)] ^ m_SB[768+get_byte(0, A)];
@@ -68,11 +68,11 @@ void Twofish::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Twofish Decryption
*/
-void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Twofish::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit A, B, C, D;
+ uint32_t A, B, C, D;
load_le(in + BLOCK_SIZE*i, A, B, C, D);
A ^= m_RK[4];
@@ -82,7 +82,7 @@ void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const
for(size_t j = 0; j != 16; j += 2)
{
- u32bit X, Y;
+ uint32_t X, Y;
X = m_SB[ get_byte(3, A)] ^ m_SB[256+get_byte(2, A)] ^
m_SB[512+get_byte(1, A)] ^ m_SB[768+get_byte(0, A)];
@@ -119,12 +119,12 @@ void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Twofish Key Schedule
*/
-void Twofish::key_schedule(const byte key[], size_t length)
+void Twofish::key_schedule(const uint8_t key[], size_t length)
{
m_SB.resize(1024);
m_RK.resize(40);
- secure_vector<byte> S(16);
+ secure_vector<uint8_t> S(16);
for(size_t i = 0; i != length; ++i)
{
@@ -133,12 +133,12 @@ void Twofish::key_schedule(const byte key[], size_t length)
*/
if(key[i])
{
- byte X = POLY_TO_EXP[key[i] - 1];
+ uint8_t X = POLY_TO_EXP[key[i] - 1];
- byte RS1 = RS[(4*i ) % 32];
- byte RS2 = RS[(4*i+1) % 32];
- byte RS3 = RS[(4*i+2) % 32];
- byte RS4 = RS[(4*i+3) % 32];
+ uint8_t RS1 = RS[(4*i ) % 32];
+ uint8_t RS2 = RS[(4*i+1) % 32];
+ uint8_t RS3 = RS[(4*i+2) % 32];
+ uint8_t RS4 = RS[(4*i+3) % 32];
S[4*(i/8) ] ^= EXP_TO_POLY[(X + POLY_TO_EXP[RS1 - 1]) % 255];
S[4*(i/8)+1] ^= EXP_TO_POLY[(X + POLY_TO_EXP[RS2 - 1]) % 255];
@@ -159,11 +159,11 @@ void Twofish::key_schedule(const byte key[], size_t length)
BOTAN_PARALLEL_FOR(size_t i = 0; i < 40; i += 2)
{
- u32bit X = MDS0[Q0[Q0[i ]^key[ 8]]^key[ 0]] ^
+ uint32_t X = MDS0[Q0[Q0[i ]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[i ]^key[ 9]]^key[ 1]] ^
MDS2[Q1[Q0[i ]^key[10]]^key[ 2]] ^
MDS3[Q1[Q1[i ]^key[11]]^key[ 3]];
- u32bit Y = MDS0[Q0[Q0[i+1]^key[12]]^key[ 4]] ^
+ uint32_t Y = MDS0[Q0[Q0[i+1]^key[12]]^key[ 4]] ^
MDS1[Q0[Q1[i+1]^key[13]]^key[ 5]] ^
MDS2[Q1[Q0[i+1]^key[14]]^key[ 6]] ^
MDS3[Q1[Q1[i+1]^key[15]]^key[ 7]];
@@ -186,11 +186,11 @@ void Twofish::key_schedule(const byte key[], size_t length)
BOTAN_PARALLEL_FOR(size_t i = 0; i < 40; i += 2)
{
- u32bit X = MDS0[Q0[Q0[Q1[i ]^key[16]]^key[ 8]]^key[ 0]] ^
+ uint32_t X = MDS0[Q0[Q0[Q1[i ]^key[16]]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[Q1[i ]^key[17]]^key[ 9]]^key[ 1]] ^
MDS2[Q1[Q0[Q0[i ]^key[18]]^key[10]]^key[ 2]] ^
MDS3[Q1[Q1[Q0[i ]^key[19]]^key[11]]^key[ 3]];
- u32bit Y = MDS0[Q0[Q0[Q1[i+1]^key[20]]^key[12]]^key[ 4]] ^
+ uint32_t Y = MDS0[Q0[Q0[Q1[i+1]^key[20]]^key[12]]^key[ 4]] ^
MDS1[Q0[Q1[Q1[i+1]^key[21]]^key[13]]^key[ 5]] ^
MDS2[Q1[Q0[Q0[i+1]^key[22]]^key[14]]^key[ 6]] ^
MDS3[Q1[Q1[Q0[i+1]^key[23]]^key[15]]^key[ 7]];
@@ -213,11 +213,11 @@ void Twofish::key_schedule(const byte key[], size_t length)
BOTAN_PARALLEL_FOR(size_t i = 0; i < 40; i += 2)
{
- u32bit X = MDS0[Q0[Q0[Q1[Q1[i ]^key[24]]^key[16]]^key[ 8]]^key[ 0]] ^
+ uint32_t X = MDS0[Q0[Q0[Q1[Q1[i ]^key[24]]^key[16]]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[Q1[Q0[i ]^key[25]]^key[17]]^key[ 9]]^key[ 1]] ^
MDS2[Q1[Q0[Q0[Q0[i ]^key[26]]^key[18]]^key[10]]^key[ 2]] ^
MDS3[Q1[Q1[Q0[Q1[i ]^key[27]]^key[19]]^key[11]]^key[ 3]];
- u32bit Y = MDS0[Q0[Q0[Q1[Q1[i+1]^key[28]]^key[20]]^key[12]]^key[ 4]] ^
+ uint32_t Y = MDS0[Q0[Q0[Q1[Q1[i+1]^key[28]]^key[20]]^key[12]]^key[ 4]] ^
MDS1[Q0[Q1[Q1[Q0[i+1]^key[29]]^key[21]]^key[13]]^key[ 5]] ^
MDS2[Q1[Q0[Q0[Q0[i+1]^key[30]]^key[22]]^key[14]]^key[ 6]] ^
MDS3[Q1[Q1[Q0[Q1[i+1]^key[31]]^key[23]]^key[15]]^key[ 7]];
diff --git a/src/lib/block/twofish/twofish.h b/src/lib/block/twofish/twofish.h
index b8021263e..50168ffdf 100644
--- a/src/lib/block/twofish/twofish.h
+++ b/src/lib/block/twofish/twofish.h
@@ -18,26 +18,26 @@ namespace Botan {
class BOTAN_DLL Twofish final : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "Twofish"; }
BlockCipher* clone() const override { return new Twofish; }
private:
- void key_schedule(const byte[], size_t) override;
-
- static const u32bit MDS0[256];
- static const u32bit MDS1[256];
- static const u32bit MDS2[256];
- static const u32bit MDS3[256];
- static const byte Q0[256];
- static const byte Q1[256];
- static const byte RS[32];
- static const byte EXP_TO_POLY[255];
- static const byte POLY_TO_EXP[255];
-
- secure_vector<u32bit> m_SB, m_RK;
+ void key_schedule(const uint8_t[], size_t) override;
+
+ static const uint32_t MDS0[256];
+ static const uint32_t MDS1[256];
+ static const uint32_t MDS2[256];
+ static const uint32_t MDS3[256];
+ static const uint8_t Q0[256];
+ static const uint8_t Q1[256];
+ static const uint8_t RS[32];
+ static const uint8_t EXP_TO_POLY[255];
+ static const uint8_t POLY_TO_EXP[255];
+
+ secure_vector<uint32_t> m_SB, m_RK;
};
}
diff --git a/src/lib/block/twofish/twofish_tab.cpp b/src/lib/block/twofish/twofish_tab.cpp
index 6eb6b62f0..d6ac8f41b 100644
--- a/src/lib/block/twofish/twofish_tab.cpp
+++ b/src/lib/block/twofish/twofish_tab.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-const byte Twofish::Q0[256] = {
+const uint8_t Twofish::Q0[256] = {
0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78,
0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C,
0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30,
@@ -33,7 +33,7 @@ const byte Twofish::Q0[256] = {
0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42,
0x4A, 0x5E, 0xC1, 0xE0 };
-const byte Twofish::Q1[256] = {
+const uint8_t Twofish::Q1[256] = {
0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B,
0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1,
0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B,
@@ -57,12 +57,12 @@ const byte Twofish::Q1[256] = {
0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56,
0x55, 0x09, 0xBE, 0x91 };
-const byte Twofish::RS[32] = {
+const uint8_t Twofish::RS[32] = {
0x01, 0xA4, 0x02, 0xA4, 0xA4, 0x56, 0xA1, 0x55, 0x55, 0x82, 0xFC, 0x87,
0x87, 0xF3, 0xC1, 0x5A, 0x5A, 0x1E, 0x47, 0x58, 0x58, 0xC6, 0xAE, 0xDB,
0xDB, 0x68, 0x3D, 0x9E, 0x9E, 0xE5, 0x19, 0x03 };
-const byte Twofish::EXP_TO_POLY[255] = {
+const uint8_t Twofish::EXP_TO_POLY[255] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D, 0x9A, 0x79, 0xF2,
0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC, 0xF5, 0xA7, 0x03,
0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3, 0x8B, 0x5B, 0xB6,
@@ -86,7 +86,7 @@ const byte Twofish::EXP_TO_POLY[255] = {
0x3B, 0x76, 0xEC, 0x95, 0x67, 0xCE, 0xD1, 0xEF, 0x93, 0x6B, 0xD6, 0xE1,
0x8F, 0x53, 0xA6 };
-const byte Twofish::POLY_TO_EXP[255] = {
+const uint8_t Twofish::POLY_TO_EXP[255] = {
0x00, 0x01, 0x17, 0x02, 0x2E, 0x18, 0x53, 0x03, 0x6A, 0x2F, 0x93, 0x19,
0x34, 0x54, 0x45, 0x04, 0x5C, 0x6B, 0xB6, 0x30, 0xA6, 0x94, 0x4B, 0x1A,
0x8C, 0x35, 0x81, 0x55, 0xAA, 0x46, 0x0D, 0x05, 0x24, 0x5D, 0x87, 0x6C,
@@ -110,7 +110,7 @@ const byte Twofish::POLY_TO_EXP[255] = {
0xB4, 0x0B, 0x7F, 0x51, 0x15, 0x43, 0x91, 0x10, 0x71, 0xBB, 0xEE, 0xBF,
0x85, 0xC8, 0xA1 };
-const u32bit Twofish::MDS0[256] = {
+const uint32_t Twofish::MDS0[256] = {
0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B,
0xE2E22BFB, 0x9E9EFAC8, 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B,
0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, 0x3C3C57D6, 0x93938A32,
@@ -155,7 +155,7 @@ const u32bit Twofish::MDS0[256] = {
0x04047FF6, 0x272746C2, 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756,
0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91 };
-const u32bit Twofish::MDS1[256] = {
+const uint32_t Twofish::MDS1[256] = {
0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252,
0xA3658080, 0x76DFE4E4, 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A,
0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, 0x0D54E6E6, 0xC6432020,
@@ -200,7 +200,7 @@ const u32bit Twofish::MDS1[256] = {
0x0FE25151, 0x00000000, 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7,
0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8 };
-const u32bit Twofish::MDS2[256] = {
+const uint32_t Twofish::MDS2[256] = {
0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B,
0xE2FBE22B, 0x9EC89EFA, 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F,
0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, 0x3CD63C57, 0x9332938A,
@@ -245,7 +245,7 @@ const u32bit Twofish::MDS2[256] = {
0x04F6047F, 0x27C22746, 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7,
0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF };
-const u32bit Twofish::MDS3[256] = {
+const uint32_t Twofish::MDS3[256] = {
0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98,
0x6580A365, 0xDFE476DF, 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866,
0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, 0x54E60D54, 0x4320C643,
diff --git a/src/lib/block/xtea/xtea.cpp b/src/lib/block/xtea/xtea.cpp
index 4e5ca7e7c..b53de448b 100644
--- a/src/lib/block/xtea/xtea.cpp
+++ b/src/lib/block/xtea/xtea.cpp
@@ -13,16 +13,16 @@ namespace Botan {
/*
* XTEA Encryption
*/
-void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void XTEA::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u32bit* EK = &m_EK[0];
+ const uint32_t* EK = &m_EK[0];
const size_t blocks4 = blocks / 4;
const size_t blocks_left = blocks % 4;
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks4; i++)
{
- u32bit L0, R0, L1, R1, L2, R2, L3, R3;
+ uint32_t L0, R0, L1, R1, L2, R2, L3, R3;
load_be(in + 4*BLOCK_SIZE*i, L0, R0, L1, R1, L2, R2, L3, R3);
for(size_t r = 0; r != 32; ++r)
@@ -43,7 +43,7 @@ void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks_left; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*(4*blocks4+i), L, R);
for(size_t r = 0; r != 32; ++r)
@@ -59,16 +59,16 @@ void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* XTEA Decryption
*/
-void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void XTEA::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u32bit* EK = &m_EK[0];
+ const uint32_t* EK = &m_EK[0];
const size_t blocks4 = blocks / 4;
const size_t blocks_left = blocks % 4;
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks4; i++)
{
- u32bit L0, R0, L1, R1, L2, R2, L3, R3;
+ uint32_t L0, R0, L1, R1, L2, R2, L3, R3;
load_be(in + 4*BLOCK_SIZE*i, L0, R0, L1, R1, L2, R2, L3, R3);
for(size_t r = 0; r != 32; ++r)
@@ -89,7 +89,7 @@ void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks_left; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*(4*blocks4+i), L, R);
for(size_t r = 0; r != 32; ++r)
@@ -105,15 +105,15 @@ void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* XTEA Key Schedule
*/
-void XTEA::key_schedule(const byte key[], size_t)
+void XTEA::key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(64);
- secure_vector<u32bit> UK(4);
+ secure_vector<uint32_t> UK(4);
for(size_t i = 0; i != 4; ++i)
- UK[i] = load_be<u32bit>(key, i);
+ UK[i] = load_be<uint32_t>(key, i);
- u32bit D = 0;
+ uint32_t D = 0;
for(size_t i = 0; i != 64; i += 2)
{
m_EK[i ] = D + UK[D % 4];
diff --git a/src/lib/block/xtea/xtea.h b/src/lib/block/xtea/xtea.h
index 3baccc866..cf9bedc4a 100644
--- a/src/lib/block/xtea/xtea.h
+++ b/src/lib/block/xtea/xtea.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL XTEA : public Block_Cipher_Fixed_Params<8, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "XTEA"; }
@@ -28,11 +28,11 @@ class BOTAN_DLL XTEA : public Block_Cipher_Fixed_Params<8, 16>
/**
* @return const reference to the key schedule
*/
- const secure_vector<u32bit>& get_EK() const { return m_EK; }
+ const secure_vector<uint32_t>& get_EK() const { return m_EK; }
private:
- void key_schedule(const byte[], size_t) override;
- secure_vector<u32bit> m_EK;
+ void key_schedule(const uint8_t[], size_t) override;
+ secure_vector<uint32_t> m_EK;
};
}
diff --git a/src/lib/codec/base64/base64.cpp b/src/lib/codec/base64/base64.cpp
index bd4d36cfa..c854e52b0 100644
--- a/src/lib/codec/base64/base64.cpp
+++ b/src/lib/codec/base64/base64.cpp
@@ -14,7 +14,7 @@ namespace Botan {
namespace {
-static const byte BIN_TO_BASE64[64] = {
+static const uint8_t BIN_TO_BASE64[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
@@ -22,7 +22,7 @@ static const byte BIN_TO_BASE64[64] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
};
-void do_base64_encode(char out[4], const byte in[3])
+void do_base64_encode(char out[4], const uint8_t in[3])
{
out[0] = BIN_TO_BASE64[((in[0] & 0xFC) >> 2)];
out[1] = BIN_TO_BASE64[((in[0] & 0x03) << 4) | (in[1] >> 4)];
@@ -33,7 +33,7 @@ void do_base64_encode(char out[4], const byte in[3])
}
size_t base64_encode(char out[],
- const byte in[],
+ const uint8_t in[],
size_t input_length,
size_t& input_consumed,
bool final_inputs)
@@ -54,7 +54,7 @@ size_t base64_encode(char out[],
if(final_inputs && input_remaining)
{
- byte remainder[3] = { 0 };
+ uint8_t remainder[3] = { 0 };
for(size_t i = 0; i != input_remaining; ++i)
remainder[i] = in[input_consumed + i];
@@ -75,7 +75,7 @@ size_t base64_encode(char out[],
return output_produced;
}
-std::string base64_encode(const byte input[],
+std::string base64_encode(const uint8_t input[],
size_t input_length)
{
const size_t output_length = (round_up(input_length, 3) / 3) * 4;
@@ -97,7 +97,7 @@ std::string base64_encode(const byte input[],
return output;
}
-size_t base64_decode(byte output[],
+size_t base64_decode(uint8_t output[],
const char input[],
size_t input_length,
size_t& input_consumed,
@@ -108,7 +108,7 @@ size_t base64_decode(byte output[],
* Base64 Decoder Lookup Table
* Warning: assumes ASCII encodings
*/
- static const byte BASE64_TO_BIN[256] = {
+ static const uint8_t BASE64_TO_BIN[256] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80,
0x80, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -136,8 +136,8 @@ size_t base64_decode(byte output[],
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
- byte* out_ptr = output;
- byte decode_buf[4];
+ uint8_t* out_ptr = output;
+ uint8_t decode_buf[4];
size_t decode_buf_pos = 0;
size_t final_truncate = 0;
@@ -145,7 +145,7 @@ size_t base64_decode(byte output[],
for(size_t i = 0; i != input_length; ++i)
{
- const byte bin = BASE64_TO_BIN[static_cast<byte>(input[i])];
+ const uint8_t bin = BASE64_TO_BIN[static_cast<uint8_t>(input[i])];
if(bin <= 0x3F)
{
@@ -194,7 +194,7 @@ size_t base64_decode(byte output[],
}
while(input_consumed < input_length &&
- BASE64_TO_BIN[static_cast<byte>(input[input_consumed])] == 0x80)
+ BASE64_TO_BIN[static_cast<uint8_t>(input[input_consumed])] == 0x80)
{
++input_consumed;
}
@@ -204,7 +204,7 @@ size_t base64_decode(byte output[],
return written;
}
-size_t base64_decode(byte output[],
+size_t base64_decode(uint8_t output[],
const char input[],
size_t input_length,
bool ignore_ws)
@@ -219,19 +219,19 @@ size_t base64_decode(byte output[],
return written;
}
-size_t base64_decode(byte output[],
+size_t base64_decode(uint8_t output[],
const std::string& input,
bool ignore_ws)
{
return base64_decode(output, input.data(), input.length(), ignore_ws);
}
-secure_vector<byte> base64_decode(const char input[],
+secure_vector<uint8_t> base64_decode(const char input[],
size_t input_length,
bool ignore_ws)
{
const size_t output_length = (round_up(input_length, 4) * 3) / 4;
- secure_vector<byte> bin(output_length);
+ secure_vector<uint8_t> bin(output_length);
size_t written = base64_decode(bin.data(),
input,
@@ -242,7 +242,7 @@ secure_vector<byte> base64_decode(const char input[],
return bin;
}
-secure_vector<byte> base64_decode(const std::string& input,
+secure_vector<uint8_t> base64_decode(const std::string& input,
bool ignore_ws)
{
return base64_decode(input.data(), input.size(), ignore_ws);
diff --git a/src/lib/codec/base64/base64.h b/src/lib/codec/base64/base64.h
index 92c4dc627..0e78ea3c2 100644
--- a/src/lib/codec/base64/base64.h
+++ b/src/lib/codec/base64/base64.h
@@ -27,7 +27,7 @@ namespace Botan {
* @return number of bytes written to output
*/
size_t BOTAN_DLL base64_encode(char output[],
- const byte input[],
+ const uint8_t input[],
size_t input_length,
size_t& input_consumed,
bool final_inputs);
@@ -38,7 +38,7 @@ size_t BOTAN_DLL base64_encode(char output[],
* @param input_length length of input in bytes
* @return base64adecimal representation of input
*/
-std::string BOTAN_DLL base64_encode(const byte input[],
+std::string BOTAN_DLL base64_encode(const uint8_t input[],
size_t input_length);
/**
@@ -47,7 +47,7 @@ std::string BOTAN_DLL base64_encode(const byte input[],
* @return base64adecimal representation of input
*/
template<typename Alloc>
-std::string base64_encode(const std::vector<byte, Alloc>& input)
+std::string base64_encode(const std::vector<uint8_t, Alloc>& input)
{
return base64_encode(input.data(), input.size());
}
@@ -67,7 +67,7 @@ std::string base64_encode(const std::vector<byte, Alloc>& input)
exception if whitespace is encountered
* @return number of bytes written to output
*/
-size_t BOTAN_DLL base64_decode(byte output[],
+size_t BOTAN_DLL base64_decode(uint8_t output[],
const char input[],
size_t input_length,
size_t& input_consumed,
@@ -83,7 +83,7 @@ size_t BOTAN_DLL base64_decode(byte output[],
exception if whitespace is encountered
* @return number of bytes written to output
*/
-size_t BOTAN_DLL base64_decode(byte output[],
+size_t BOTAN_DLL base64_decode(uint8_t output[],
const char input[],
size_t input_length,
bool ignore_ws = true);
@@ -96,7 +96,7 @@ size_t BOTAN_DLL base64_decode(byte output[],
exception if whitespace is encountered
* @return number of bytes written to output
*/
-size_t BOTAN_DLL base64_decode(byte output[],
+size_t BOTAN_DLL base64_decode(uint8_t output[],
const std::string& input,
bool ignore_ws = true);
@@ -108,7 +108,7 @@ size_t BOTAN_DLL base64_decode(byte output[],
exception if whitespace is encountered
* @return decoded base64 output
*/
-secure_vector<byte> BOTAN_DLL base64_decode(const char input[],
+secure_vector<uint8_t> BOTAN_DLL base64_decode(const char input[],
size_t input_length,
bool ignore_ws = true);
@@ -119,7 +119,7 @@ secure_vector<byte> BOTAN_DLL base64_decode(const char input[],
exception if whitespace is encountered
* @return decoded base64 output
*/
-secure_vector<byte> BOTAN_DLL base64_decode(const std::string& input,
+secure_vector<uint8_t> BOTAN_DLL base64_decode(const std::string& input,
bool ignore_ws = true);
}
diff --git a/src/lib/codec/hex/hex.cpp b/src/lib/codec/hex/hex.cpp
index e47a75cb7..8d8d3ff49 100644
--- a/src/lib/codec/hex/hex.cpp
+++ b/src/lib/codec/hex/hex.cpp
@@ -12,29 +12,29 @@
namespace Botan {
void hex_encode(char output[],
- const byte input[],
+ const uint8_t input[],
size_t input_length,
bool uppercase)
{
- static const byte BIN_TO_HEX_UPPER[16] = {
+ static const uint8_t BIN_TO_HEX_UPPER[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F' };
- static const byte BIN_TO_HEX_LOWER[16] = {
+ static const uint8_t BIN_TO_HEX_LOWER[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f' };
- const byte* tbl = uppercase ? BIN_TO_HEX_UPPER : BIN_TO_HEX_LOWER;
+ const uint8_t* tbl = uppercase ? BIN_TO_HEX_UPPER : BIN_TO_HEX_LOWER;
for(size_t i = 0; i != input_length; ++i)
{
- byte x = input[i];
+ uint8_t x = input[i];
output[2*i ] = tbl[(x >> 4) & 0x0F];
output[2*i+1] = tbl[(x ) & 0x0F];
}
}
-std::string hex_encode(const byte input[],
+std::string hex_encode(const uint8_t input[],
size_t input_length,
bool uppercase)
{
@@ -46,7 +46,7 @@ std::string hex_encode(const byte input[],
return output;
}
-size_t hex_decode(byte output[],
+size_t hex_decode(uint8_t output[],
const char input[],
size_t input_length,
size_t& input_consumed,
@@ -61,7 +61,7 @@ size_t hex_decode(byte output[],
* Warning: this table assumes ASCII character encodings
*/
- static const byte HEX_TO_BIN[256] = {
+ static const uint8_t HEX_TO_BIN[256] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80,
0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -89,14 +89,14 @@ size_t hex_decode(byte output[],
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
- byte* out_ptr = output;
+ uint8_t* out_ptr = output;
bool top_nibble = true;
clear_mem(output, input_length / 2);
for(size_t i = 0; i != input_length; ++i)
{
- const byte bin = HEX_TO_BIN[static_cast<byte>(input[i])];
+ const uint8_t bin = HEX_TO_BIN[static_cast<uint8_t>(input[i])];
if(bin >= 0x10)
{
@@ -125,7 +125,7 @@ size_t hex_decode(byte output[],
size_t written = (out_ptr - output);
/*
- * We only got half of a byte at the end; zap the half-written
+ * We only got half of a uint8_t at the end; zap the half-written
* output and mark it as unread
*/
if(!top_nibble)
@@ -137,7 +137,7 @@ size_t hex_decode(byte output[],
return written;
}
-size_t hex_decode(byte output[],
+size_t hex_decode(uint8_t output[],
const char input[],
size_t input_length,
bool ignore_ws)
@@ -152,18 +152,18 @@ size_t hex_decode(byte output[],
return written;
}
-size_t hex_decode(byte output[],
+size_t hex_decode(uint8_t output[],
const std::string& input,
bool ignore_ws)
{
return hex_decode(output, input.data(), input.length(), ignore_ws);
}
-secure_vector<byte> hex_decode_locked(const char input[],
+secure_vector<uint8_t> hex_decode_locked(const char input[],
size_t input_length,
bool ignore_ws)
{
- secure_vector<byte> bin(1 + input_length / 2);
+ secure_vector<uint8_t> bin(1 + input_length / 2);
size_t written = hex_decode(bin.data(),
input,
@@ -174,17 +174,17 @@ secure_vector<byte> hex_decode_locked(const char input[],
return bin;
}
-secure_vector<byte> hex_decode_locked(const std::string& input,
+secure_vector<uint8_t> hex_decode_locked(const std::string& input,
bool ignore_ws)
{
return hex_decode_locked(input.data(), input.size(), ignore_ws);
}
-std::vector<byte> hex_decode(const char input[],
+std::vector<uint8_t> hex_decode(const char input[],
size_t input_length,
bool ignore_ws)
{
- std::vector<byte> bin(1 + input_length / 2);
+ std::vector<uint8_t> bin(1 + input_length / 2);
size_t written = hex_decode(bin.data(),
input,
@@ -195,7 +195,7 @@ std::vector<byte> hex_decode(const char input[],
return bin;
}
-std::vector<byte> hex_decode(const std::string& input,
+std::vector<uint8_t> hex_decode(const std::string& input,
bool ignore_ws)
{
return hex_decode(input.data(), input.size(), ignore_ws);
diff --git a/src/lib/codec/hex/hex.h b/src/lib/codec/hex/hex.h
index b524c43f0..2927640e2 100644
--- a/src/lib/codec/hex/hex.h
+++ b/src/lib/codec/hex/hex.h
@@ -21,7 +21,7 @@ namespace Botan {
* @param uppercase should output be upper or lower case?
*/
void BOTAN_DLL hex_encode(char output[],
- const byte input[],
+ const uint8_t input[],
size_t input_length,
bool uppercase = true);
@@ -32,7 +32,7 @@ void BOTAN_DLL hex_encode(char output[],
* @param uppercase should output be upper or lower case?
* @return hexadecimal representation of input
*/
-std::string BOTAN_DLL hex_encode(const byte input[],
+std::string BOTAN_DLL hex_encode(const uint8_t input[],
size_t input_length,
bool uppercase = true);
@@ -43,7 +43,7 @@ std::string BOTAN_DLL hex_encode(const byte input[],
* @return hexadecimal representation of input
*/
template<typename Alloc>
-std::string hex_encode(const std::vector<byte, Alloc>& input,
+std::string hex_encode(const std::vector<uint8_t, Alloc>& input,
bool uppercase = true)
{
return hex_encode(input.data(), input.size(), uppercase);
@@ -62,7 +62,7 @@ std::string hex_encode(const std::vector<byte, Alloc>& input,
exception if whitespace is encountered
* @return number of bytes written to output
*/
-size_t BOTAN_DLL hex_decode(byte output[],
+size_t BOTAN_DLL hex_decode(uint8_t output[],
const char input[],
size_t input_length,
size_t& input_consumed,
@@ -77,7 +77,7 @@ size_t BOTAN_DLL hex_decode(byte output[],
exception if whitespace is encountered
* @return number of bytes written to output
*/
-size_t BOTAN_DLL hex_decode(byte output[],
+size_t BOTAN_DLL hex_decode(uint8_t output[],
const char input[],
size_t input_length,
bool ignore_ws = true);
@@ -90,7 +90,7 @@ size_t BOTAN_DLL hex_decode(byte output[],
exception if whitespace is encountered
* @return number of bytes written to output
*/
-size_t BOTAN_DLL hex_decode(byte output[],
+size_t BOTAN_DLL hex_decode(uint8_t output[],
const std::string& input,
bool ignore_ws = true);
@@ -102,7 +102,7 @@ size_t BOTAN_DLL hex_decode(byte output[],
exception if whitespace is encountered
* @return decoded hex output
*/
-std::vector<byte> BOTAN_DLL
+std::vector<uint8_t> BOTAN_DLL
hex_decode(const char input[],
size_t input_length,
bool ignore_ws = true);
@@ -114,7 +114,7 @@ hex_decode(const char input[],
exception if whitespace is encountered
* @return decoded hex output
*/
-std::vector<byte> BOTAN_DLL
+std::vector<uint8_t> BOTAN_DLL
hex_decode(const std::string& input,
bool ignore_ws = true);
@@ -127,7 +127,7 @@ hex_decode(const std::string& input,
exception if whitespace is encountered
* @return decoded hex output
*/
-secure_vector<byte> BOTAN_DLL
+secure_vector<uint8_t> BOTAN_DLL
hex_decode_locked(const char input[],
size_t input_length,
bool ignore_ws = true);
@@ -139,7 +139,7 @@ hex_decode_locked(const char input[],
exception if whitespace is encountered
* @return decoded hex output
*/
-secure_vector<byte> BOTAN_DLL
+secure_vector<uint8_t> BOTAN_DLL
hex_decode_locked(const std::string& input,
bool ignore_ws = true);
diff --git a/src/lib/compression/bzip2/bzip2.cpp b/src/lib/compression/bzip2/bzip2.cpp
index 1d1af7e29..4ebf572c9 100644
--- a/src/lib/compression/bzip2/bzip2.cpp
+++ b/src/lib/compression/bzip2/bzip2.cpp
@@ -28,9 +28,9 @@ class Bzip2_Stream : public Zlib_Style_Stream<bz_stream, char>
streamp()->bzfree = Compression_Alloc_Info::free;
}
- u32bit run_flag() const override { return BZ_RUN; }
- u32bit flush_flag() const override { return BZ_FLUSH; }
- u32bit finish_flag() const override { return BZ_FINISH; }
+ uint32_t run_flag() const override { return BZ_RUN; }
+ uint32_t flush_flag() const override { return BZ_FLUSH; }
+ uint32_t finish_flag() const override { return BZ_FINISH; }
};
class Bzip2_Compression_Stream : public Bzip2_Stream
@@ -59,7 +59,7 @@ class Bzip2_Compression_Stream : public Bzip2_Stream
BZ2_bzCompressEnd(streamp());
}
- bool run(u32bit flags) override
+ bool run(uint32_t flags) override
{
int rc = BZ2_bzCompress(streamp(), flags);
@@ -90,7 +90,7 @@ class Bzip2_Decompression_Stream : public Bzip2_Stream
BZ2_bzDecompressEnd(streamp());
}
- bool run(u32bit) override
+ bool run(uint32_t) override
{
int rc = BZ2_bzDecompress(streamp());
diff --git a/src/lib/compression/compress_utils.cpp b/src/lib/compression/compress_utils.cpp
index 65361fba8..06e7fea53 100644
--- a/src/lib/compression/compress_utils.cpp
+++ b/src/lib/compression/compress_utils.cpp
@@ -62,7 +62,7 @@ void Stream_Compression::start(size_t level)
m_stream.reset(make_stream(level));
}
-void Stream_Compression::process(secure_vector<byte>& buf, size_t offset, u32bit flags)
+void Stream_Compression::process(secure_vector<uint8_t>& buf, size_t offset, uint32_t flags)
{
BOTAN_ASSERT(m_stream, "Initialized");
BOTAN_ASSERT(buf.size() >= offset, "Offset is sane");
@@ -102,13 +102,13 @@ void Stream_Compression::process(secure_vector<byte>& buf, size_t offset, u32bit
buf.swap(m_buffer);
}
-void Stream_Compression::update(secure_vector<byte>& buf, size_t offset, bool flush)
+void Stream_Compression::update(secure_vector<uint8_t>& buf, size_t offset, bool flush)
{
BOTAN_ASSERT(m_stream, "Initialized");
process(buf, offset, flush ? m_stream->flush_flag() : m_stream->run_flag());
}
-void Stream_Compression::finish(secure_vector<byte>& buf, size_t offset)
+void Stream_Compression::finish(secure_vector<uint8_t>& buf, size_t offset)
{
BOTAN_ASSERT(m_stream, "Initialized");
process(buf, offset, m_stream->finish_flag());
@@ -125,7 +125,7 @@ void Stream_Decompression::start()
m_stream.reset(make_stream());
}
-void Stream_Decompression::process(secure_vector<byte>& buf, size_t offset, u32bit flags)
+void Stream_Decompression::process(secure_vector<uint8_t>& buf, size_t offset, uint32_t flags)
{
BOTAN_ASSERT(m_stream, "Initialized");
BOTAN_ASSERT(buf.size() >= offset, "Offset is sane");
@@ -172,12 +172,12 @@ void Stream_Decompression::process(secure_vector<byte>& buf, size_t offset, u32b
buf.swap(m_buffer);
}
-void Stream_Decompression::update(secure_vector<byte>& buf, size_t offset)
+void Stream_Decompression::update(secure_vector<uint8_t>& buf, size_t offset)
{
process(buf, offset, m_stream->run_flag());
}
-void Stream_Decompression::finish(secure_vector<byte>& buf, size_t offset)
+void Stream_Decompression::finish(secure_vector<uint8_t>& buf, size_t offset)
{
if(buf.size() != offset || m_stream.get())
process(buf, offset, m_stream->finish_flag());
diff --git a/src/lib/compression/compress_utils.h b/src/lib/compression/compress_utils.h
index 9f6871a0b..a34faef69 100644
--- a/src/lib/compression/compress_utils.h
+++ b/src/lib/compression/compress_utils.h
@@ -45,13 +45,13 @@ template<typename Stream, typename ByteType>
class Zlib_Style_Stream : public Compression_Stream
{
public:
- void next_in(byte* b, size_t len) override
+ void next_in(uint8_t* b, size_t len) override
{
m_stream.next_in = reinterpret_cast<ByteType*>(b);
m_stream.avail_in = len;
}
- void next_out(byte* b, size_t len) override
+ void next_out(uint8_t* b, size_t len) override
{
m_stream.next_out = reinterpret_cast<ByteType*>(b);
m_stream.avail_out = len;
diff --git a/src/lib/compression/compression.h b/src/lib/compression/compression.h
index 1c429195c..ad5ed45c5 100644
--- a/src/lib/compression/compression.h
+++ b/src/lib/compression/compression.h
@@ -30,12 +30,12 @@ class BOTAN_DLL Compression_Algorithm
virtual void start(size_t comp_level = 0) = 0;
/**
- * Process some data. Input must be in size update_granularity() byte blocks.
+ * Process some data. Input must be in size update_granularity() uint8_t blocks.
* @param buf in/out parameter which will possibly be resized or swapped
* @param offset an offset into blocks to begin processing
* @param flush if true the compressor will be told to flush state
*/
- virtual void update(secure_vector<byte>& buf, size_t offset = 0, bool flush = false) = 0;
+ virtual void update(secure_vector<uint8_t>& buf, size_t offset = 0, bool flush = false) = 0;
/**
* Finish compressing
@@ -43,7 +43,7 @@ class BOTAN_DLL Compression_Algorithm
* @param final_block in/out parameter
* @param offset an offset into final_block to begin processing
*/
- virtual void finish(secure_vector<byte>& final_block, size_t offset = 0) = 0;
+ virtual void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) = 0;
/**
* @return name of the compression algorithm
@@ -72,11 +72,11 @@ class BOTAN_DLL Decompression_Algorithm
virtual void start() = 0;
/**
- * Process some data. Input must be in size update_granularity() byte blocks.
+ * Process some data. Input must be in size update_granularity() uint8_t blocks.
* @param buf in/out parameter which will possibly be resized or swapped
* @param offset an offset into blocks to begin processing
*/
- virtual void update(secure_vector<byte>& buf, size_t offset = 0) = 0;
+ virtual void update(secure_vector<uint8_t>& buf, size_t offset = 0) = 0;
/**
* Finish decompressing
@@ -84,7 +84,7 @@ class BOTAN_DLL Decompression_Algorithm
* @param final_block in/out parameter
* @param offset an offset into final_block to begin processing
*/
- virtual void finish(secure_vector<byte>& final_block, size_t offset = 0) = 0;
+ virtual void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) = 0;
/**
* @return name of the decompression algorithm
@@ -111,19 +111,19 @@ class Compression_Stream
public:
virtual ~Compression_Stream() {}
- virtual void next_in(byte* b, size_t len) = 0;
+ virtual void next_in(uint8_t* b, size_t len) = 0;
- virtual void next_out(byte* b, size_t len) = 0;
+ virtual void next_out(uint8_t* b, size_t len) = 0;
virtual size_t avail_in() const = 0;
virtual size_t avail_out() const = 0;
- virtual u32bit run_flag() const = 0;
- virtual u32bit flush_flag() const = 0;
- virtual u32bit finish_flag() const = 0;
+ virtual uint32_t run_flag() const = 0;
+ virtual uint32_t flush_flag() const = 0;
+ virtual uint32_t finish_flag() const = 0;
- virtual bool run(u32bit flags) = 0;
+ virtual bool run(uint32_t flags) = 0;
};
/**
@@ -132,20 +132,20 @@ class Compression_Stream
class Stream_Compression : public Compression_Algorithm
{
public:
- void update(secure_vector<byte>& buf, size_t offset, bool flush) final override;
+ void update(secure_vector<uint8_t>& buf, size_t offset, bool flush) final override;
- void finish(secure_vector<byte>& buf, size_t offset) final override;
+ void finish(secure_vector<uint8_t>& buf, size_t offset) final override;
void clear() final override;
private:
void start(size_t level) final override;
- void process(secure_vector<byte>& buf, size_t offset, u32bit flags);
+ void process(secure_vector<uint8_t>& buf, size_t offset, uint32_t flags);
virtual Compression_Stream* make_stream(size_t level) const = 0;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
std::unique_ptr<Compression_Stream> m_stream;
};
@@ -155,20 +155,20 @@ class Stream_Compression : public Compression_Algorithm
class Stream_Decompression : public Decompression_Algorithm
{
public:
- void update(secure_vector<byte>& buf, size_t offset) final override;
+ void update(secure_vector<uint8_t>& buf, size_t offset) final override;
- void finish(secure_vector<byte>& buf, size_t offset) final override;
+ void finish(secure_vector<uint8_t>& buf, size_t offset) final override;
void clear() final override;
private:
void start() final override;
- void process(secure_vector<byte>& buf, size_t offset, u32bit flags);
+ void process(secure_vector<uint8_t>& buf, size_t offset, uint32_t flags);
virtual Compression_Stream* make_stream() const = 0;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
std::unique_ptr<Compression_Stream> m_stream;
};
diff --git a/src/lib/compression/lzma/lzma.cpp b/src/lib/compression/lzma/lzma.cpp
index 3831ef68c..44af1ee67 100644
--- a/src/lib/compression/lzma/lzma.cpp
+++ b/src/lib/compression/lzma/lzma.cpp
@@ -17,7 +17,7 @@ namespace Botan {
namespace {
-class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte>
+class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, uint8_t>
{
public:
LZMA_Stream()
@@ -35,7 +35,7 @@ class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte>
delete streamp()->allocator;
}
- bool run(u32bit flags) override
+ bool run(uint32_t flags) override
{
lzma_ret rc = ::lzma_code(streamp(), static_cast<lzma_action>(flags));
@@ -47,9 +47,9 @@ class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte>
return (rc == LZMA_STREAM_END);
}
- u32bit run_flag() const override { return LZMA_RUN; }
- u32bit flush_flag() const override { return LZMA_FULL_FLUSH; }
- u32bit finish_flag() const override { return LZMA_FINISH; }
+ uint32_t run_flag() const override { return LZMA_RUN; }
+ uint32_t flush_flag() const override { return LZMA_FULL_FLUSH; }
+ uint32_t finish_flag() const override { return LZMA_FINISH; }
};
class LZMA_Compression_Stream : public LZMA_Stream
diff --git a/src/lib/compression/zlib/zlib.cpp b/src/lib/compression/zlib/zlib.cpp
index 27ae6fb20..2bfd22928 100644
--- a/src/lib/compression/zlib/zlib.cpp
+++ b/src/lib/compression/zlib/zlib.cpp
@@ -27,9 +27,9 @@ class Zlib_Stream : public Zlib_Style_Stream<z_stream, Bytef>
streamp()->zfree = Compression_Alloc_Info::free;
}
- u32bit run_flag() const override { return Z_NO_FLUSH; }
- u32bit flush_flag() const override { return Z_SYNC_FLUSH; }
- u32bit finish_flag() const override { return Z_FINISH; }
+ uint32_t run_flag() const override { return Z_NO_FLUSH; }
+ uint32_t flush_flag() const override { return Z_SYNC_FLUSH; }
+ uint32_t finish_flag() const override { return Z_FINISH; }
int compute_window_bits(int wbits, int wbits_offset) const
{
@@ -63,7 +63,7 @@ class Zlib_Compression_Stream : public Zlib_Stream
::deflateEnd(streamp());
}
- bool run(u32bit flags) override
+ bool run(uint32_t flags) override
{
int rc = ::deflate(streamp(), flags);
@@ -94,7 +94,7 @@ class Zlib_Decompression_Stream : public Zlib_Stream
::inflateEnd(streamp());
}
- bool run(u32bit flags) override
+ bool run(uint32_t flags) override
{
int rc = ::inflate(streamp(), flags);
@@ -123,7 +123,7 @@ class Deflate_Decompression_Stream : public Zlib_Decompression_Stream
class Gzip_Compression_Stream : public Zlib_Compression_Stream
{
public:
- Gzip_Compression_Stream(size_t level, int wbits, byte os_code) :
+ Gzip_Compression_Stream(size_t level, int wbits, uint8_t os_code) :
Zlib_Compression_Stream(level, wbits, 16)
{
clear_mem(&m_header, 1);
diff --git a/src/lib/compression/zlib/zlib.h b/src/lib/compression/zlib/zlib.h
index 0cedb1eab..a2cae34f4 100644
--- a/src/lib/compression/zlib/zlib.h
+++ b/src/lib/compression/zlib/zlib.h
@@ -63,12 +63,12 @@ class BOTAN_DLL Deflate_Decompression final : public Stream_Decompression
class BOTAN_DLL Gzip_Compression final : public Stream_Compression
{
public:
- Gzip_Compression(byte os_code = 255) : m_os_code(os_code) {}
+ Gzip_Compression(uint8_t os_code = 255) : m_os_code(os_code) {}
std::string name() const override { return "Gzip_Compression"; }
private:
Compression_Stream* make_stream(size_t level) const override;
- const byte m_os_code;
+ const uint8_t m_os_code;
};
/**
diff --git a/src/lib/entropy/cryptoapi_rng/es_capi.cpp b/src/lib/entropy/cryptoapi_rng/es_capi.cpp
index 1624f8946..4695d90ed 100644
--- a/src/lib/entropy/cryptoapi_rng/es_capi.cpp
+++ b/src/lib/entropy/cryptoapi_rng/es_capi.cpp
@@ -18,7 +18,7 @@ namespace {
class CSP_Handle_Impl : public Win32_CAPI_EntropySource::CSP_Handle
{
public:
- explicit CSP_Handle_Impl(u64bit capi_provider)
+ explicit CSP_Handle_Impl(uint64_t capi_provider)
{
m_valid = ::CryptAcquireContext(&m_handle,
0,
@@ -33,7 +33,7 @@ class CSP_Handle_Impl : public Win32_CAPI_EntropySource::CSP_Handle
::CryptReleaseContext(m_handle, 0);
}
- size_t gen_random(byte out[], size_t n) const
+ size_t gen_random(uint8_t out[], size_t n) const
{
if(m_valid && ::CryptGenRandom(m_handle, static_cast<DWORD>(n), out))
return n;
diff --git a/src/lib/entropy/cryptoapi_rng/es_capi.h b/src/lib/entropy/cryptoapi_rng/es_capi.h
index 82a779672..79a42828d 100644
--- a/src/lib/entropy/cryptoapi_rng/es_capi.h
+++ b/src/lib/entropy/cryptoapi_rng/es_capi.h
@@ -32,7 +32,7 @@ class Win32_CAPI_EntropySource final : public Entropy_Source
class CSP_Handle
{
public:
- virtual size_t gen_random(byte out[], size_t n) const = 0;
+ virtual size_t gen_random(uint8_t out[], size_t n) const = 0;
};
private:
std::vector<std::unique_ptr<CSP_Handle>> m_csp_provs;
diff --git a/src/lib/entropy/proc_walk/proc_walk.h b/src/lib/entropy/proc_walk/proc_walk.h
index 4e9562c88..054da3e51 100644
--- a/src/lib/entropy/proc_walk/proc_walk.h
+++ b/src/lib/entropy/proc_walk/proc_walk.h
@@ -37,7 +37,7 @@ class ProcWalking_EntropySource final : public Entropy_Source
const std::string m_path;
mutex_type m_mutex;
std::unique_ptr<File_Descriptor_Source> m_dir;
- secure_vector<byte> m_buf;
+ secure_vector<uint8_t> m_buf;
};
}
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h
index 83aa9545d..ed1b55a56 100644
--- a/src/lib/ffi/ffi.h
+++ b/src/lib/ffi/ffi.h
@@ -522,12 +522,12 @@ BOTAN_DLL int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int
typedef struct botan_tls_session_struct* botan_tls_session_t;
BOTAN_DLL int botan_tls_session_decrypt(botan_tls_session_t* session,
- const byte key[], size_t key_len,
- const byte blob[], size_t blob_len);
+ const uint8_t key[], size_t key_len,
+ const uint8_t blob[], size_t blob_len);
BOTAN_DLL int botan_tls_session_get_version(botan_tls_session_t session, uint16_t* tls_version);
BOTAN_DLL int botan_tls_session_get_ciphersuite(botan_tls_session_t session, uint16_t* ciphersuite);
-BOTAN_DLL int botan_tls_session_encrypt(botan_tls_session_t session, botan_rng_t rng, byte key[], size_t* key_len);
+BOTAN_DLL int botan_tls_session_encrypt(botan_tls_session_t session, botan_rng_t rng, uint8_t key[], size_t* key_len);
BOTAN_DLL int botan_tls_session_get_peer_certs(botan_tls_session_t session, botan_x509_cert_t certs[], size_t* cert_len);
diff --git a/src/lib/filters/aead_filt.h b/src/lib/filters/aead_filt.h
index c86739fc8..f05d3abdb 100644
--- a/src/lib/filters/aead_filt.h
+++ b/src/lib/filters/aead_filt.h
@@ -29,7 +29,7 @@ class AEAD_Filter : public Cipher_Mode_Filter
* @param ad the associated data
* @param ad_len length of add in bytes
*/
- void set_associated_data(const byte ad[], size_t ad_len)
+ void set_associated_data(const uint8_t ad[], size_t ad_len)
{
dynamic_cast<AEAD_Mode&>(get_transform()).set_associated_data(ad, ad_len);
}
diff --git a/src/lib/filters/algo_filt.cpp b/src/lib/filters/algo_filt.cpp
index aa1a8d5f9..63906907c 100644
--- a/src/lib/filters/algo_filt.cpp
+++ b/src/lib/filters/algo_filt.cpp
@@ -36,7 +36,7 @@ StreamCipher_Filter::StreamCipher_Filter(const std::string& sc_name, const Symme
m_cipher->set_key(key);
}
-void StreamCipher_Filter::write(const byte input[], size_t length)
+void StreamCipher_Filter::write(const uint8_t input[], size_t length)
{
while(length)
{
@@ -56,7 +56,7 @@ Hash_Filter::Hash_Filter(const std::string& hash_name, size_t len) :
void Hash_Filter::end_msg()
{
- secure_vector<byte> output = m_hash->final();
+ secure_vector<uint8_t> output = m_hash->final();
if(m_out_len)
send(output, std::min<size_t>(m_out_len, output.size()));
else
@@ -78,7 +78,7 @@ MAC_Filter::MAC_Filter(const std::string& mac_name, const SymmetricKey& key, siz
void MAC_Filter::end_msg()
{
- secure_vector<byte> output = m_mac->final();
+ secure_vector<uint8_t> output = m_mac->final();
if(m_out_len)
send(output, std::min<size_t>(m_out_len, output.size()));
else
diff --git a/src/lib/filters/basefilt.h b/src/lib/filters/basefilt.h
index 629f04f29..47437688e 100644
--- a/src/lib/filters/basefilt.h
+++ b/src/lib/filters/basefilt.h
@@ -22,7 +22,7 @@ namespace Botan {
*/
struct BOTAN_DLL BitBucket final : public Filter
{
- void write(const byte[], size_t) override {}
+ void write(const uint8_t[], size_t) override {}
std::string name() const override { return "BitBucket"; }
};
@@ -36,7 +36,7 @@ struct BOTAN_DLL BitBucket final : public Filter
class BOTAN_DLL Chain : public Fanout_Filter
{
public:
- void write(const byte input[], size_t length) override { send(input, length); }
+ void write(const uint8_t input[], size_t length) override { send(input, length); }
std::string name() const override;
@@ -63,7 +63,7 @@ class BOTAN_DLL Chain : public Fanout_Filter
class BOTAN_DLL Fork : public Fanout_Filter
{
public:
- void write(const byte input[], size_t length) override { send(input, length); }
+ void write(const uint8_t input[], size_t length) override { send(input, length); }
void set_port(size_t n) { Fanout_Filter::set_port(n); }
std::string name() const override;
@@ -109,10 +109,10 @@ class BOTAN_DLL Threaded_Fork : public Fork
protected:
void set_next(Filter* f[], size_t n);
- void send(const byte in[], size_t length) override;
+ void send(const uint8_t in[], size_t length) override;
private:
- void thread_delegate_work(const byte input[], size_t length);
+ void thread_delegate_work(const uint8_t input[], size_t length);
void thread_entry(Filter* filter);
std::vector<std::shared_ptr<std::thread>> m_threads;
diff --git a/src/lib/filters/buf_filt.cpp b/src/lib/filters/buf_filt.cpp
index 9306c1ef8..8acc6c74f 100644
--- a/src/lib/filters/buf_filt.cpp
+++ b/src/lib/filters/buf_filt.cpp
@@ -31,7 +31,7 @@ Buffered_Filter::Buffered_Filter(size_t b, size_t f) :
/*
* Buffer input into blocks, trying to minimize copying
*/
-void Buffered_Filter::write(const byte input[], size_t input_size)
+void Buffered_Filter::write(const uint8_t input[], size_t input_size)
{
if(!input_size)
return;
diff --git a/src/lib/filters/buf_filt.h b/src/lib/filters/buf_filt.h
index 2ec7c4d30..b7b915c88 100644
--- a/src/lib/filters/buf_filt.h
+++ b/src/lib/filters/buf_filt.h
@@ -25,10 +25,10 @@ class BOTAN_DLL Buffered_Filter
* @param in the input bytes
* @param length of in in bytes
*/
- void write(const byte in[], size_t length);
+ void write(const uint8_t in[], size_t length);
template<typename Alloc>
- void write(const std::vector<byte, Alloc>& in, size_t length)
+ void write(const std::vector<uint8_t, Alloc>& in, size_t length)
{
write(in.data(), length);
}
@@ -57,7 +57,7 @@ class BOTAN_DLL Buffered_Filter
* @param length the size of input, guaranteed to be a multiple
* of block_size
*/
- virtual void buffered_block(const byte input[], size_t length) = 0;
+ virtual void buffered_block(const uint8_t input[], size_t length) = 0;
/**
* The final block, implemented by subclasses
@@ -65,7 +65,7 @@ class BOTAN_DLL Buffered_Filter
* @param length the size of input, guaranteed to be at least
* final_minimum bytes
*/
- virtual void buffered_final(const byte input[], size_t length) = 0;
+ virtual void buffered_final(const uint8_t input[], size_t length) = 0;
/**
* @return block size of inputs
@@ -84,7 +84,7 @@ class BOTAN_DLL Buffered_Filter
private:
size_t m_main_block_mod, m_final_minimum;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
size_t m_buffer_pos;
};
diff --git a/src/lib/filters/cipher_filter.cpp b/src/lib/filters/cipher_filter.cpp
index ed82880aa..1f3476694 100644
--- a/src/lib/filters/cipher_filter.cpp
+++ b/src/lib/filters/cipher_filter.cpp
@@ -44,7 +44,7 @@ void Cipher_Mode_Filter::Nonce_State::update(const InitializationVector& iv)
m_fresh_nonce = true;
}
-std::vector<byte> Cipher_Mode_Filter::Nonce_State::get()
+std::vector<uint8_t> Cipher_Mode_Filter::Nonce_State::get()
{
BOTAN_ASSERT(m_fresh_nonce, "The nonce is fresh for this message");
@@ -73,7 +73,7 @@ bool Cipher_Mode_Filter::valid_iv_length(size_t length) const
return m_mode->valid_nonce_length(length);
}
-void Cipher_Mode_Filter::write(const byte input[], size_t input_length)
+void Cipher_Mode_Filter::write(const uint8_t input[], size_t input_length)
{
Buffered_Filter::write(input, input_length);
}
@@ -88,7 +88,7 @@ void Cipher_Mode_Filter::start_msg()
m_mode->start(m_nonce.get());
}
-void Cipher_Mode_Filter::buffered_block(const byte input[], size_t input_length)
+void Cipher_Mode_Filter::buffered_block(const uint8_t input[], size_t input_length)
{
while(input_length)
{
@@ -104,9 +104,9 @@ void Cipher_Mode_Filter::buffered_block(const byte input[], size_t input_length)
}
}
-void Cipher_Mode_Filter::buffered_final(const byte input[], size_t input_length)
+void Cipher_Mode_Filter::buffered_final(const uint8_t input[], size_t input_length)
{
- secure_vector<byte> buf(input, input + input_length);
+ secure_vector<uint8_t> buf(input, input + input_length);
m_mode->finish(buf);
send(buf);
}
diff --git a/src/lib/filters/cipher_filter.h b/src/lib/filters/cipher_filter.h
index e0681f82a..1675a15d7 100644
--- a/src/lib/filters/cipher_filter.h
+++ b/src/lib/filters/cipher_filter.h
@@ -39,12 +39,12 @@ class BOTAN_DLL Cipher_Mode_Filter : public Keyed_Filter,
Cipher_Mode& get_mode() { return *m_mode; }
private:
- void write(const byte input[], size_t input_length) override;
+ void write(const uint8_t input[], size_t input_length) override;
void start_msg() override;
void end_msg() override;
- void buffered_block(const byte input[], size_t input_length) override;
- void buffered_final(const byte input[], size_t input_length) override;
+ void buffered_block(const uint8_t input[], size_t input_length) override;
+ void buffered_final(const uint8_t input[], size_t input_length) override;
class Nonce_State
{
@@ -52,15 +52,15 @@ class BOTAN_DLL Cipher_Mode_Filter : public Keyed_Filter,
explicit Nonce_State(bool allow_null_nonce) : m_fresh_nonce(allow_null_nonce) {}
void update(const InitializationVector& iv);
- std::vector<byte> get();
+ std::vector<uint8_t> get();
private:
bool m_fresh_nonce;
- std::vector<byte> m_nonce;
+ std::vector<uint8_t> m_nonce;
};
Nonce_State m_nonce;
std::unique_ptr<Cipher_Mode> m_mode;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
};
// deprecated aliases, will be removed before 2.0
diff --git a/src/lib/filters/codec_filt/b64_filt.cpp b/src/lib/filters/codec_filt/b64_filt.cpp
index fe6314d52..4be9c5b1d 100644
--- a/src/lib/filters/codec_filt/b64_filt.cpp
+++ b/src/lib/filters/codec_filt/b64_filt.cpp
@@ -29,7 +29,7 @@ Base64_Encoder::Base64_Encoder(bool breaks, size_t length, bool t_n) :
/*
* Encode and send a block
*/
-void Base64_Encoder::encode_and_send(const byte input[], size_t length,
+void Base64_Encoder::encode_and_send(const uint8_t input[], size_t length,
bool final_inputs)
{
while(length)
@@ -51,7 +51,7 @@ void Base64_Encoder::encode_and_send(const byte input[], size_t length,
/*
* Handle the output
*/
-void Base64_Encoder::do_output(const byte input[], size_t length)
+void Base64_Encoder::do_output(const uint8_t input[], size_t length)
{
if(m_line_length == 0)
send(input, length);
@@ -77,7 +77,7 @@ void Base64_Encoder::do_output(const byte input[], size_t length)
/*
* Convert some data into Base64
*/
-void Base64_Encoder::write(const byte input[], size_t length)
+void Base64_Encoder::write(const uint8_t input[], size_t length)
{
buffer_insert(m_in, m_position, input, length);
if(m_position + length >= m_in.size())
@@ -121,7 +121,7 @@ Base64_Decoder::Base64_Decoder(Decoder_Checking c) :
/*
* Convert some data from Base64
*/
-void Base64_Decoder::write(const byte input[], size_t length)
+void Base64_Decoder::write(const uint8_t input[], size_t length)
{
while(length)
{
diff --git a/src/lib/filters/codec_filt/b64_filt.h b/src/lib/filters/codec_filt/b64_filt.h
index f1879fb71..a643acb32 100644
--- a/src/lib/filters/codec_filt/b64_filt.h
+++ b/src/lib/filters/codec_filt/b64_filt.h
@@ -25,7 +25,7 @@ class BOTAN_DLL Base64_Encoder final : public Filter
* @param input the message to input as a byte array
* @param length the length of the byte array input
*/
- void write(const byte input[], size_t length) override;
+ void write(const uint8_t input[], size_t length) override;
/**
* Inform the Encoder that the current message shall be closed.
@@ -41,13 +41,13 @@ class BOTAN_DLL Base64_Encoder final : public Filter
Base64_Encoder(bool breaks = false, size_t length = 72,
bool t_n = false);
private:
- void encode_and_send(const byte input[], size_t length,
+ void encode_and_send(const uint8_t input[], size_t length,
bool final_inputs = false);
- void do_output(const byte output[], size_t length);
+ void do_output(const uint8_t output[], size_t length);
const size_t m_line_length;
const bool m_trailing_newline;
- std::vector<byte> m_in, m_out;
+ std::vector<uint8_t> m_in, m_out;
size_t m_position, m_out_position;
};
@@ -64,7 +64,7 @@ class BOTAN_DLL Base64_Decoder final : public Filter
* @param input the message to input as a byte array
* @param length the length of the byte array input
*/
- void write(const byte input[], size_t length) override;
+ void write(const uint8_t input[], size_t length) override;
/**
* Finish up the current message
@@ -79,7 +79,7 @@ class BOTAN_DLL Base64_Decoder final : public Filter
explicit Base64_Decoder(Decoder_Checking checking = NONE);
private:
const Decoder_Checking m_checking;
- std::vector<byte> m_in, m_out;
+ std::vector<uint8_t> m_in, m_out;
size_t m_position;
};
diff --git a/src/lib/filters/codec_filt/hex_filt.cpp b/src/lib/filters/codec_filt/hex_filt.cpp
index 2003055b4..31e6b3824 100644
--- a/src/lib/filters/codec_filt/hex_filt.cpp
+++ b/src/lib/filters/codec_filt/hex_filt.cpp
@@ -43,7 +43,7 @@ Hex_Encoder::Hex_Encoder(Case c) : m_casing(c), m_line_length(0)
/*
* Encode and send a block
*/
-void Hex_Encoder::encode_and_send(const byte block[], size_t length)
+void Hex_Encoder::encode_and_send(const uint8_t block[], size_t length)
{
hex_encode(reinterpret_cast<char*>(m_out.data()),
block, length,
@@ -73,7 +73,7 @@ void Hex_Encoder::encode_and_send(const byte block[], size_t length)
/*
* Convert some data into hex format
*/
-void Hex_Encoder::write(const byte input[], size_t length)
+void Hex_Encoder::write(const uint8_t input[], size_t length)
{
buffer_insert(m_in, m_position, input, length);
if(m_position + length >= m_in.size())
@@ -117,7 +117,7 @@ Hex_Decoder::Hex_Decoder(Decoder_Checking c) : m_checking(c)
/*
* Convert some data from hex format
*/
-void Hex_Decoder::write(const byte input[], size_t length)
+void Hex_Decoder::write(const uint8_t input[], size_t length)
{
while(length)
{
diff --git a/src/lib/filters/codec_filt/hex_filt.h b/src/lib/filters/codec_filt/hex_filt.h
index f8a35b8b9..f1288b0b9 100644
--- a/src/lib/filters/codec_filt/hex_filt.h
+++ b/src/lib/filters/codec_filt/hex_filt.h
@@ -26,7 +26,7 @@ class BOTAN_DLL Hex_Encoder final : public Filter
std::string name() const override { return "Hex_Encoder"; }
- void write(const byte in[], size_t length) override;
+ void write(const uint8_t in[], size_t length) override;
void end_msg() override;
/**
@@ -45,11 +45,11 @@ class BOTAN_DLL Hex_Encoder final : public Filter
size_t line_length = 72,
Case the_case = Uppercase);
private:
- void encode_and_send(const byte[], size_t);
+ void encode_and_send(const uint8_t[], size_t);
const Case m_casing;
const size_t m_line_length;
- std::vector<byte> m_in, m_out;
+ std::vector<uint8_t> m_in, m_out;
size_t m_position, m_counter;
};
@@ -61,7 +61,7 @@ class BOTAN_DLL Hex_Decoder final : public Filter
public:
std::string name() const override { return "Hex_Decoder"; }
- void write(const byte[], size_t) override;
+ void write(const uint8_t[], size_t) override;
void end_msg() override;
/**
@@ -72,7 +72,7 @@ class BOTAN_DLL Hex_Decoder final : public Filter
explicit Hex_Decoder(Decoder_Checking checking = NONE);
private:
const Decoder_Checking m_checking;
- std::vector<byte> m_in, m_out;
+ std::vector<uint8_t> m_in, m_out;
size_t m_position;
};
diff --git a/src/lib/filters/comp_filter.cpp b/src/lib/filters/comp_filter.cpp
index 1dc6c5839..4fdc8ffc8 100644
--- a/src/lib/filters/comp_filter.cpp
+++ b/src/lib/filters/comp_filter.cpp
@@ -38,7 +38,7 @@ void Compression_Filter::start_msg()
m_comp->start(m_level);
}
-void Compression_Filter::write(const byte input[], size_t input_length)
+void Compression_Filter::write(const uint8_t input[], size_t input_length)
{
while(input_length)
{
@@ -89,7 +89,7 @@ void Decompression_Filter::start_msg()
m_comp->start();
}
-void Decompression_Filter::write(const byte input[], size_t input_length)
+void Decompression_Filter::write(const uint8_t input[], size_t input_length)
{
while(input_length)
{
diff --git a/src/lib/filters/comp_filter.h b/src/lib/filters/comp_filter.h
index c7f8e181a..552dc8588 100644
--- a/src/lib/filters/comp_filter.h
+++ b/src/lib/filters/comp_filter.h
@@ -24,7 +24,7 @@ class BOTAN_DLL Compression_Filter : public Filter
{
public:
void start_msg() override;
- void write(const byte input[], size_t input_length) override;
+ void write(const uint8_t input[], size_t input_length) override;
void end_msg() override;
void flush();
@@ -37,7 +37,7 @@ class BOTAN_DLL Compression_Filter : public Filter
private:
std::unique_ptr<Compression_Algorithm> m_comp;
size_t m_buffersize, m_level;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
};
/**
@@ -47,7 +47,7 @@ class BOTAN_DLL Decompression_Filter : public Filter
{
public:
void start_msg() override;
- void write(const byte input[], size_t input_length) override;
+ void write(const uint8_t input[], size_t input_length) override;
void end_msg() override;
std::string name() const override;
@@ -57,7 +57,7 @@ class BOTAN_DLL Decompression_Filter : public Filter
private:
std::unique_ptr<Decompression_Algorithm> m_comp;
std::size_t m_buffersize;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
};
#endif
diff --git a/src/lib/filters/data_snk.cpp b/src/lib/filters/data_snk.cpp
index efedef268..e6dc0d671 100644
--- a/src/lib/filters/data_snk.cpp
+++ b/src/lib/filters/data_snk.cpp
@@ -19,7 +19,7 @@ namespace Botan {
/*
* Write to a stream
*/
-void DataSink_Stream::write(const byte out[], size_t length)
+void DataSink_Stream::write(const uint8_t out[], size_t length)
{
m_sink.write(reinterpret_cast<const char*>(out), length);
if(!m_sink.good())
diff --git a/src/lib/filters/data_snk.h b/src/lib/filters/data_snk.h
index 2405fdf98..46aef285c 100644
--- a/src/lib/filters/data_snk.h
+++ b/src/lib/filters/data_snk.h
@@ -37,7 +37,7 @@ class BOTAN_DLL DataSink_Stream : public DataSink
public:
std::string name() const override { return m_identifier; }
- void write(const byte[], size_t) override;
+ void write(const uint8_t[], size_t) override;
/**
* Construct a DataSink_Stream from a stream.
diff --git a/src/lib/filters/fd_unix/fd_unix.cpp b/src/lib/filters/fd_unix/fd_unix.cpp
index a809ba8d8..53f396cab 100644
--- a/src/lib/filters/fd_unix/fd_unix.cpp
+++ b/src/lib/filters/fd_unix/fd_unix.cpp
@@ -16,7 +16,7 @@ namespace Botan {
*/
int operator<<(int fd, Pipe& pipe)
{
- secure_vector<byte> buffer(DEFAULT_BUFFERSIZE);
+ secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE);
while(pipe.remaining())
{
size_t got = pipe.read(buffer.data(), buffer.size());
@@ -38,7 +38,7 @@ int operator<<(int fd, Pipe& pipe)
*/
int operator>>(int fd, Pipe& pipe)
{
- secure_vector<byte> buffer(DEFAULT_BUFFERSIZE);
+ secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE);
while(true)
{
ssize_t ret = read(fd, buffer.data(), buffer.size());
diff --git a/src/lib/filters/filter.cpp b/src/lib/filters/filter.cpp
index 6ae713314..6653fc781 100644
--- a/src/lib/filters/filter.cpp
+++ b/src/lib/filters/filter.cpp
@@ -24,7 +24,7 @@ Filter::Filter()
/*
* Send data to all ports
*/
-void Filter::send(const byte input[], size_t length)
+void Filter::send(const uint8_t input[], size_t length)
{
if(!length)
return;
diff --git a/src/lib/filters/filter.h b/src/lib/filters/filter.h
index 359a76ac0..81a35c003 100644
--- a/src/lib/filters/filter.h
+++ b/src/lib/filters/filter.h
@@ -31,7 +31,7 @@ class BOTAN_DLL Filter
* @param input the input as a byte array
* @param length the length of the byte array input
*/
- virtual void write(const byte input[], size_t length) = 0;
+ virtual void write(const uint8_t input[], size_t length) = 0;
/**
* Start a new message. Must be closed by end_msg() before another
@@ -57,28 +57,28 @@ class BOTAN_DLL Filter
* @param in some input for the filter
* @param length the length of in
*/
- virtual void send(const byte in[], size_t length);
+ virtual void send(const uint8_t in[], size_t length);
/**
* @param in some input for the filter
*/
- void send(byte in) { send(&in, 1); }
+ void send(uint8_t in) { send(&in, 1); }
/**
* @param in some input for the filter
*/
- void send(const secure_vector<byte>& in) { send(in.data(), in.size()); }
+ void send(const secure_vector<uint8_t>& in) { send(in.data(), in.size()); }
/**
* @param in some input for the filter
*/
- void send(const std::vector<byte>& in) { send(in.data(), in.size()); }
+ void send(const std::vector<uint8_t>& in) { send(in.data(), in.size()); }
/**
* @param in some input for the filter
* @param length the number of bytes of in to send
*/
- void send(const secure_vector<byte>& in, size_t length)
+ void send(const secure_vector<uint8_t>& in, size_t length)
{
send(in.data(), length);
}
@@ -87,7 +87,7 @@ class BOTAN_DLL Filter
* @param in some input for the filter
* @param length the number of bytes of in to send
*/
- void send(const std::vector<byte>& in, size_t length)
+ void send(const std::vector<uint8_t>& in, size_t length)
{
send(in.data(), length);
}
@@ -138,7 +138,7 @@ class BOTAN_DLL Filter
void set_next(Filter* filters[], size_t count);
Filter* get_next() const;
- secure_vector<byte> m_write_queue;
+ secure_vector<uint8_t> m_write_queue;
std::vector<Filter*> m_next;
size_t m_port_num, m_filter_owns;
diff --git a/src/lib/filters/filters.h b/src/lib/filters/filters.h
index af2b6c70d..b823d7751 100644
--- a/src/lib/filters/filters.h
+++ b/src/lib/filters/filters.h
@@ -39,7 +39,7 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter
* @param input data
* @param input_len length of input in bytes
*/
- void write(const byte input[], size_t input_len) override;
+ void write(const uint8_t input[], size_t input_len) override;
bool valid_iv_length(size_t iv_len) const override
{ return m_cipher->valid_iv_length(iv_len); }
@@ -87,7 +87,7 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter
*/
StreamCipher_Filter(const std::string& cipher, const SymmetricKey& key);
private:
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
std::unique_ptr<StreamCipher> m_cipher;
};
@@ -97,7 +97,7 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter
class BOTAN_DLL Hash_Filter : public Filter
{
public:
- void write(const byte input[], size_t len) override { m_hash->update(input, len); }
+ void write(const uint8_t input[], size_t len) override { m_hash->update(input, len); }
void end_msg() override;
std::string name() const override { return m_hash->name(); }
@@ -134,7 +134,7 @@ class BOTAN_DLL Hash_Filter : public Filter
class BOTAN_DLL MAC_Filter : public Keyed_Filter
{
public:
- void write(const byte input[], size_t len) override { m_mac->update(input, len); }
+ void write(const uint8_t input[], size_t len) override { m_mac->update(input, len); }
void end_msg() override;
std::string name() const override { return m_mac->name(); }
diff --git a/src/lib/filters/out_buf.cpp b/src/lib/filters/out_buf.cpp
index e0d649a5b..68554e56b 100644
--- a/src/lib/filters/out_buf.cpp
+++ b/src/lib/filters/out_buf.cpp
@@ -14,7 +14,7 @@ namespace Botan {
/*
* Read data from a message
*/
-size_t Output_Buffers::read(byte output[], size_t length,
+size_t Output_Buffers::read(uint8_t output[], size_t length,
Pipe::message_id msg)
{
SecureQueue* q = get(msg);
@@ -26,7 +26,7 @@ size_t Output_Buffers::read(byte output[], size_t length,
/*
* Peek at data in a message
*/
-size_t Output_Buffers::peek(byte output[], size_t length,
+size_t Output_Buffers::peek(uint8_t output[], size_t length,
size_t stream_offset,
Pipe::message_id msg) const
{
diff --git a/src/lib/filters/out_buf.h b/src/lib/filters/out_buf.h
index 4898ca105..9f20e2858 100644
--- a/src/lib/filters/out_buf.h
+++ b/src/lib/filters/out_buf.h
@@ -21,8 +21,8 @@ namespace Botan {
class Output_Buffers
{
public:
- size_t read(byte[], size_t, Pipe::message_id);
- size_t peek(byte[], size_t, size_t, Pipe::message_id) const;
+ size_t read(uint8_t[], size_t, Pipe::message_id);
+ size_t peek(uint8_t[], size_t, size_t, Pipe::message_id) const;
size_t get_bytes_read(Pipe::message_id) const;
size_t remaining(Pipe::message_id) const;
diff --git a/src/lib/filters/pipe.cpp b/src/lib/filters/pipe.cpp
index a4962f891..9af5a2158 100644
--- a/src/lib/filters/pipe.cpp
+++ b/src/lib/filters/pipe.cpp
@@ -20,7 +20,7 @@ namespace {
class Null_Filter : public Filter
{
public:
- void write(const byte input[], size_t length) override
+ void write(const uint8_t input[], size_t length) override
{ send(input, length); }
std::string name() const override { return "Null"; }
@@ -114,7 +114,7 @@ void Pipe::set_default_msg(message_id msg)
/*
* Process a full message at once
*/
-void Pipe::process_msg(const byte input[], size_t length)
+void Pipe::process_msg(const uint8_t input[], size_t length)
{
start_msg();
write(input, length);
@@ -124,12 +124,12 @@ void Pipe::process_msg(const byte input[], size_t length)
/*
* Process a full message at once
*/
-void Pipe::process_msg(const secure_vector<byte>& input)
+void Pipe::process_msg(const secure_vector<uint8_t>& input)
{
process_msg(input.data(), input.size());
}
-void Pipe::process_msg(const std::vector<byte>& input)
+void Pipe::process_msg(const std::vector<uint8_t>& input)
{
process_msg(input.data(), input.size());
}
@@ -139,7 +139,7 @@ void Pipe::process_msg(const std::vector<byte>& input)
*/
void Pipe::process_msg(const std::string& input)
{
- process_msg(reinterpret_cast<const byte*>(input.data()), input.length());
+ process_msg(reinterpret_cast<const uint8_t*>(input.data()), input.length());
}
/*
diff --git a/src/lib/filters/pipe.h b/src/lib/filters/pipe.h
index 8775e1433..9be0fa1b4 100644
--- a/src/lib/filters/pipe.h
+++ b/src/lib/filters/pipe.h
@@ -63,20 +63,20 @@ class BOTAN_DLL Pipe final : public DataSource
* @param in the byte array to write
* @param length the length of the byte array in
*/
- void write(const byte in[], size_t length);
+ void write(const uint8_t in[], size_t length);
/**
* Write input to the pipe, i.e. to its first filter.
* @param in the secure_vector containing the data to write
*/
- void write(const secure_vector<byte>& in)
+ void write(const secure_vector<uint8_t>& in)
{ write(in.data(), in.size()); }
/**
* Write input to the pipe, i.e. to its first filter.
* @param in the std::vector containing the data to write
*/
- void write(const std::vector<byte>& in)
+ void write(const std::vector<uint8_t>& in)
{ write(in.data(), in.size()); }
/**
@@ -95,26 +95,26 @@ class BOTAN_DLL Pipe final : public DataSource
* Write input to the pipe, i.e. to its first filter.
* @param in a single byte to be written
*/
- void write(byte in);
+ void write(uint8_t in);
/**
* Perform start_msg(), write() and end_msg() sequentially.
* @param in the byte array containing the data to write
* @param length the length of the byte array to write
*/
- void process_msg(const byte in[], size_t length);
+ void process_msg(const uint8_t in[], size_t length);
/**
* Perform start_msg(), write() and end_msg() sequentially.
* @param in the secure_vector containing the data to write
*/
- void process_msg(const secure_vector<byte>& in);
+ void process_msg(const secure_vector<uint8_t>& in);
/**
* Perform start_msg(), write() and end_msg() sequentially.
* @param in the secure_vector containing the data to write
*/
- void process_msg(const std::vector<byte>& in);
+ void process_msg(const std::vector<uint8_t>& in);
/**
* Perform start_msg(), write() and end_msg() sequentially.
@@ -145,7 +145,7 @@ class BOTAN_DLL Pipe final : public DataSource
* @param length the length of the byte array output
* @return number of bytes actually read into output
*/
- size_t read(byte output[], size_t length) override BOTAN_WARN_UNUSED_RESULT;
+ size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT;
/**
* Read a specified message from the pipe. Moves the internal
@@ -156,7 +156,7 @@ class BOTAN_DLL Pipe final : public DataSource
* @param msg the number identifying the message to read from
* @return number of bytes actually read into output
*/
- size_t read(byte output[], size_t length, message_id msg) BOTAN_WARN_UNUSED_RESULT;
+ size_t read(uint8_t output[], size_t length, message_id msg) BOTAN_WARN_UNUSED_RESULT;
/**
* Read a single byte from the pipe. Moves the internal offset so
@@ -167,14 +167,14 @@ class BOTAN_DLL Pipe final : public DataSource
* @param msg the message to read from
* @return number of bytes actually read into output
*/
- size_t read(byte& output, message_id msg = DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT;
+ size_t read(uint8_t& output, message_id msg = DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT;
/**
* Read the full contents of the pipe.
* @param msg the number identifying the message to read from
* @return secure_vector holding the contents of the pipe
*/
- secure_vector<byte> read_all(message_id msg = DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT;
+ secure_vector<uint8_t> read_all(message_id msg = DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT;
/**
* Read the full contents of the pipe.
@@ -192,7 +192,7 @@ class BOTAN_DLL Pipe final : public DataSource
* @param offset the offset from the current position in message
* @return number of bytes actually peeked and written into output
*/
- size_t peek(byte output[], size_t length, size_t offset) const override BOTAN_WARN_UNUSED_RESULT;
+ size_t peek(uint8_t output[], size_t length, size_t offset) const override BOTAN_WARN_UNUSED_RESULT;
/** Read from the specified message but do not modify the
* internal offset. Consecutive calls to peek() will return
@@ -203,7 +203,7 @@ class BOTAN_DLL Pipe final : public DataSource
* @param msg the number identifying the message to peek from
* @return number of bytes actually peeked and written into output
*/
- size_t peek(byte output[], size_t length,
+ size_t peek(uint8_t output[], size_t length,
size_t offset, message_id msg) const BOTAN_WARN_UNUSED_RESULT;
/** Read a single byte from the specified message but do not
@@ -214,7 +214,7 @@ class BOTAN_DLL Pipe final : public DataSource
* @param msg the number identifying the message to peek from
* @return number of bytes actually peeked and written into output
*/
- size_t peek(byte& output, size_t offset,
+ size_t peek(uint8_t& output, size_t offset,
message_id msg = DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT;
/**
diff --git a/src/lib/filters/pipe_io.cpp b/src/lib/filters/pipe_io.cpp
index ce476fd94..b1787a5a8 100644
--- a/src/lib/filters/pipe_io.cpp
+++ b/src/lib/filters/pipe_io.cpp
@@ -15,7 +15,7 @@ namespace Botan {
*/
std::ostream& operator<<(std::ostream& stream, Pipe& pipe)
{
- secure_vector<byte> buffer(DEFAULT_BUFFERSIZE);
+ secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE);
while(stream.good() && pipe.remaining())
{
size_t got = pipe.read(buffer.data(), buffer.size());
@@ -31,7 +31,7 @@ std::ostream& operator<<(std::ostream& stream, Pipe& pipe)
*/
std::istream& operator>>(std::istream& stream, Pipe& pipe)
{
- secure_vector<byte> buffer(DEFAULT_BUFFERSIZE);
+ secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE);
while(stream.good())
{
stream.read(reinterpret_cast<char*>(buffer.data()), buffer.size());
diff --git a/src/lib/filters/pipe_rw.cpp b/src/lib/filters/pipe_rw.cpp
index 646752e7c..6979bd4ce 100644
--- a/src/lib/filters/pipe_rw.cpp
+++ b/src/lib/filters/pipe_rw.cpp
@@ -31,7 +31,7 @@ Pipe::message_id Pipe::get_message_no(const std::string& func_name,
/*
* Write into a Pipe
*/
-void Pipe::write(const byte input[], size_t length)
+void Pipe::write(const uint8_t input[], size_t length)
{
if(!m_inside_msg)
throw Invalid_State("Cannot write to a Pipe while it is not processing");
@@ -43,13 +43,13 @@ void Pipe::write(const byte input[], size_t length)
*/
void Pipe::write(const std::string& str)
{
- write(reinterpret_cast<const byte*>(str.data()), str.size());
+ write(reinterpret_cast<const uint8_t*>(str.data()), str.size());
}
/*
* Write a single byte into a Pipe
*/
-void Pipe::write(byte input)
+void Pipe::write(uint8_t input)
{
write(&input, 1);
}
@@ -59,7 +59,7 @@ void Pipe::write(byte input)
*/
void Pipe::write(DataSource& source)
{
- secure_vector<byte> buffer(DEFAULT_BUFFERSIZE);
+ secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE);
while(!source.end_of_data())
{
size_t got = source.read(buffer.data(), buffer.size());
@@ -70,7 +70,7 @@ void Pipe::write(DataSource& source)
/*
* Read some data from the pipe
*/
-size_t Pipe::read(byte output[], size_t length, message_id msg)
+size_t Pipe::read(uint8_t output[], size_t length, message_id msg)
{
return m_outputs->read(output, length, get_message_no("read", msg));
}
@@ -78,7 +78,7 @@ size_t Pipe::read(byte output[], size_t length, message_id msg)
/*
* Read some data from the pipe
*/
-size_t Pipe::read(byte output[], size_t length)
+size_t Pipe::read(uint8_t output[], size_t length)
{
return read(output, length, DEFAULT_MESSAGE);
}
@@ -86,7 +86,7 @@ size_t Pipe::read(byte output[], size_t length)
/*
* Read a single byte from the pipe
*/
-size_t Pipe::read(byte& out, message_id msg)
+size_t Pipe::read(uint8_t& out, message_id msg)
{
return read(&out, 1, msg);
}
@@ -94,10 +94,10 @@ size_t Pipe::read(byte& out, message_id msg)
/*
* Return all data in the pipe
*/
-secure_vector<byte> Pipe::read_all(message_id msg)
+secure_vector<uint8_t> Pipe::read_all(message_id msg)
{
msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg());
- secure_vector<byte> buffer(remaining(msg));
+ secure_vector<uint8_t> buffer(remaining(msg));
size_t got = read(buffer.data(), buffer.size(), msg);
buffer.resize(got);
return buffer;
@@ -109,7 +109,7 @@ secure_vector<byte> Pipe::read_all(message_id msg)
std::string Pipe::read_all_as_string(message_id msg)
{
msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg());
- secure_vector<byte> buffer(DEFAULT_BUFFERSIZE);
+ secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE);
std::string str;
str.reserve(remaining(msg));
@@ -135,7 +135,7 @@ size_t Pipe::remaining(message_id msg) const
/*
* Peek at some data in the pipe
*/
-size_t Pipe::peek(byte output[], size_t length,
+size_t Pipe::peek(uint8_t output[], size_t length,
size_t offset, message_id msg) const
{
return m_outputs->peek(output, length, offset, get_message_no("peek", msg));
@@ -144,7 +144,7 @@ size_t Pipe::peek(byte output[], size_t length,
/*
* Peek at some data in the pipe
*/
-size_t Pipe::peek(byte output[], size_t length, size_t offset) const
+size_t Pipe::peek(uint8_t output[], size_t length, size_t offset) const
{
return peek(output, length, offset, DEFAULT_MESSAGE);
}
@@ -152,7 +152,7 @@ size_t Pipe::peek(byte output[], size_t length, size_t offset) const
/*
* Peek at a byte in the pipe
*/
-size_t Pipe::peek(byte& out, size_t offset, message_id msg) const
+size_t Pipe::peek(uint8_t& out, size_t offset, message_id msg) const
{
return peek(&out, 1, offset, msg);
}
diff --git a/src/lib/filters/secqueue.cpp b/src/lib/filters/secqueue.cpp
index 6f4070813..b2fc444af 100644
--- a/src/lib/filters/secqueue.cpp
+++ b/src/lib/filters/secqueue.cpp
@@ -22,7 +22,7 @@ class SecureQueueNode
~SecureQueueNode() { m_next = nullptr; m_start = m_end = 0; }
- size_t write(const byte input[], size_t length)
+ size_t write(const uint8_t input[], size_t length)
{
size_t copied = std::min<size_t>(length, m_buffer.size() - m_end);
copy_mem(m_buffer.data() + m_end, input, copied);
@@ -30,7 +30,7 @@ class SecureQueueNode
return copied;
}
- size_t read(byte output[], size_t length)
+ size_t read(uint8_t output[], size_t length)
{
size_t copied = std::min(length, m_end - m_start);
copy_mem(output, m_buffer.data() + m_start, copied);
@@ -38,7 +38,7 @@ class SecureQueueNode
return copied;
}
- size_t peek(byte output[], size_t length, size_t offset = 0)
+ size_t peek(uint8_t output[], size_t length, size_t offset = 0)
{
const size_t left = m_end - m_start;
if(offset >= left) return 0;
@@ -51,7 +51,7 @@ class SecureQueueNode
private:
friend class SecureQueue;
SecureQueueNode* m_next;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
size_t m_start, m_end;
};
@@ -118,7 +118,7 @@ SecureQueue& SecureQueue::operator=(const SecureQueue& input)
/*
* Add some bytes to the queue
*/
-void SecureQueue::write(const byte input[], size_t length)
+void SecureQueue::write(const uint8_t input[], size_t length)
{
if(!m_head)
m_head = m_tail = new SecureQueueNode;
@@ -138,7 +138,7 @@ void SecureQueue::write(const byte input[], size_t length)
/*
* Read some bytes from the queue
*/
-size_t SecureQueue::read(byte output[], size_t length)
+size_t SecureQueue::read(uint8_t output[], size_t length)
{
size_t got = 0;
while(length && m_head)
@@ -161,7 +161,7 @@ size_t SecureQueue::read(byte output[], size_t length)
/*
* Read data, but do not remove it from queue
*/
-size_t SecureQueue::peek(byte output[], size_t length, size_t offset) const
+size_t SecureQueue::peek(uint8_t output[], size_t length, size_t offset) const
{
SecureQueueNode* current = m_head;
diff --git a/src/lib/filters/secqueue.h b/src/lib/filters/secqueue.h
index 33afd478a..b4b977411 100644
--- a/src/lib/filters/secqueue.h
+++ b/src/lib/filters/secqueue.h
@@ -22,10 +22,10 @@ class BOTAN_DLL SecureQueue : public Fanout_Filter, public DataSource
public:
std::string name() const override { return "Queue"; }
- void write(const byte[], size_t) override;
+ void write(const uint8_t[], size_t) override;
- size_t read(byte[], size_t) override;
- size_t peek(byte[], size_t, size_t = 0) const override;
+ size_t read(uint8_t[], size_t) override;
+ size_t peek(uint8_t[], size_t, size_t = 0) const override;
size_t get_bytes_read() const override;
bool end_of_data() const override;
diff --git a/src/lib/filters/threaded_fork.cpp b/src/lib/filters/threaded_fork.cpp
index 07df590f8..170264353 100644
--- a/src/lib/filters/threaded_fork.cpp
+++ b/src/lib/filters/threaded_fork.cpp
@@ -33,7 +33,7 @@ struct Threaded_Fork_Data
* are NOT running (i.e. before notifying the work condition, after
* the input_complete_barrier has reset.)
*/
- const byte* m_input = nullptr;
+ const uint8_t* m_input = nullptr;
/*
* The length of the work that needs to be done.
@@ -98,7 +98,7 @@ void Threaded_Fork::set_next(Filter* f[], size_t n)
}
}
-void Threaded_Fork::send(const byte input[], size_t length)
+void Threaded_Fork::send(const uint8_t input[], size_t length)
{
if(m_write_queue.size())
thread_delegate_work(m_write_queue.data(), m_write_queue.size());
@@ -115,7 +115,7 @@ void Threaded_Fork::send(const byte input[], size_t length)
m_write_queue.clear();
}
-void Threaded_Fork::thread_delegate_work(const byte input[], size_t length)
+void Threaded_Fork::thread_delegate_work(const uint8_t input[], size_t length)
{
//Set the data to do.
m_thread_data->m_input = input;
diff --git a/src/lib/hash/blake2/blake2b.cpp b/src/lib/hash/blake2/blake2b.cpp
index 928f344d7..b478af106 100644
--- a/src/lib/hash/blake2/blake2b.cpp
+++ b/src/lib/hash/blake2/blake2b.cpp
@@ -16,14 +16,14 @@ namespace Botan {
namespace {
-const u64bit blake2b_IV[BLAKE2B_IVU64COUNT] = {
+const uint64_t blake2b_IV[BLAKE2B_IVU64COUNT] = {
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
};
-const u64bit blake2b_sigma[12][16] = {
+const uint64_t blake2b_sigma[12][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
@@ -57,17 +57,17 @@ Blake2b::Blake2b(size_t output_bits) :
void Blake2b::state_init()
{
std::copy(std::begin(blake2b_IV), std::end(blake2b_IV), m_H.begin());
- m_H[0] ^= 0x01010000 ^ static_cast<byte>(output_length());
+ m_H[0] ^= 0x01010000 ^ static_cast<uint8_t>(output_length());
m_T[0] = m_T[1] = 0;
m_F[0] = m_F[1] = 0;
}
void Blake2b::compress(bool lastblock)
{
- u64bit m[16];
- u64bit v[16];
- u64bit* const H = m_H.data();
- const byte* const block = m_buffer.data();
+ uint64_t m[16];
+ uint64_t v[16];
+ uint64_t* const H = m_H.data();
+ const uint8_t* const block = m_buffer.data();
if(lastblock)
{
@@ -76,7 +76,7 @@ void Blake2b::compress(bool lastblock)
for(int i = 0; i < 16; i++)
{
- m[i] = load_le<u64bit>(block, i);
+ m[i] = load_le<uint64_t>(block, i);
}
for(int i = 0; i < 8; i++)
@@ -93,13 +93,13 @@ void Blake2b::compress(bool lastblock)
#define G(r, i, a, b, c, d) \
do { \
a = a + b + m[blake2b_sigma[r][2 * i + 0]]; \
- d = rotate_right<u64bit>(d ^ a, 32); \
+ d = rotate_right<uint64_t>(d ^ a, 32); \
c = c + d; \
- b = rotate_right<u64bit>(b ^ c, 24); \
+ b = rotate_right<uint64_t>(b ^ c, 24); \
a = a + b + m[blake2b_sigma[r][2 * i + 1]]; \
- d = rotate_right<u64bit>(d ^ a, 16); \
+ d = rotate_right<uint64_t>(d ^ a, 16); \
c = c + d; \
- b = rotate_right<u64bit>(b ^ c, 63); \
+ b = rotate_right<uint64_t>(b ^ c, 63); \
} while(0)
#define ROUND(r) \
@@ -136,7 +136,7 @@ void Blake2b::compress(bool lastblock)
#undef ROUND
}
-void Blake2b::increment_counter(const u64bit inc)
+void Blake2b::increment_counter(const uint64_t inc)
{
m_T[0] += inc;
if(m_T[0] < inc)
@@ -145,14 +145,14 @@ void Blake2b::increment_counter(const u64bit inc)
}
}
-void Blake2b::add_data(const byte input[], size_t length)
+void Blake2b::add_data(const uint8_t input[], size_t length)
{
if(!input || length == 0)
{
return;
}
- byte* const buffer = m_buffer.data();
+ uint8_t* const buffer = m_buffer.data();
while(length > 0)
{
@@ -175,22 +175,22 @@ void Blake2b::add_data(const byte input[], size_t length)
}
}
-void Blake2b::final_result(byte output[])
+void Blake2b::final_result(uint8_t output[])
{
if(!output)
{
return;
}
- byte* const buffer = m_buffer.data();
- const u64bit* const H = static_cast<const u64bit*>(m_H.data());
- u16bit outlen = static_cast<u16bit>(output_length());
+ uint8_t* const buffer = m_buffer.data();
+ const uint64_t* const H = static_cast<const uint64_t*>(m_H.data());
+ uint16_t outlen = static_cast<uint16_t>(output_length());
std::memset(buffer + m_buflen, 0, BLAKE2B_BLOCKBYTES - m_buflen);
increment_counter(m_buflen);
compress(true);
- for (u16bit i = 0; i < outlen; i++)
+ for (uint16_t i = 0; i < outlen; i++)
{
output[i] = (H[i >> 3] >> (8 * (i & 7))) & 0xFF;
}
diff --git a/src/lib/hash/blake2/blake2b.h b/src/lib/hash/blake2/blake2b.h
index 343f276b5..473352174 100644
--- a/src/lib/hash/blake2/blake2b.h
+++ b/src/lib/hash/blake2/blake2b.h
@@ -39,21 +39,21 @@ class BOTAN_DLL Blake2b final : public HashFunction
void clear() override;
private:
- void add_data(const byte input[], size_t length) override;
- void final_result(byte out[]) override;
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t out[]) override;
inline void state_init();
- inline void increment_counter(const u64bit inc);
+ inline void increment_counter(const uint64_t inc);
void compress(bool lastblock = false);
size_t m_output_bits;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
size_t m_buflen;
- secure_vector<u64bit> m_H;
- u64bit m_T[2];
- u64bit m_F[2];
+ secure_vector<uint64_t> m_H;
+ uint64_t m_T[2];
+ uint64_t m_F[2];
};
}
diff --git a/src/lib/hash/checksum/adler32/adler32.cpp b/src/lib/hash/checksum/adler32/adler32.cpp
index 304c664dd..b7f6356c4 100644
--- a/src/lib/hash/checksum/adler32/adler32.cpp
+++ b/src/lib/hash/checksum/adler32/adler32.cpp
@@ -12,11 +12,11 @@ namespace Botan {
namespace {
-void adler32_update(const byte input[], size_t length,
- u16bit& S1, u16bit& S2)
+void adler32_update(const uint8_t input[], size_t length,
+ uint16_t& S1, uint16_t& S2)
{
- u32bit S1x = S1;
- u32bit S2x = S2;
+ uint32_t S1x = S1;
+ uint32_t S2x = S2;
while(length >= 16)
{
@@ -55,7 +55,7 @@ void adler32_update(const byte input[], size_t length,
/*
* Update an Adler32 Checksum
*/
-void Adler32::add_data(const byte input[], size_t length)
+void Adler32::add_data(const uint8_t input[], size_t length)
{
const size_t PROCESS_AMOUNT = 5552;
@@ -72,7 +72,7 @@ void Adler32::add_data(const byte input[], size_t length)
/*
* Finalize an Adler32 Checksum
*/
-void Adler32::final_result(byte output[])
+void Adler32::final_result(uint8_t output[])
{
store_be(output, m_S2, m_S1);
clear();
diff --git a/src/lib/hash/checksum/adler32/adler32.h b/src/lib/hash/checksum/adler32/adler32.h
index 73df6134a..eaf57c656 100644
--- a/src/lib/hash/checksum/adler32/adler32.h
+++ b/src/lib/hash/checksum/adler32/adler32.h
@@ -27,9 +27,9 @@ class BOTAN_DLL Adler32 final : public HashFunction
Adler32() { clear(); }
~Adler32() { clear(); }
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- u16bit m_S1, m_S2;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ uint16_t m_S1, m_S2;
};
}
diff --git a/src/lib/hash/checksum/crc24/crc24.cpp b/src/lib/hash/checksum/crc24/crc24.cpp
index 6f1eea453..923433d7e 100644
--- a/src/lib/hash/checksum/crc24/crc24.cpp
+++ b/src/lib/hash/checksum/crc24/crc24.cpp
@@ -13,9 +13,9 @@ namespace Botan {
/*
* Update a CRC24 Checksum
*/
-void CRC24::add_data(const byte input[], size_t length)
+void CRC24::add_data(const uint8_t input[], size_t length)
{
- const u32bit TABLE[256] = {
+ const uint32_t TABLE[256] = {
0x00000000, 0x00864CFB, 0x008AD50D, 0x000C99F6, 0x0093E6E1, 0x0015AA1A,
0x001933EC, 0x009F7F17, 0x00A18139, 0x0027CDC2, 0x002B5434, 0x00AD18CF,
0x003267D8, 0x00B42B23, 0x00B8B2D5, 0x003EFE2E, 0x00C54E89, 0x00430272,
@@ -60,7 +60,7 @@ void CRC24::add_data(const byte input[], size_t length)
0x00FA48FA, 0x007C0401, 0x0042FA2F, 0x00C4B6D4, 0x00C82F22, 0x004E63D9,
0x00D11CCE, 0x00575035, 0x005BC9C3, 0x00DD8538 };
- u32bit tmp = m_crc;
+ uint32_t tmp = m_crc;
while(length >= 16)
{
tmp = TABLE[((tmp >> 16) ^ input[ 0]) & 0xFF] ^ (tmp << 8);
@@ -92,7 +92,7 @@ void CRC24::add_data(const byte input[], size_t length)
/*
* Finalize a CRC24 Checksum
*/
-void CRC24::final_result(byte output[])
+void CRC24::final_result(uint8_t output[])
{
for(size_t i = 0; i != 3; ++i)
output[i] = get_byte(i+1, m_crc);
diff --git a/src/lib/hash/checksum/crc24/crc24.h b/src/lib/hash/checksum/crc24/crc24.h
index f80ee1c2a..95977bc48 100644
--- a/src/lib/hash/checksum/crc24/crc24.h
+++ b/src/lib/hash/checksum/crc24/crc24.h
@@ -27,9 +27,9 @@ class BOTAN_DLL CRC24 final : public HashFunction
CRC24() { clear(); }
~CRC24() { clear(); }
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- u32bit m_crc;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ uint32_t m_crc;
};
}
diff --git a/src/lib/hash/checksum/crc32/crc32.cpp b/src/lib/hash/checksum/crc32/crc32.cpp
index ca8c87c5f..1bbc35ac8 100644
--- a/src/lib/hash/checksum/crc32/crc32.cpp
+++ b/src/lib/hash/checksum/crc32/crc32.cpp
@@ -13,9 +13,9 @@ namespace Botan {
/*
* Update a CRC32 Checksum
*/
-void CRC32::add_data(const byte input[], size_t length)
+void CRC32::add_data(const uint8_t input[], size_t length)
{
- const u32bit TABLE[256] = {
+ const uint32_t TABLE[256] = {
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
@@ -60,7 +60,7 @@ void CRC32::add_data(const byte input[], size_t length)
0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D };
- u32bit tmp = m_crc;
+ uint32_t tmp = m_crc;
while(length >= 16)
{
tmp = TABLE[(tmp ^ input[ 0]) & 0xFF] ^ (tmp >> 8);
@@ -92,7 +92,7 @@ void CRC32::add_data(const byte input[], size_t length)
/*
* Finalize a CRC32 Checksum
*/
-void CRC32::final_result(byte output[])
+void CRC32::final_result(uint8_t output[])
{
m_crc ^= 0xFFFFFFFF;
store_be(m_crc, output);
diff --git a/src/lib/hash/checksum/crc32/crc32.h b/src/lib/hash/checksum/crc32/crc32.h
index 987f34608..fd9db1b3e 100644
--- a/src/lib/hash/checksum/crc32/crc32.h
+++ b/src/lib/hash/checksum/crc32/crc32.h
@@ -27,9 +27,9 @@ class BOTAN_DLL CRC32 final : public HashFunction
CRC32() { clear(); }
~CRC32() { clear(); }
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- u32bit m_crc;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ uint32_t m_crc;
};
}
diff --git a/src/lib/hash/comb4p/comb4p.cpp b/src/lib/hash/comb4p/comb4p.cpp
index 4659ace77..ece8c9051 100644
--- a/src/lib/hash/comb4p/comb4p.cpp
+++ b/src/lib/hash/comb4p/comb4p.cpp
@@ -12,9 +12,9 @@ namespace Botan {
namespace {
-void comb4p_round(secure_vector<byte>& out,
- const secure_vector<byte>& in,
- byte round_no,
+void comb4p_round(secure_vector<uint8_t>& out,
+ const secure_vector<uint8_t>& in,
+ uint8_t round_no,
HashFunction& h1,
HashFunction& h2)
{
@@ -24,7 +24,7 @@ void comb4p_round(secure_vector<byte>& out,
h1.update(in.data(), in.size());
h2.update(in.data(), in.size());
- secure_vector<byte> h_buf = h1.final();
+ secure_vector<uint8_t> h_buf = h1.final();
xor_buf(out.data(), h_buf.data(), std::min(out.size(), h_buf.size()));
h_buf = h2.final();
@@ -69,16 +69,16 @@ void Comb4P::clear()
m_hash2->update(0);
}
-void Comb4P::add_data(const byte input[], size_t length)
+void Comb4P::add_data(const uint8_t input[], size_t length)
{
m_hash1->update(input, length);
m_hash2->update(input, length);
}
-void Comb4P::final_result(byte out[])
+void Comb4P::final_result(uint8_t out[])
{
- secure_vector<byte> h1 = m_hash1->final();
- secure_vector<byte> h2 = m_hash2->final();
+ secure_vector<uint8_t> h1 = m_hash1->final();
+ secure_vector<uint8_t> h2 = m_hash2->final();
// First round
xor_buf(h1.data(), h2.data(), std::min(h1.size(), h2.size()));
diff --git a/src/lib/hash/comb4p/comb4p.h b/src/lib/hash/comb4p/comb4p.h
index cb78914e7..a578b56c8 100644
--- a/src/lib/hash/comb4p/comb4p.h
+++ b/src/lib/hash/comb4p/comb4p.h
@@ -44,8 +44,8 @@ class BOTAN_DLL Comb4P final : public HashFunction
void clear() override;
private:
- void add_data(const byte input[], size_t length) override;
- void final_result(byte out[]) override;
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t out[]) override;
std::unique_ptr<HashFunction> m_hash1, m_hash2;
};
diff --git a/src/lib/hash/gost_3411/gost_3411.cpp b/src/lib/hash/gost_3411/gost_3411.cpp
index 17c590a5c..62028e496 100644
--- a/src/lib/hash/gost_3411/gost_3411.cpp
+++ b/src/lib/hash/gost_3411/gost_3411.cpp
@@ -34,7 +34,7 @@ void GOST_34_11::clear()
/**
* Hash additional inputs
*/
-void GOST_34_11::add_data(const byte input[], size_t length)
+void GOST_34_11::add_data(const uint8_t input[], size_t length)
{
m_count += length;
@@ -64,26 +64,26 @@ void GOST_34_11::add_data(const byte input[], size_t length)
/**
* The GOST 34.11 compression function
*/
-void GOST_34_11::compress_n(const byte input[], size_t blocks)
+void GOST_34_11::compress_n(const uint8_t input[], size_t blocks)
{
for(size_t i = 0; i != blocks; ++i)
{
- for(u16bit j = 0, carry = 0; j != 32; ++j)
+ for(uint16_t j = 0, carry = 0; j != 32; ++j)
{
- u16bit s = m_sum[j] + input[32*i+j] + carry;
+ uint16_t s = m_sum[j] + input[32*i+j] + carry;
carry = get_byte(0, s);
m_sum[j] = get_byte(1, s);
}
- byte S[32] = { 0 };
+ uint8_t S[32] = { 0 };
- u64bit U[4], V[4];
+ uint64_t U[4], V[4];
load_be(U, m_hash.data(), 4);
load_be(V, input + 32*i, 4);
for(size_t j = 0; j != 4; ++j)
{
- byte key[32] = { 0 };
+ uint8_t key[32] = { 0 };
// P transformation
for(size_t k = 0; k != 4; ++k)
@@ -97,7 +97,7 @@ void GOST_34_11::compress_n(const byte input[], size_t blocks)
break;
// A(x)
- u64bit A_U = U[0];
+ uint64_t A_U = U[0];
U[0] = U[1];
U[1] = U[2];
U[2] = U[3];
@@ -112,15 +112,15 @@ void GOST_34_11::compress_n(const byte input[], size_t blocks)
}
// A(A(x))
- u64bit AA_V_1 = V[0] ^ V[1];
- u64bit AA_V_2 = V[1] ^ V[2];
+ uint64_t AA_V_1 = V[0] ^ V[1];
+ uint64_t AA_V_2 = V[1] ^ V[2];
V[0] = V[2];
V[1] = V[3];
V[2] = AA_V_1;
V[3] = AA_V_2;
}
- byte S2[32] = { 0 };
+ uint8_t S2[32] = { 0 };
// 12 rounds of psi
S2[ 0] = S[24];
@@ -214,7 +214,7 @@ void GOST_34_11::compress_n(const byte input[], size_t blocks)
/**
* Produce the final GOST 34.11 output
*/
-void GOST_34_11::final_result(byte out[])
+void GOST_34_11::final_result(uint8_t out[])
{
if(m_position)
{
@@ -222,11 +222,11 @@ void GOST_34_11::final_result(byte out[])
compress_n(m_buffer.data(), 1);
}
- secure_vector<byte> length_buf(32);
- const u64bit bit_count = m_count * 8;
+ secure_vector<uint8_t> length_buf(32);
+ const uint64_t bit_count = m_count * 8;
store_le(bit_count, length_buf.data());
- secure_vector<byte> sum_buf = m_sum;
+ secure_vector<uint8_t> sum_buf = m_sum;
compress_n(length_buf.data(), 1);
compress_n(sum_buf.data(), 1);
diff --git a/src/lib/hash/gost_3411/gost_3411.h b/src/lib/hash/gost_3411/gost_3411.h
index 16f6a4954..e18ab56fa 100644
--- a/src/lib/hash/gost_3411/gost_3411.h
+++ b/src/lib/hash/gost_3411/gost_3411.h
@@ -28,15 +28,15 @@ class BOTAN_DLL GOST_34_11 final : public HashFunction
GOST_34_11();
private:
- void compress_n(const byte input[], size_t blocks);
+ void compress_n(const uint8_t input[], size_t blocks);
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
GOST_28147_89 m_cipher;
- secure_vector<byte> m_buffer, m_sum, m_hash;
+ secure_vector<uint8_t> m_buffer, m_sum, m_hash;
size_t m_position;
- u64bit m_count;
+ uint64_t m_count;
};
}
diff --git a/src/lib/hash/keccak/keccak.cpp b/src/lib/hash/keccak/keccak.cpp
index e0c67131b..1d2747ff2 100644
--- a/src/lib/hash/keccak/keccak.cpp
+++ b/src/lib/hash/keccak/keccak.cpp
@@ -42,14 +42,14 @@ void Keccak_1600::clear()
m_S_pos = 0;
}
-void Keccak_1600::add_data(const byte input[], size_t length)
+void Keccak_1600::add_data(const uint8_t input[], size_t length)
{
m_S_pos = SHA_3::absorb(m_bitrate, m_S, m_S_pos, input, length);
}
-void Keccak_1600::final_result(byte output[])
+void Keccak_1600::final_result(uint8_t output[])
{
- std::vector<byte> padding(m_bitrate / 8 - m_S_pos);
+ std::vector<uint8_t> padding(m_bitrate / 8 - m_S_pos);
padding[0] = 0x01;
padding[padding.size()-1] |= 0x80;
diff --git a/src/lib/hash/keccak/keccak.h b/src/lib/hash/keccak/keccak.h
index ac50d4c52..a2c14c65a 100644
--- a/src/lib/hash/keccak/keccak.h
+++ b/src/lib/hash/keccak/keccak.h
@@ -35,11 +35,11 @@ class BOTAN_DLL Keccak_1600 final : public HashFunction
void clear() override;
private:
- void add_data(const byte input[], size_t length) override;
- void final_result(byte out[]) override;
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t out[]) override;
size_t m_output_bits, m_bitrate;
- secure_vector<u64bit> m_S;
+ secure_vector<uint64_t> m_S;
size_t m_S_pos;
};
diff --git a/src/lib/hash/md4/md4.cpp b/src/lib/hash/md4/md4.cpp
index d22f2d1ac..014ba8c2c 100644
--- a/src/lib/hash/md4/md4.cpp
+++ b/src/lib/hash/md4/md4.cpp
@@ -14,7 +14,7 @@ namespace {
/*
* MD4 FF Function
*/
-inline void FF(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S)
+inline void FF(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t M, uint8_t S)
{
A += (D ^ (B & (C ^ D))) + M;
A = rotate_left(A, S);
@@ -23,7 +23,7 @@ inline void FF(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S)
/*
* MD4 GG Function
*/
-inline void GG(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S)
+inline void GG(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t M, uint8_t S)
{
A += ((B & C) | (D & (B | C))) + M + 0x5A827999;
A = rotate_left(A, S);
@@ -32,7 +32,7 @@ inline void GG(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S)
/*
* MD4 HH Function
*/
-inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S)
+inline void HH(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t M, uint8_t S)
{
A += (B ^ C ^ D) + M + 0x6ED9EBA1;
A = rotate_left(A, S);
@@ -43,9 +43,9 @@ inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S)
/*
* MD4 Compression Function
*/
-void MD4::compress_n(const byte input[], size_t blocks)
+void MD4::compress_n(const uint8_t input[], size_t blocks)
{
- u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3];
+ uint32_t A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3];
for(size_t i = 0; i != blocks; ++i)
{
@@ -90,7 +90,7 @@ void MD4::compress_n(const byte input[], size_t blocks)
/*
* Copy out the digest
*/
-void MD4::copy_out(byte output[])
+void MD4::copy_out(uint8_t output[])
{
copy_out_vec_le(output, output_length(), m_digest);
}
diff --git a/src/lib/hash/md4/md4.h b/src/lib/hash/md4/md4.h
index 8b7ab5d70..ebd0bdedd 100644
--- a/src/lib/hash/md4/md4.h
+++ b/src/lib/hash/md4/md4.h
@@ -27,19 +27,19 @@ class BOTAN_DLL MD4 final : public MDx_HashFunction
MD4() : MDx_HashFunction(64, false, true), m_M(16), m_digest(4)
{ clear(); }
protected:
- void compress_n(const byte input[], size_t blocks) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t input[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
private:
/**
* The message buffer
*/
- secure_vector<u32bit> m_M;
+ secure_vector<uint32_t> m_M;
/**
* The digest value
*/
- secure_vector<u32bit> m_digest;
+ secure_vector<uint32_t> m_digest;
};
}
diff --git a/src/lib/hash/md5/md5.cpp b/src/lib/hash/md5/md5.cpp
index 439dbde7b..0612ba956 100644
--- a/src/lib/hash/md5/md5.cpp
+++ b/src/lib/hash/md5/md5.cpp
@@ -14,8 +14,8 @@ namespace {
/*
* MD5 FF Function
*/
-inline void FF(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
- byte S, u32bit magic)
+inline void FF(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t msg,
+ uint8_t S, uint32_t magic)
{
A += (D ^ (B & (C ^ D))) + msg + magic;
A = rotate_left(A, S) + B;
@@ -24,8 +24,8 @@ inline void FF(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
/*
* MD5 GG Function
*/
-inline void GG(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
- byte S, u32bit magic)
+inline void GG(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t msg,
+ uint8_t S, uint32_t magic)
{
A += (C ^ (D & (B ^ C))) + msg + magic;
A = rotate_left(A, S) + B;
@@ -34,8 +34,8 @@ inline void GG(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
/*
* MD5 HH Function
*/
-inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
- byte S, u32bit magic)
+inline void HH(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t msg,
+ uint8_t S, uint32_t magic)
{
A += (B ^ C ^ D) + msg + magic;
A = rotate_left(A, S) + B;
@@ -44,8 +44,8 @@ inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
/*
* MD5 II Function
*/
-inline void II(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
- byte S, u32bit magic)
+inline void II(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t msg,
+ uint8_t S, uint32_t magic)
{
A += (C ^ (B | ~D)) + msg + magic;
A = rotate_left(A, S) + B;
@@ -56,9 +56,9 @@ inline void II(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
/*
* MD5 Compression Function
*/
-void MD5::compress_n(const byte input[], size_t blocks)
+void MD5::compress_n(const uint8_t input[], size_t blocks)
{
- u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3];
+ uint32_t A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3];
for(size_t i = 0; i != blocks; ++i)
{
@@ -112,7 +112,7 @@ void MD5::compress_n(const byte input[], size_t blocks)
/*
* Copy out the digest
*/
-void MD5::copy_out(byte output[])
+void MD5::copy_out(uint8_t output[])
{
copy_out_vec_le(output, output_length(), m_digest);
}
diff --git a/src/lib/hash/md5/md5.h b/src/lib/hash/md5/md5.h
index bbeffee50..13a423594 100644
--- a/src/lib/hash/md5/md5.h
+++ b/src/lib/hash/md5/md5.h
@@ -27,19 +27,19 @@ class BOTAN_DLL MD5 final : public MDx_HashFunction
MD5() : MDx_HashFunction(64, false, true), m_M(16), m_digest(4)
{ clear(); }
protected:
- void compress_n(const byte[], size_t blocks) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
private:
/**
* The message buffer
*/
- secure_vector<u32bit> m_M;
+ secure_vector<uint32_t> m_M;
/**
* The digest value
*/
- secure_vector<u32bit> m_digest;
+ secure_vector<uint32_t> m_digest;
};
}
diff --git a/src/lib/hash/mdx_hash/mdx_hash.cpp b/src/lib/hash/mdx_hash/mdx_hash.cpp
index f21b4ac34..c2fb320ec 100644
--- a/src/lib/hash/mdx_hash/mdx_hash.cpp
+++ b/src/lib/hash/mdx_hash/mdx_hash.cpp
@@ -38,7 +38,7 @@ void MDx_HashFunction::clear()
/*
* Update the hash
*/
-void MDx_HashFunction::add_data(const byte input[], size_t length)
+void MDx_HashFunction::add_data(const uint8_t input[], size_t length)
{
m_count += length;
@@ -68,7 +68,7 @@ void MDx_HashFunction::add_data(const byte input[], size_t length)
/*
* Finalize a hash
*/
-void MDx_HashFunction::final_result(byte output[])
+void MDx_HashFunction::final_result(uint8_t output[])
{
m_buffer[m_position] = (BIG_BIT_ENDIAN ? 0x80 : 0x01);
for(size_t i = m_position+1; i != m_buffer.size(); ++i)
@@ -90,14 +90,14 @@ void MDx_HashFunction::final_result(byte output[])
/*
* Write the count bits to the buffer
*/
-void MDx_HashFunction::write_count(byte out[])
+void MDx_HashFunction::write_count(uint8_t out[])
{
if(COUNT_SIZE < 8)
throw Invalid_State("MDx_HashFunction::write_count: COUNT_SIZE < 8");
if(COUNT_SIZE >= output_length() || COUNT_SIZE >= hash_block_size())
throw Invalid_Argument("MDx_HashFunction: COUNT_SIZE is too big");
- const u64bit bit_count = m_count * 8;
+ const uint64_t bit_count = m_count * 8;
if(BIG_BYTE_ENDIAN)
store_be(bit_count, out + COUNT_SIZE - 8);
diff --git a/src/lib/hash/mdx_hash/mdx_hash.h b/src/lib/hash/mdx_hash/mdx_hash.h
index 4b2f9bad0..649cf387d 100644
--- a/src/lib/hash/mdx_hash/mdx_hash.h
+++ b/src/lib/hash/mdx_hash/mdx_hash.h
@@ -31,15 +31,15 @@ class BOTAN_DLL MDx_HashFunction : public HashFunction
size_t hash_block_size() const override { return m_buffer.size(); }
protected:
- void add_data(const byte input[], size_t length) override;
- void final_result(byte output[]) override;
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t output[]) override;
/**
* Run the hash's compression function over a set of blocks
* @param blocks the input
* @param block_n the number of blocks
*/
- virtual void compress_n(const byte blocks[], size_t block_n) = 0;
+ virtual void compress_n(const uint8_t blocks[], size_t block_n) = 0;
void clear() override;
@@ -47,16 +47,16 @@ class BOTAN_DLL MDx_HashFunction : public HashFunction
* Copy the output to the buffer
* @param buffer to put the output into
*/
- virtual void copy_out(byte buffer[]) = 0;
+ virtual void copy_out(uint8_t buffer[]) = 0;
/**
* Write the count, if used, to this spot
* @param out where to write the counter to
*/
- virtual void write_count(byte out[]);
+ virtual void write_count(uint8_t out[]);
private:
- secure_vector<byte> m_buffer;
- u64bit m_count;
+ secure_vector<uint8_t> m_buffer;
+ uint64_t m_count;
size_t m_position;
const bool BIG_BYTE_ENDIAN, BIG_BIT_ENDIAN;
diff --git a/src/lib/hash/par_hash/par_hash.cpp b/src/lib/hash/par_hash/par_hash.cpp
index 7320afee3..2a1ef7c9c 100644
--- a/src/lib/hash/par_hash/par_hash.cpp
+++ b/src/lib/hash/par_hash/par_hash.cpp
@@ -10,15 +10,15 @@
namespace Botan {
-void Parallel::add_data(const byte input[], size_t length)
+void Parallel::add_data(const uint8_t input[], size_t length)
{
for(auto&& hash : m_hashes)
hash->update(input, length);
}
-void Parallel::final_result(byte out[])
+void Parallel::final_result(uint8_t out[])
{
- u32bit offset = 0;
+ uint32_t offset = 0;
for(auto&& hash : m_hashes)
{
diff --git a/src/lib/hash/par_hash/par_hash.h b/src/lib/hash/par_hash/par_hash.h
index 67d026c2f..cbc2ad591 100644
--- a/src/lib/hash/par_hash/par_hash.h
+++ b/src/lib/hash/par_hash/par_hash.h
@@ -36,8 +36,8 @@ class BOTAN_DLL Parallel final : public HashFunction
private:
Parallel() {}
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
std::vector<std::unique_ptr<HashFunction>> m_hashes;
};
diff --git a/src/lib/hash/rmd160/rmd160.cpp b/src/lib/hash/rmd160/rmd160.cpp
index a48b97882..8d190a74f 100644
--- a/src/lib/hash/rmd160/rmd160.cpp
+++ b/src/lib/hash/rmd160/rmd160.cpp
@@ -14,8 +14,8 @@ namespace {
/*
* RIPEMD-160 F1 Function
*/
-inline void F1(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
- u32bit msg, u32bit shift)
+inline void F1(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
+ uint32_t msg, uint32_t shift)
{
A += (B ^ C ^ D) + msg;
A = rotate_left(A, shift) + E;
@@ -25,8 +25,8 @@ inline void F1(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
/*
* RIPEMD-160 F2 Function
*/
-inline void F2(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
- u32bit msg, u32bit shift, u32bit magic)
+inline void F2(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
+ uint32_t msg, uint32_t shift, uint32_t magic)
{
A += (D ^ (B & (C ^ D))) + msg + magic;
A = rotate_left(A, shift) + E;
@@ -36,8 +36,8 @@ inline void F2(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
/*
* RIPEMD-160 F3 Function
*/
-inline void F3(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
- u32bit msg, u32bit shift, u32bit magic)
+inline void F3(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
+ uint32_t msg, uint32_t shift, uint32_t magic)
{
A += (D ^ (B | ~C)) + msg + magic;
A = rotate_left(A, shift) + E;
@@ -47,8 +47,8 @@ inline void F3(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
/*
* RIPEMD-160 F4 Function
*/
-inline void F4(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
- u32bit msg, u32bit shift, u32bit magic)
+inline void F4(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
+ uint32_t msg, uint32_t shift, uint32_t magic)
{
A += (C ^ (D & (B ^ C))) + msg + magic;
A = rotate_left(A, shift) + E;
@@ -58,8 +58,8 @@ inline void F4(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
/*
* RIPEMD-160 F5 Function
*/
-inline void F5(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
- u32bit msg, u32bit shift, u32bit magic)
+inline void F5(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
+ uint32_t msg, uint32_t shift, uint32_t magic)
{
A += (B ^ (C | ~D)) + msg + magic;
A = rotate_left(A, shift) + E;
@@ -71,9 +71,9 @@ inline void F5(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
/*
* RIPEMD-160 Compression Function
*/
-void RIPEMD_160::compress_n(const byte input[], size_t blocks)
+void RIPEMD_160::compress_n(const uint8_t input[], size_t blocks)
{
- const u32bit MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1,
+ const uint32_t MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1,
MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0xA953FD4E,
MAGIC6 = 0x50A28BE6, MAGIC7 = 0x5C4DD124,
MAGIC8 = 0x6D703EF3, MAGIC9 = 0x7A6D76E9;
@@ -82,7 +82,7 @@ void RIPEMD_160::compress_n(const byte input[], size_t blocks)
{
load_le(m_M.data(), input, m_M.size());
- u32bit A1 = m_digest[0], A2 = A1, B1 = m_digest[1], B2 = B1,
+ uint32_t A1 = m_digest[0], A2 = A1, B1 = m_digest[1], B2 = B1,
C1 = m_digest[2], C2 = C1, D1 = m_digest[3], D2 = D1,
E1 = m_digest[4], E2 = E1;
@@ -185,7 +185,7 @@ void RIPEMD_160::compress_n(const byte input[], size_t blocks)
/*
* Copy out the digest
*/
-void RIPEMD_160::copy_out(byte output[])
+void RIPEMD_160::copy_out(uint8_t output[])
{
copy_out_vec_le(output, output_length(), m_digest);
}
diff --git a/src/lib/hash/rmd160/rmd160.h b/src/lib/hash/rmd160/rmd160.h
index 0e4103101..9e2d1de87 100644
--- a/src/lib/hash/rmd160/rmd160.h
+++ b/src/lib/hash/rmd160/rmd160.h
@@ -27,10 +27,10 @@ class BOTAN_DLL RIPEMD_160 final : public MDx_HashFunction
RIPEMD_160() : MDx_HashFunction(64, false, true), m_M(16), m_digest(5)
{ clear(); }
private:
- void compress_n(const byte[], size_t blocks) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
- secure_vector<u32bit> m_M, m_digest;
+ secure_vector<uint32_t> m_M, m_digest;
};
}
diff --git a/src/lib/hash/sha1/sha160.cpp b/src/lib/hash/sha1/sha160.cpp
index 87738fb00..735789cab 100644
--- a/src/lib/hash/sha1/sha160.cpp
+++ b/src/lib/hash/sha1/sha160.cpp
@@ -17,7 +17,7 @@ namespace {
/*
* SHA-160 F1 Function
*/
-inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
+inline void F1(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg)
{
E += (D ^ (B & (C ^ D))) + msg + 0x5A827999 + rotate_left(A, 5);
B = rotate_left(B, 30);
@@ -26,7 +26,7 @@ inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 F2 Function
*/
-inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
+inline void F2(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg)
{
E += (B ^ C ^ D) + msg + 0x6ED9EBA1 + rotate_left(A, 5);
B = rotate_left(B, 30);
@@ -35,7 +35,7 @@ inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 F3 Function
*/
-inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
+inline void F3(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg)
{
E += ((B & C) | ((B | C) & D)) + msg + 0x8F1BBCDC + rotate_left(A, 5);
B = rotate_left(B, 30);
@@ -44,7 +44,7 @@ inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 F4 Function
*/
-inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
+inline void F4(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg)
{
E += (B ^ C ^ D) + msg + 0xCA62C1D6 + rotate_left(A, 5);
B = rotate_left(B, 30);
@@ -57,7 +57,7 @@ inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 Compression Function
*/
-void SHA_160::compress_n(const byte input[], size_t blocks)
+void SHA_160::compress_n(const uint8_t input[], size_t blocks)
{
using namespace SHA1_F;
@@ -69,7 +69,7 @@ void SHA_160::compress_n(const byte input[], size_t blocks)
#endif
- u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2],
+ uint32_t A = m_digest[0], B = m_digest[1], C = m_digest[2],
D = m_digest[3], E = m_digest[4];
m_W.resize(80);
@@ -147,7 +147,7 @@ void SHA_160::compress_n(const byte input[], size_t blocks)
/*
* Copy out the digest
*/
-void SHA_160::copy_out(byte output[])
+void SHA_160::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
diff --git a/src/lib/hash/sha1/sha160.h b/src/lib/hash/sha1/sha160.h
index d7860834f..7ba7257af 100644
--- a/src/lib/hash/sha1/sha160.h
+++ b/src/lib/hash/sha1/sha160.h
@@ -30,26 +30,26 @@ class BOTAN_DLL SHA_160 final : public MDx_HashFunction
}
private:
- void compress_n(const byte[], size_t blocks) override;
+ void compress_n(const uint8_t[], size_t blocks) override;
#if defined(BOTAN_HAS_SHA1_SSE2)
- static void sse2_compress_n(secure_vector<u32bit>& digest,
- const byte blocks[],
+ static void sse2_compress_n(secure_vector<uint32_t>& digest,
+ const uint8_t blocks[],
size_t block_count);
#endif
- void copy_out(byte[]) override;
+ void copy_out(uint8_t[]) override;
/**
* The digest value
*/
- secure_vector<u32bit> m_digest;
+ secure_vector<uint32_t> m_digest;
/**
* The message buffer
*/
- secure_vector<u32bit> m_W;
+ secure_vector<uint32_t> m_W;
};
typedef SHA_160 SHA_1;
diff --git a/src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp b/src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp
index 0f88bb4c2..8c7785051 100644
--- a/src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp
+++ b/src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp
@@ -111,7 +111,7 @@ W0 = W[t]..W[t+3]
/*
* SHA-160 F1 Function
*/
-inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
+inline void F1(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg)
{
E += (D ^ (B & (C ^ D))) + msg + rotate_left(A, 5);
B = rotate_left(B, 30);
@@ -120,7 +120,7 @@ inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 F2 Function
*/
-inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
+inline void F2(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg)
{
E += (B ^ C ^ D) + msg + rotate_left(A, 5);
B = rotate_left(B, 30);
@@ -129,7 +129,7 @@ inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 F3 Function
*/
-inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
+inline void F3(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg)
{
E += ((B & C) | ((B | C) & D)) + msg + rotate_left(A, 5);
B = rotate_left(B, 30);
@@ -138,7 +138,7 @@ inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 F4 Function
*/
-inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
+inline void F4(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg)
{
E += (B ^ C ^ D) + msg + rotate_left(A, 5);
B = rotate_left(B, 30);
@@ -153,7 +153,7 @@ inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
*/
//static
BOTAN_FUNC_ISA("sse2")
-void SHA_160::sse2_compress_n(secure_vector<uint32_t>& digest, const byte input[], size_t blocks)
+void SHA_160::sse2_compress_n(secure_vector<uint32_t>& digest, const uint8_t input[], size_t blocks)
{
using namespace SHA1_SSE2_F;
@@ -162,7 +162,7 @@ void SHA_160::sse2_compress_n(secure_vector<uint32_t>& digest, const byte input[
const __m128i K40_59 = _mm_set1_epi32(0x8F1BBCDC);
const __m128i K60_79 = _mm_set1_epi32(0xCA62C1D6);
- u32bit A = digest[0],
+ uint32_t A = digest[0],
B = digest[1],
C = digest[2],
D = digest[3],
@@ -173,7 +173,7 @@ void SHA_160::sse2_compress_n(secure_vector<uint32_t>& digest, const byte input[
for(size_t i = 0; i != blocks; ++i)
{
union v4si {
- u32bit u32[4];
+ uint32_t u32[4];
__m128i u128;
};
diff --git a/src/lib/hash/sha2_32/sha2_32.cpp b/src/lib/hash/sha2_32/sha2_32.cpp
index 46551431c..2a748a6aa 100644
--- a/src/lib/hash/sha2_32/sha2_32.cpp
+++ b/src/lib/hash/sha2_32/sha2_32.cpp
@@ -17,7 +17,7 @@ namespace SHA2_32 {
/*
* SHA-256 Rho Function
*/
-inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3)
+inline uint32_t rho(uint32_t X, uint32_t rot1, uint32_t rot2, uint32_t rot3)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^
rotate_right(X, rot3));
@@ -26,7 +26,7 @@ inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3)
/*
* SHA-256 Sigma Function
*/
-inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift)
+inline uint32_t sigma(uint32_t X, uint32_t rot1, uint32_t rot2, uint32_t shift)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift));
}
@@ -48,31 +48,31 @@ inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift)
/*
* SHA-224 / SHA-256 compression function
*/
-void compress(secure_vector<u32bit>& digest,
- const byte input[], size_t blocks)
+void compress(secure_vector<uint32_t>& digest,
+ const uint8_t input[], size_t blocks)
{
- u32bit A = digest[0], B = digest[1], C = digest[2],
+ uint32_t A = digest[0], B = digest[1], C = digest[2],
D = digest[3], E = digest[4], F = digest[5],
G = digest[6], H = digest[7];
for(size_t i = 0; i != blocks; ++i)
{
- u32bit W00 = load_be<u32bit>(input, 0);
- u32bit W01 = load_be<u32bit>(input, 1);
- u32bit W02 = load_be<u32bit>(input, 2);
- u32bit W03 = load_be<u32bit>(input, 3);
- u32bit W04 = load_be<u32bit>(input, 4);
- u32bit W05 = load_be<u32bit>(input, 5);
- u32bit W06 = load_be<u32bit>(input, 6);
- u32bit W07 = load_be<u32bit>(input, 7);
- u32bit W08 = load_be<u32bit>(input, 8);
- u32bit W09 = load_be<u32bit>(input, 9);
- u32bit W10 = load_be<u32bit>(input, 10);
- u32bit W11 = load_be<u32bit>(input, 11);
- u32bit W12 = load_be<u32bit>(input, 12);
- u32bit W13 = load_be<u32bit>(input, 13);
- u32bit W14 = load_be<u32bit>(input, 14);
- u32bit W15 = load_be<u32bit>(input, 15);
+ uint32_t W00 = load_be<uint32_t>(input, 0);
+ uint32_t W01 = load_be<uint32_t>(input, 1);
+ uint32_t W02 = load_be<uint32_t>(input, 2);
+ uint32_t W03 = load_be<uint32_t>(input, 3);
+ uint32_t W04 = load_be<uint32_t>(input, 4);
+ uint32_t W05 = load_be<uint32_t>(input, 5);
+ uint32_t W06 = load_be<uint32_t>(input, 6);
+ uint32_t W07 = load_be<uint32_t>(input, 7);
+ uint32_t W08 = load_be<uint32_t>(input, 8);
+ uint32_t W09 = load_be<uint32_t>(input, 9);
+ uint32_t W10 = load_be<uint32_t>(input, 10);
+ uint32_t W11 = load_be<uint32_t>(input, 11);
+ uint32_t W12 = load_be<uint32_t>(input, 12);
+ uint32_t W13 = load_be<uint32_t>(input, 13);
+ uint32_t W14 = load_be<uint32_t>(input, 14);
+ uint32_t W15 = load_be<uint32_t>(input, 15);
SHA2_32_F(A, B, C, D, E, F, G, H, W00, W14, W09, W01, 0x428A2F98);
SHA2_32_F(H, A, B, C, D, E, F, G, W01, W15, W10, W02, 0x71374491);
@@ -159,7 +159,7 @@ void compress(secure_vector<u32bit>& digest,
/*
* SHA-224 compression function
*/
-void SHA_224::compress_n(const byte input[], size_t blocks)
+void SHA_224::compress_n(const uint8_t input[], size_t blocks)
{
SHA2_32::compress(m_digest, input, blocks);
}
@@ -167,7 +167,7 @@ void SHA_224::compress_n(const byte input[], size_t blocks)
/*
* Copy out the digest
*/
-void SHA_224::copy_out(byte output[])
+void SHA_224::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
@@ -191,7 +191,7 @@ void SHA_224::clear()
/*
* SHA-256 compression function
*/
-void SHA_256::compress_n(const byte input[], size_t blocks)
+void SHA_256::compress_n(const uint8_t input[], size_t blocks)
{
SHA2_32::compress(m_digest, input, blocks);
}
@@ -199,7 +199,7 @@ void SHA_256::compress_n(const byte input[], size_t blocks)
/*
* Copy out the digest
*/
-void SHA_256::copy_out(byte output[])
+void SHA_256::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
diff --git a/src/lib/hash/sha2_32/sha2_32.h b/src/lib/hash/sha2_32/sha2_32.h
index 528fe9cfd..78e08c97a 100644
--- a/src/lib/hash/sha2_32/sha2_32.h
+++ b/src/lib/hash/sha2_32/sha2_32.h
@@ -28,10 +28,10 @@ class BOTAN_DLL SHA_224 final : public MDx_HashFunction
SHA_224() : MDx_HashFunction(64, true, true), m_digest(8)
{ clear(); }
private:
- void compress_n(const byte[], size_t blocks) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
- secure_vector<u32bit> m_digest;
+ secure_vector<uint32_t> m_digest;
};
/**
@@ -49,10 +49,10 @@ class BOTAN_DLL SHA_256 final : public MDx_HashFunction
SHA_256() : MDx_HashFunction(64, true, true), m_digest(8)
{ clear(); }
private:
- void compress_n(const byte[], size_t blocks) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
- secure_vector<u32bit> m_digest;
+ secure_vector<uint32_t> m_digest;
};
}
diff --git a/src/lib/hash/sha2_64/sha2_64.cpp b/src/lib/hash/sha2_64/sha2_64.cpp
index d7c3f1325..59242ee9c 100644
--- a/src/lib/hash/sha2_64/sha2_64.cpp
+++ b/src/lib/hash/sha2_64/sha2_64.cpp
@@ -16,7 +16,7 @@ namespace SHA2_64 {
/*
* SHA-{384,512} Rho Function
*/
-inline u64bit rho(u64bit X, u32bit rot1, u32bit rot2, u32bit rot3)
+inline uint64_t rho(uint64_t X, uint32_t rot1, uint32_t rot2, uint32_t rot3)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^
rotate_right(X, rot3));
@@ -25,7 +25,7 @@ inline u64bit rho(u64bit X, u32bit rot1, u32bit rot2, u32bit rot3)
/*
* SHA-{384,512} Sigma Function
*/
-inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift)
+inline uint64_t sigma(uint64_t X, uint32_t rot1, uint32_t rot2, uint32_t shift)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift));
}
@@ -47,31 +47,31 @@ inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift)
/*
* SHA-{384,512} Compression Function
*/
-void compress(secure_vector<u64bit>& digest,
- const byte input[], size_t blocks)
+void compress(secure_vector<uint64_t>& digest,
+ const uint8_t input[], size_t blocks)
{
- u64bit A = digest[0], B = digest[1], C = digest[2],
+ uint64_t A = digest[0], B = digest[1], C = digest[2],
D = digest[3], E = digest[4], F = digest[5],
G = digest[6], H = digest[7];
for(size_t i = 0; i != blocks; ++i)
{
- u64bit W00 = load_be<u64bit>(input, 0);
- u64bit W01 = load_be<u64bit>(input, 1);
- u64bit W02 = load_be<u64bit>(input, 2);
- u64bit W03 = load_be<u64bit>(input, 3);
- u64bit W04 = load_be<u64bit>(input, 4);
- u64bit W05 = load_be<u64bit>(input, 5);
- u64bit W06 = load_be<u64bit>(input, 6);
- u64bit W07 = load_be<u64bit>(input, 7);
- u64bit W08 = load_be<u64bit>(input, 8);
- u64bit W09 = load_be<u64bit>(input, 9);
- u64bit W10 = load_be<u64bit>(input, 10);
- u64bit W11 = load_be<u64bit>(input, 11);
- u64bit W12 = load_be<u64bit>(input, 12);
- u64bit W13 = load_be<u64bit>(input, 13);
- u64bit W14 = load_be<u64bit>(input, 14);
- u64bit W15 = load_be<u64bit>(input, 15);
+ uint64_t W00 = load_be<uint64_t>(input, 0);
+ uint64_t W01 = load_be<uint64_t>(input, 1);
+ uint64_t W02 = load_be<uint64_t>(input, 2);
+ uint64_t W03 = load_be<uint64_t>(input, 3);
+ uint64_t W04 = load_be<uint64_t>(input, 4);
+ uint64_t W05 = load_be<uint64_t>(input, 5);
+ uint64_t W06 = load_be<uint64_t>(input, 6);
+ uint64_t W07 = load_be<uint64_t>(input, 7);
+ uint64_t W08 = load_be<uint64_t>(input, 8);
+ uint64_t W09 = load_be<uint64_t>(input, 9);
+ uint64_t W10 = load_be<uint64_t>(input, 10);
+ uint64_t W11 = load_be<uint64_t>(input, 11);
+ uint64_t W12 = load_be<uint64_t>(input, 12);
+ uint64_t W13 = load_be<uint64_t>(input, 13);
+ uint64_t W14 = load_be<uint64_t>(input, 14);
+ uint64_t W15 = load_be<uint64_t>(input, 15);
SHA2_64_F(A, B, C, D, E, F, G, H, W00, W14, W09, W01, 0x428A2F98D728AE22);
SHA2_64_F(H, A, B, C, D, E, F, G, W01, W15, W10, W02, 0x7137449123EF65CD);
@@ -171,32 +171,32 @@ void compress(secure_vector<u64bit>& digest,
}
-void SHA_512_256::compress_n(const byte input[], size_t blocks)
+void SHA_512_256::compress_n(const uint8_t input[], size_t blocks)
{
SHA2_64::compress(m_digest, input, blocks);
}
-void SHA_384::compress_n(const byte input[], size_t blocks)
+void SHA_384::compress_n(const uint8_t input[], size_t blocks)
{
SHA2_64::compress(m_digest, input, blocks);
}
-void SHA_512::compress_n(const byte input[], size_t blocks)
+void SHA_512::compress_n(const uint8_t input[], size_t blocks)
{
SHA2_64::compress(m_digest, input, blocks);
}
-void SHA_512_256::copy_out(byte output[])
+void SHA_512_256::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
-void SHA_384::copy_out(byte output[])
+void SHA_384::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
-void SHA_512::copy_out(byte output[])
+void SHA_512::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
diff --git a/src/lib/hash/sha2_64/sha2_64.h b/src/lib/hash/sha2_64/sha2_64.h
index a38f12dae..51bdb2b77 100644
--- a/src/lib/hash/sha2_64/sha2_64.h
+++ b/src/lib/hash/sha2_64/sha2_64.h
@@ -27,10 +27,10 @@ class BOTAN_DLL SHA_384 final : public MDx_HashFunction
SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8)
{ clear(); }
private:
- void compress_n(const byte[], size_t blocks) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
- secure_vector<u64bit> m_digest;
+ secure_vector<uint64_t> m_digest;
};
/**
@@ -48,10 +48,10 @@ class BOTAN_DLL SHA_512 final : public MDx_HashFunction
SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8)
{ clear(); }
private:
- void compress_n(const byte[], size_t blocks) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
- secure_vector<u64bit> m_digest;
+ secure_vector<uint64_t> m_digest;
};
/**
@@ -68,10 +68,10 @@ class BOTAN_DLL SHA_512_256 final : public MDx_HashFunction
SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
private:
- void compress_n(const byte[], size_t blocks) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
- secure_vector<u64bit> m_digest;
+ secure_vector<uint64_t> m_digest;
};
}
diff --git a/src/lib/hash/sha3/sha3.cpp b/src/lib/hash/sha3/sha3.cpp
index 2361d7d5b..f1c769e6b 100644
--- a/src/lib/hash/sha3/sha3.cpp
+++ b/src/lib/hash/sha3/sha3.cpp
@@ -12,9 +12,9 @@
namespace Botan {
//static
-void SHA_3::permute(u64bit A[25])
+void SHA_3::permute(uint64_t A[25])
{
- static const u64bit RC[24] = {
+ static const uint64_t RC[24] = {
0x0000000000000001, 0x0000000000008082, 0x800000000000808A,
0x8000000080008000, 0x000000000000808B, 0x0000000080000001,
0x8000000080008081, 0x8000000000008009, 0x000000000000008A,
@@ -27,43 +27,43 @@ void SHA_3::permute(u64bit A[25])
for(size_t i = 0; i != 24; ++i)
{
- const u64bit C0 = A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20];
- const u64bit C1 = A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21];
- const u64bit C2 = A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22];
- const u64bit C3 = A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23];
- const u64bit C4 = A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24];
-
- const u64bit D0 = rotate_left(C0, 1) ^ C3;
- const u64bit D1 = rotate_left(C1, 1) ^ C4;
- const u64bit D2 = rotate_left(C2, 1) ^ C0;
- const u64bit D3 = rotate_left(C3, 1) ^ C1;
- const u64bit D4 = rotate_left(C4, 1) ^ C2;
-
- const u64bit B00 = A[ 0] ^ D1;
- const u64bit B10 = rotate_left(A[ 1] ^ D2, 1);
- const u64bit B20 = rotate_left(A[ 2] ^ D3, 62);
- const u64bit B05 = rotate_left(A[ 3] ^ D4, 28);
- const u64bit B15 = rotate_left(A[ 4] ^ D0, 27);
- const u64bit B16 = rotate_left(A[ 5] ^ D1, 36);
- const u64bit B01 = rotate_left(A[ 6] ^ D2, 44);
- const u64bit B11 = rotate_left(A[ 7] ^ D3, 6);
- const u64bit B21 = rotate_left(A[ 8] ^ D4, 55);
- const u64bit B06 = rotate_left(A[ 9] ^ D0, 20);
- const u64bit B07 = rotate_left(A[10] ^ D1, 3);
- const u64bit B17 = rotate_left(A[11] ^ D2, 10);
- const u64bit B02 = rotate_left(A[12] ^ D3, 43);
- const u64bit B12 = rotate_left(A[13] ^ D4, 25);
- const u64bit B22 = rotate_left(A[14] ^ D0, 39);
- const u64bit B23 = rotate_left(A[15] ^ D1, 41);
- const u64bit B08 = rotate_left(A[16] ^ D2, 45);
- const u64bit B18 = rotate_left(A[17] ^ D3, 15);
- const u64bit B03 = rotate_left(A[18] ^ D4, 21);
- const u64bit B13 = rotate_left(A[19] ^ D0, 8);
- const u64bit B14 = rotate_left(A[20] ^ D1, 18);
- const u64bit B24 = rotate_left(A[21] ^ D2, 2);
- const u64bit B09 = rotate_left(A[22] ^ D3, 61);
- const u64bit B19 = rotate_left(A[23] ^ D4, 56);
- const u64bit B04 = rotate_left(A[24] ^ D0, 14);
+ const uint64_t C0 = A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20];
+ const uint64_t C1 = A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21];
+ const uint64_t C2 = A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22];
+ const uint64_t C3 = A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23];
+ const uint64_t C4 = A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24];
+
+ const uint64_t D0 = rotate_left(C0, 1) ^ C3;
+ const uint64_t D1 = rotate_left(C1, 1) ^ C4;
+ const uint64_t D2 = rotate_left(C2, 1) ^ C0;
+ const uint64_t D3 = rotate_left(C3, 1) ^ C1;
+ const uint64_t D4 = rotate_left(C4, 1) ^ C2;
+
+ const uint64_t B00 = A[ 0] ^ D1;
+ const uint64_t B10 = rotate_left(A[ 1] ^ D2, 1);
+ const uint64_t B20 = rotate_left(A[ 2] ^ D3, 62);
+ const uint64_t B05 = rotate_left(A[ 3] ^ D4, 28);
+ const uint64_t B15 = rotate_left(A[ 4] ^ D0, 27);
+ const uint64_t B16 = rotate_left(A[ 5] ^ D1, 36);
+ const uint64_t B01 = rotate_left(A[ 6] ^ D2, 44);
+ const uint64_t B11 = rotate_left(A[ 7] ^ D3, 6);
+ const uint64_t B21 = rotate_left(A[ 8] ^ D4, 55);
+ const uint64_t B06 = rotate_left(A[ 9] ^ D0, 20);
+ const uint64_t B07 = rotate_left(A[10] ^ D1, 3);
+ const uint64_t B17 = rotate_left(A[11] ^ D2, 10);
+ const uint64_t B02 = rotate_left(A[12] ^ D3, 43);
+ const uint64_t B12 = rotate_left(A[13] ^ D4, 25);
+ const uint64_t B22 = rotate_left(A[14] ^ D0, 39);
+ const uint64_t B23 = rotate_left(A[15] ^ D1, 41);
+ const uint64_t B08 = rotate_left(A[16] ^ D2, 45);
+ const uint64_t B18 = rotate_left(A[17] ^ D3, 15);
+ const uint64_t B03 = rotate_left(A[18] ^ D4, 21);
+ const uint64_t B13 = rotate_left(A[19] ^ D0, 8);
+ const uint64_t B14 = rotate_left(A[20] ^ D1, 18);
+ const uint64_t B24 = rotate_left(A[21] ^ D2, 2);
+ const uint64_t B09 = rotate_left(A[22] ^ D3, 61);
+ const uint64_t B19 = rotate_left(A[23] ^ D4, 56);
+ const uint64_t B04 = rotate_left(A[24] ^ D0, 14);
A[ 0] = B00 ^ (~B01 & B02);
A[ 1] = B01 ^ (~B02 & B03);
@@ -128,7 +128,7 @@ void SHA_3::clear()
//static
size_t SHA_3::absorb(size_t bitrate,
secure_vector<uint64_t>& S, size_t S_pos,
- const byte input[], size_t length)
+ const uint8_t input[], size_t length)
{
while(length > 0)
{
@@ -138,7 +138,7 @@ size_t SHA_3::absorb(size_t bitrate,
while(to_take && S_pos % 8)
{
- S[S_pos / 8] ^= static_cast<u64bit>(input[0]) << (8 * (S_pos % 8));
+ S[S_pos / 8] ^= static_cast<uint64_t>(input[0]) << (8 * (S_pos % 8));
++S_pos;
++input;
@@ -147,7 +147,7 @@ size_t SHA_3::absorb(size_t bitrate,
while(to_take && to_take % 8 == 0)
{
- S[S_pos / 8] ^= load_le<u64bit>(input, 0);
+ S[S_pos / 8] ^= load_le<uint64_t>(input, 0);
S_pos += 8;
input += 8;
to_take -= 8;
@@ -155,7 +155,7 @@ size_t SHA_3::absorb(size_t bitrate,
while(to_take)
{
- S[S_pos / 8] ^= static_cast<u64bit>(input[0]) << (8 * (S_pos % 8));
+ S[S_pos / 8] ^= static_cast<uint64_t>(input[0]) << (8 * (S_pos % 8));
++S_pos;
++input;
@@ -175,7 +175,7 @@ size_t SHA_3::absorb(size_t bitrate,
//static
void SHA_3::expand(size_t bitrate,
secure_vector<uint64_t>& S,
- byte output[], size_t output_length)
+ uint8_t output[], size_t output_length)
{
BOTAN_ARG_CHECK(bitrate % 8 == 0);
@@ -200,14 +200,14 @@ void SHA_3::expand(size_t bitrate,
}
}
-void SHA_3::add_data(const byte input[], size_t length)
+void SHA_3::add_data(const uint8_t input[], size_t length)
{
m_S_pos = SHA_3::absorb(m_bitrate, m_S, m_S_pos, input, length);
}
-void SHA_3::final_result(byte output[])
+void SHA_3::final_result(uint8_t output[])
{
- std::vector<byte> padding(m_bitrate / 8 - m_S_pos);
+ std::vector<uint8_t> padding(m_bitrate / 8 - m_S_pos);
padding[0] = 0x06;
padding[padding.size()-1] |= 0x80;
diff --git a/src/lib/hash/sha3/sha3.h b/src/lib/hash/sha3/sha3.h
index 649aa12fd..e7905b5c4 100644
--- a/src/lib/hash/sha3/sha3.h
+++ b/src/lib/hash/sha3/sha3.h
@@ -46,7 +46,7 @@ class BOTAN_DLL SHA_3 : public HashFunction
*/
static size_t absorb(size_t bitrate,
secure_vector<uint64_t>& S, size_t S_pos,
- const byte input[], size_t length);
+ const uint8_t input[], size_t length);
/**
* Expand from provided state
@@ -57,19 +57,19 @@ class BOTAN_DLL SHA_3 : public HashFunction
*/
static void expand(size_t bitrate,
secure_vector<uint64_t>& S,
- byte output[], size_t output_length);
+ uint8_t output[], size_t output_length);
/**
* The bare Keccak-1600 permutation
*/
- static void permute(u64bit A[25]);
+ static void permute(uint64_t A[25]);
private:
- void add_data(const byte input[], size_t length) override;
- void final_result(byte out[]) override;
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t out[]) override;
size_t m_output_bits, m_bitrate;
- secure_vector<u64bit> m_S;
+ secure_vector<uint64_t> m_S;
size_t m_S_pos;
};
diff --git a/src/lib/hash/shake/shake.cpp b/src/lib/hash/shake/shake.cpp
index 1ff6f1fd3..97ee0c4da 100644
--- a/src/lib/hash/shake/shake.cpp
+++ b/src/lib/hash/shake/shake.cpp
@@ -36,14 +36,14 @@ void SHAKE_128::clear()
m_S_pos = 0;
}
-void SHAKE_128::add_data(const byte input[], size_t length)
+void SHAKE_128::add_data(const uint8_t input[], size_t length)
{
m_S_pos = SHA_3::absorb(SHAKE_128_BITRATE, m_S, m_S_pos, input, length);
}
-void SHAKE_128::final_result(byte output[])
+void SHAKE_128::final_result(uint8_t output[])
{
- std::vector<byte> padding(SHAKE_128_BITRATE / 8 - m_S_pos);
+ std::vector<uint8_t> padding(SHAKE_128_BITRATE / 8 - m_S_pos);
padding[0] = 0x1F;
padding[padding.size()-1] |= 0x80;
@@ -79,14 +79,14 @@ void SHAKE_256::clear()
m_S_pos = 0;
}
-void SHAKE_256::add_data(const byte input[], size_t length)
+void SHAKE_256::add_data(const uint8_t input[], size_t length)
{
m_S_pos = SHA_3::absorb(SHAKE_256_BITRATE, m_S, m_S_pos, input, length);
}
-void SHAKE_256::final_result(byte output[])
+void SHAKE_256::final_result(uint8_t output[])
{
- std::vector<byte> padding(SHAKE_256_BITRATE / 8 - m_S_pos);
+ std::vector<uint8_t> padding(SHAKE_256_BITRATE / 8 - m_S_pos);
padding[0] = 0x1F;
padding[padding.size()-1] |= 0x80;
diff --git a/src/lib/hash/shake/shake.h b/src/lib/hash/shake/shake.h
index 96c171323..f24fda4fa 100644
--- a/src/lib/hash/shake/shake.h
+++ b/src/lib/hash/shake/shake.h
@@ -35,13 +35,13 @@ class BOTAN_DLL SHAKE_128 : public HashFunction
void clear() override;
private:
- void add_data(const byte input[], size_t length) override;
- void final_result(byte out[]) override;
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t out[]) override;
static const size_t SHAKE_128_BITRATE = 1600 - 256;
size_t m_output_bits;
- secure_vector<u64bit> m_S;
+ secure_vector<uint64_t> m_S;
size_t m_S_pos;
};
@@ -66,13 +66,13 @@ class BOTAN_DLL SHAKE_256 : public HashFunction
void clear() override;
private:
- void add_data(const byte input[], size_t length) override;
- void final_result(byte out[]) override;
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t out[]) override;
static const size_t SHAKE_256_BITRATE = 1600 - 512;
size_t m_output_bits;
- secure_vector<u64bit> m_S;
+ secure_vector<uint64_t> m_S;
size_t m_S_pos;
};
diff --git a/src/lib/hash/skein/skein_512.cpp b/src/lib/hash/skein/skein_512.cpp
index 21eeb1f27..ae059f085 100644
--- a/src/lib/hash/skein/skein_512.cpp
+++ b/src/lib/hash/skein/skein_512.cpp
@@ -50,20 +50,20 @@ void Skein_512::reset_tweak(type_code type, bool is_final)
{
m_T[0] = 0;
- m_T[1] = (static_cast<u64bit>(type) << 56) |
- (static_cast<u64bit>(1) << 62) |
- (static_cast<u64bit>(is_final) << 63);
+ m_T[1] = (static_cast<uint64_t>(type) << 56) |
+ (static_cast<uint64_t>(1) << 62) |
+ (static_cast<uint64_t>(is_final) << 63);
}
void Skein_512::initial_block()
{
- const byte zeros[64] = { 0 };
+ const uint8_t zeros[64] = { 0 };
m_threefish->set_key(zeros, sizeof(zeros));
// ASCII("SHA3") followed by version (0x0001) code
- byte config_str[32] = { 0x53, 0x48, 0x41, 0x33, 0x01, 0x00, 0 };
- store_le(u32bit(m_output_bits), config_str + 8);
+ uint8_t config_str[32] = { 0x53, 0x48, 0x41, 0x33, 0x01, 0x00, 0 };
+ store_le(uint32_t(m_output_bits), config_str + 8);
reset_tweak(SKEIN_CONFIG, true);
ubi_512(config_str, sizeof(config_str));
@@ -78,7 +78,7 @@ void Skein_512::initial_block()
if(m_personalization.length() > 64)
throw Invalid_Argument("Skein personalization must be less than 64 bytes");
- const byte* bits = reinterpret_cast<const byte*>(m_personalization.data());
+ const uint8_t* bits = reinterpret_cast<const uint8_t*>(m_personalization.data());
reset_tweak(SKEIN_PERSONALIZATION, true);
ubi_512(bits, m_personalization.length());
}
@@ -86,9 +86,9 @@ void Skein_512::initial_block()
reset_tweak(SKEIN_MSG, false);
}
-void Skein_512::ubi_512(const byte msg[], size_t msg_len)
+void Skein_512::ubi_512(const uint8_t msg[], size_t msg_len)
{
- secure_vector<u64bit> M(8);
+ secure_vector<uint64_t> M(8);
do
{
@@ -100,20 +100,20 @@ void Skein_512::ubi_512(const byte msg[], size_t msg_len)
if(to_proc % 8)
{
for(size_t j = 0; j != to_proc % 8; ++j)
- M[to_proc/8] |= static_cast<u64bit>(msg[8*(to_proc/8)+j]) << (8*j);
+ M[to_proc/8] |= static_cast<uint64_t>(msg[8*(to_proc/8)+j]) << (8*j);
}
m_threefish->skein_feedfwd(M, m_T);
// clear first flag if set
- m_T[1] &= ~(static_cast<u64bit>(1) << 62);
+ m_T[1] &= ~(static_cast<uint64_t>(1) << 62);
msg_len -= to_proc;
msg += to_proc;
} while(msg_len);
}
-void Skein_512::add_data(const byte input[], size_t length)
+void Skein_512::add_data(const uint8_t input[], size_t length)
{
if(length == 0)
return;
@@ -142,16 +142,16 @@ void Skein_512::add_data(const byte input[], size_t length)
m_buf_pos += length;
}
-void Skein_512::final_result(byte out[])
+void Skein_512::final_result(uint8_t out[])
{
- m_T[1] |= (static_cast<u64bit>(1) << 63); // final block flag
+ m_T[1] |= (static_cast<uint64_t>(1) << 63); // final block flag
for(size_t i = m_buf_pos; i != m_buffer.size(); ++i)
m_buffer[i] = 0;
ubi_512(m_buffer.data(), m_buf_pos);
- const byte counter[8] = { 0 };
+ const uint8_t counter[8] = { 0 };
reset_tweak(SKEIN_OUTPUT, true);
ubi_512(counter, sizeof(counter));
diff --git a/src/lib/hash/skein/skein_512.h b/src/lib/hash/skein/skein_512.h
index 1f34f1583..32323807e 100644
--- a/src/lib/hash/skein/skein_512.h
+++ b/src/lib/hash/skein/skein_512.h
@@ -47,10 +47,10 @@ class BOTAN_DLL Skein_512 final : public HashFunction
SKEIN_OUTPUT = 63
};
- void add_data(const byte input[], size_t length) override;
- void final_result(byte out[]) override;
+ void add_data(const uint8_t input[], size_t length) override;
+ void final_result(uint8_t out[]) override;
- void ubi_512(const byte msg[], size_t msg_len);
+ void ubi_512(const uint8_t msg[], size_t msg_len);
void initial_block();
void reset_tweak(type_code type, bool is_final);
@@ -59,8 +59,8 @@ class BOTAN_DLL Skein_512 final : public HashFunction
size_t m_output_bits;
std::unique_ptr<Threefish_512> m_threefish;
- secure_vector<u64bit> m_T;
- secure_vector<byte> m_buffer;
+ secure_vector<uint64_t> m_T;
+ secure_vector<uint8_t> m_buffer;
size_t m_buf_pos;
};
diff --git a/src/lib/hash/tiger/tig_tab.cpp b/src/lib/hash/tiger/tig_tab.cpp
index 4d0bea5ee..3d1dc1eeb 100644
--- a/src/lib/hash/tiger/tig_tab.cpp
+++ b/src/lib/hash/tiger/tig_tab.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-const u64bit Tiger::SBOX1[256] = {
+const uint64_t Tiger::SBOX1[256] = {
0x02AAB17CF7E90C5E, 0xAC424B03E243A8EC, 0x72CD5BE30DD5FCD3,
0x6D019B93F6F97F3A, 0xCD9978FFD21F9193, 0x7573A1C9708029E2,
0xB164326B922A83C3, 0x46883EEE04915870, 0xEAACE3057103ECE6,
@@ -97,7 +97,7 @@ const u64bit Tiger::SBOX1[256] = {
0xFFED95D8F1EA02A2, 0xE72B3BD61464D43D, 0xA6300F170BDC4820,
0xEBC18760ED78A77A };
-const u64bit Tiger::SBOX2[256] = {
+const uint64_t Tiger::SBOX2[256] = {
0xE6A6BE5A05A12138, 0xB5A122A5B4F87C98, 0x563C6089140B6990,
0x4C46CB2E391F5DD5, 0xD932ADDBC9B79434, 0x08EA70E42015AFF5,
0xD765A6673E478CF1, 0xC4FB757EAB278D99, 0xDF11C6862D6E0692,
@@ -185,7 +185,7 @@ const u64bit Tiger::SBOX2[256] = {
0x9010A91E84711AE9, 0x4DF7F0B7B1498371, 0xD62A2EABC0977179,
0x22FAC097AA8D5C0E };
-const u64bit Tiger::SBOX3[256] = {
+const uint64_t Tiger::SBOX3[256] = {
0xF49FCC2FF1DAF39B, 0x487FD5C66FF29281, 0xE8A30667FCDCA83F,
0x2C9B4BE3D2FCCE63, 0xDA3FF74B93FBBBC2, 0x2FA165D2FE70BA66,
0xA103E279970E93D4, 0xBECDEC77B0E45E71, 0xCFB41E723985E497,
@@ -273,7 +273,7 @@ const u64bit Tiger::SBOX3[256] = {
0x454C6FE9F2C0C1CD, 0x419CF6496412691C, 0xD3DC3BEF265B0F70,
0x6D0E60F5C3578A9E };
-const u64bit Tiger::SBOX4[256] = {
+const uint64_t Tiger::SBOX4[256] = {
0x5B0E608526323C55, 0x1A46C1A9FA1B59F5, 0xA9E245A17C4C8FFA,
0x65CA5159DB2955D7, 0x05DB0A76CE35AFC2, 0x81EAC77EA9113D45,
0x528EF88AB6AC0A0D, 0xA09EA253597BE3FF, 0x430DDFB3AC48CD56,
diff --git a/src/lib/hash/tiger/tiger.cpp b/src/lib/hash/tiger/tiger.cpp
index 1da38291c..b09e03d2e 100644
--- a/src/lib/hash/tiger/tiger.cpp
+++ b/src/lib/hash/tiger/tiger.cpp
@@ -16,7 +16,7 @@ namespace {
/*
* Tiger Mixing Function
*/
-inline void mix(secure_vector<u64bit>& X)
+inline void mix(secure_vector<uint64_t>& X)
{
X[0] -= X[7] ^ 0xA5A5A5A5A5A5A5A5;
X[1] ^= X[0];
@@ -42,9 +42,9 @@ inline void mix(secure_vector<u64bit>& X)
/*
* Tiger Compression Function
*/
-void Tiger::compress_n(const byte input[], size_t blocks)
+void Tiger::compress_n(const uint8_t input[], size_t blocks)
{
- u64bit A = m_digest[0], B = m_digest[1], C = m_digest[2];
+ uint64_t A = m_digest[0], B = m_digest[1], C = m_digest[2];
for(size_t i = 0; i != blocks; ++i)
{
@@ -58,7 +58,7 @@ void Tiger::compress_n(const byte input[], size_t blocks)
{
mix(m_X);
pass(A, B, C, m_X, 9);
- u64bit T = A; A = C; C = B; B = T;
+ uint64_t T = A; A = C; C = B; B = T;
}
A = (m_digest[0] ^= A);
@@ -72,7 +72,7 @@ void Tiger::compress_n(const byte input[], size_t blocks)
/*
* Copy out the digest
*/
-void Tiger::copy_out(byte output[])
+void Tiger::copy_out(uint8_t output[])
{
copy_out_vec_le(output, output_length(), m_digest);
}
@@ -80,9 +80,9 @@ void Tiger::copy_out(byte output[])
/*
* Tiger Pass
*/
-void Tiger::pass(u64bit& A, u64bit& B, u64bit& C,
- const secure_vector<u64bit>& X,
- byte mul)
+void Tiger::pass(uint64_t& A, uint64_t& B, uint64_t& C,
+ const secure_vector<uint64_t>& X,
+ uint8_t mul)
{
C ^= X[0];
A -= SBOX1[get_byte(7, C)] ^ SBOX2[get_byte(5, C)] ^
diff --git a/src/lib/hash/tiger/tiger.h b/src/lib/hash/tiger/tiger.h
index fb0524d44..32ae26258 100644
--- a/src/lib/hash/tiger/tiger.h
+++ b/src/lib/hash/tiger/tiger.h
@@ -34,19 +34,19 @@ class BOTAN_DLL Tiger final : public MDx_HashFunction
*/
Tiger(size_t out_size = 24, size_t passes = 3);
private:
- void compress_n(const byte[], size_t block) override;
- void copy_out(byte[]) override;
+ void compress_n(const uint8_t[], size_t block) override;
+ void copy_out(uint8_t[]) override;
- static void pass(u64bit& A, u64bit& B, u64bit& C,
- const secure_vector<u64bit>& M,
- byte mul);
+ static void pass(uint64_t& A, uint64_t& B, uint64_t& C,
+ const secure_vector<uint64_t>& M,
+ uint8_t mul);
- static const u64bit SBOX1[256];
- static const u64bit SBOX2[256];
- static const u64bit SBOX3[256];
- static const u64bit SBOX4[256];
+ static const uint64_t SBOX1[256];
+ static const uint64_t SBOX2[256];
+ static const uint64_t SBOX3[256];
+ static const uint64_t SBOX4[256];
- secure_vector<u64bit> m_X, m_digest;
+ secure_vector<uint64_t> m_X, m_digest;
const size_t m_hash_len, m_passes;
};
diff --git a/src/lib/hash/whirlpool/whirlpool.cpp b/src/lib/hash/whirlpool/whirlpool.cpp
index 5bf4c5246..64350fd24 100644
--- a/src/lib/hash/whirlpool/whirlpool.cpp
+++ b/src/lib/hash/whirlpool/whirlpool.cpp
@@ -12,9 +12,9 @@ namespace Botan {
/*
* Whirlpool Compression Function
*/
-void Whirlpool::compress_n(const byte in[], size_t blocks)
+void Whirlpool::compress_n(const uint8_t in[], size_t blocks)
{
- static const u64bit RC[10] = {
+ static const uint64_t RC[10] = {
0x1823C6E887B8014F, 0x36A6D2F5796F9152,
0x60BC9B8EA30C7B35, 0x1DE0D7C22E4BFE57,
0x157737E59FF04ADA, 0x58C9290AB1A06B85,
@@ -26,17 +26,17 @@ void Whirlpool::compress_n(const byte in[], size_t blocks)
{
load_be(m_M.data(), in, m_M.size());
- u64bit K0, K1, K2, K3, K4, K5, K6, K7;
+ uint64_t K0, K1, K2, K3, K4, K5, K6, K7;
K0 = m_digest[0]; K1 = m_digest[1]; K2 = m_digest[2]; K3 = m_digest[3];
K4 = m_digest[4]; K5 = m_digest[5]; K6 = m_digest[6]; K7 = m_digest[7];
- u64bit B0, B1, B2, B3, B4, B5, B6, B7;
+ uint64_t B0, B1, B2, B3, B4, B5, B6, B7;
B0 = K0 ^ m_M[0]; B1 = K1 ^ m_M[1]; B2 = K2 ^ m_M[2]; B3 = K3 ^ m_M[3];
B4 = K4 ^ m_M[4]; B5 = K5 ^ m_M[5]; B6 = K6 ^ m_M[6]; B7 = K7 ^ m_M[7];
for(size_t j = 0; j != 10; ++j)
{
- u64bit T0, T1, T2, T3, T4, T5, T6, T7;
+ uint64_t T0, T1, T2, T3, T4, T5, T6, T7;
T0 = C0[get_byte(0, K0)] ^ C1[get_byte(1, K7)] ^
C2[get_byte(2, K6)] ^ C3[get_byte(3, K5)] ^
C4[get_byte(4, K4)] ^ C5[get_byte(5, K3)] ^
@@ -126,7 +126,7 @@ void Whirlpool::compress_n(const byte in[], size_t blocks)
/*
* Copy out the digest
*/
-void Whirlpool::copy_out(byte output[])
+void Whirlpool::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
diff --git a/src/lib/hash/whirlpool/whrl_tab.cpp b/src/lib/hash/whirlpool/whrl_tab.cpp
index 7289a0560..460425cee 100644
--- a/src/lib/hash/whirlpool/whrl_tab.cpp
+++ b/src/lib/hash/whirlpool/whrl_tab.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-const u64bit Whirlpool::C0[256] = {
+const uint64_t Whirlpool::C0[256] = {
0x18186018C07830D8, 0x23238C2305AF4626, 0xC6C63FC67EF991B8, 0xE8E887E8136FCDFB,
0x878726874CA113CB, 0xB8B8DAB8A9626D11, 0x0101040108050209, 0x4F4F214F426E9E0D,
0x3636D836ADEE6C9B, 0xA6A6A2A6590451FF, 0xD2D26FD2DEBDB90C, 0xF5F5F3F5FB06F70E,
@@ -75,7 +75,7 @@ const u64bit Whirlpool::C0[256] = {
0xCCCC17CC2EDB85E2, 0x424215422A578468, 0x98985A98B4C22D2C, 0xA4A4AAA4490E55ED,
0x2828A0285D885075, 0x5C5C6D5CDA31B886, 0xF8F8C7F8933FED6B, 0x8686228644A411C2 };
-const u64bit Whirlpool::C1[256] = {
+const uint64_t Whirlpool::C1[256] = {
0xD818186018C07830, 0x2623238C2305AF46, 0xB8C6C63FC67EF991, 0xFBE8E887E8136FCD,
0xCB878726874CA113, 0x11B8B8DAB8A9626D, 0x0901010401080502, 0x0D4F4F214F426E9E,
0x9B3636D836ADEE6C, 0xFFA6A6A2A6590451, 0x0CD2D26FD2DEBDB9, 0x0EF5F5F3F5FB06F7,
@@ -141,7 +141,7 @@ const u64bit Whirlpool::C1[256] = {
0xE2CCCC17CC2EDB85, 0x68424215422A5784, 0x2C98985A98B4C22D, 0xEDA4A4AAA4490E55,
0x752828A0285D8850, 0x865C5C6D5CDA31B8, 0x6BF8F8C7F8933FED, 0xC28686228644A411 };
-const u64bit Whirlpool::C2[256] = {
+const uint64_t Whirlpool::C2[256] = {
0x30D818186018C078, 0x462623238C2305AF, 0x91B8C6C63FC67EF9, 0xCDFBE8E887E8136F,
0x13CB878726874CA1, 0x6D11B8B8DAB8A962, 0x0209010104010805, 0x9E0D4F4F214F426E,
0x6C9B3636D836ADEE, 0x51FFA6A6A2A65904, 0xB90CD2D26FD2DEBD, 0xF70EF5F5F3F5FB06,
@@ -207,7 +207,7 @@ const u64bit Whirlpool::C2[256] = {
0x85E2CCCC17CC2EDB, 0x8468424215422A57, 0x2D2C98985A98B4C2, 0x55EDA4A4AAA4490E,
0x50752828A0285D88, 0xB8865C5C6D5CDA31, 0xED6BF8F8C7F8933F, 0x11C28686228644A4 };
-const u64bit Whirlpool::C3[256] = {
+const uint64_t Whirlpool::C3[256] = {
0x7830D818186018C0, 0xAF462623238C2305, 0xF991B8C6C63FC67E, 0x6FCDFBE8E887E813,
0xA113CB878726874C, 0x626D11B8B8DAB8A9, 0x0502090101040108, 0x6E9E0D4F4F214F42,
0xEE6C9B3636D836AD, 0x0451FFA6A6A2A659, 0xBDB90CD2D26FD2DE, 0x06F70EF5F5F3F5FB,
@@ -273,7 +273,7 @@ const u64bit Whirlpool::C3[256] = {
0xDB85E2CCCC17CC2E, 0x578468424215422A, 0xC22D2C98985A98B4, 0x0E55EDA4A4AAA449,
0x8850752828A0285D, 0x31B8865C5C6D5CDA, 0x3FED6BF8F8C7F893, 0xA411C28686228644 };
-const u64bit Whirlpool::C4[256] = {
+const uint64_t Whirlpool::C4[256] = {
0xC07830D818186018, 0x05AF462623238C23, 0x7EF991B8C6C63FC6, 0x136FCDFBE8E887E8,
0x4CA113CB87872687, 0xA9626D11B8B8DAB8, 0x0805020901010401, 0x426E9E0D4F4F214F,
0xADEE6C9B3636D836, 0x590451FFA6A6A2A6, 0xDEBDB90CD2D26FD2, 0xFB06F70EF5F5F3F5,
@@ -339,7 +339,7 @@ const u64bit Whirlpool::C4[256] = {
0x2EDB85E2CCCC17CC, 0x2A57846842421542, 0xB4C22D2C98985A98, 0x490E55EDA4A4AAA4,
0x5D8850752828A028, 0xDA31B8865C5C6D5C, 0x933FED6BF8F8C7F8, 0x44A411C286862286 };
-const u64bit Whirlpool::C5[256] = {
+const uint64_t Whirlpool::C5[256] = {
0x18C07830D8181860, 0x2305AF462623238C, 0xC67EF991B8C6C63F, 0xE8136FCDFBE8E887,
0x874CA113CB878726, 0xB8A9626D11B8B8DA, 0x0108050209010104, 0x4F426E9E0D4F4F21,
0x36ADEE6C9B3636D8, 0xA6590451FFA6A6A2, 0xD2DEBDB90CD2D26F, 0xF5FB06F70EF5F5F3,
@@ -405,7 +405,7 @@ const u64bit Whirlpool::C5[256] = {
0xCC2EDB85E2CCCC17, 0x422A578468424215, 0x98B4C22D2C98985A, 0xA4490E55EDA4A4AA,
0x285D8850752828A0, 0x5CDA31B8865C5C6D, 0xF8933FED6BF8F8C7, 0x8644A411C2868622 };
-const u64bit Whirlpool::C6[256] = {
+const uint64_t Whirlpool::C6[256] = {
0x6018C07830D81818, 0x8C2305AF46262323, 0x3FC67EF991B8C6C6, 0x87E8136FCDFBE8E8,
0x26874CA113CB8787, 0xDAB8A9626D11B8B8, 0x0401080502090101, 0x214F426E9E0D4F4F,
0xD836ADEE6C9B3636, 0xA2A6590451FFA6A6, 0x6FD2DEBDB90CD2D2, 0xF3F5FB06F70EF5F5,
@@ -471,7 +471,7 @@ const u64bit Whirlpool::C6[256] = {
0x17CC2EDB85E2CCCC, 0x15422A5784684242, 0x5A98B4C22D2C9898, 0xAAA4490E55EDA4A4,
0xA0285D8850752828, 0x6D5CDA31B8865C5C, 0xC7F8933FED6BF8F8, 0x228644A411C28686 };
-const u64bit Whirlpool::C7[256] = {
+const uint64_t Whirlpool::C7[256] = {
0x186018C07830D818, 0x238C2305AF462623, 0xC63FC67EF991B8C6, 0xE887E8136FCDFBE8,
0x8726874CA113CB87, 0xB8DAB8A9626D11B8, 0x0104010805020901, 0x4F214F426E9E0D4F,
0x36D836ADEE6C9B36, 0xA6A2A6590451FFA6, 0xD26FD2DEBDB90CD2, 0xF5F3F5FB06F70EF5,
diff --git a/src/lib/hash/whirlpool/whrlpool.h b/src/lib/hash/whirlpool/whrlpool.h
index d7db1de28..606fc3257 100644
--- a/src/lib/hash/whirlpool/whrlpool.h
+++ b/src/lib/hash/whirlpool/whrlpool.h
@@ -27,19 +27,19 @@ class BOTAN_DLL Whirlpool final : public MDx_HashFunction
Whirlpool() : MDx_HashFunction(64, true, true, 32), m_M(8), m_digest(8)
{ clear(); }
private:
- void compress_n(const byte[], size_t blocks) override;
- void copy_out(byte[]) override;
-
- static const u64bit C0[256];
- static const u64bit C1[256];
- static const u64bit C2[256];
- static const u64bit C3[256];
- static const u64bit C4[256];
- static const u64bit C5[256];
- static const u64bit C6[256];
- static const u64bit C7[256];
-
- secure_vector<u64bit> m_M, m_digest;
+ void compress_n(const uint8_t[], size_t blocks) override;
+ void copy_out(uint8_t[]) override;
+
+ static const uint64_t C0[256];
+ static const uint64_t C1[256];
+ static const uint64_t C2[256];
+ static const uint64_t C3[256];
+ static const uint64_t C4[256];
+ static const uint64_t C5[256];
+ static const uint64_t C6[256];
+ static const uint64_t C7[256];
+
+ secure_vector<uint64_t> m_M, m_digest;
};
}
diff --git a/src/lib/kdf/hkdf/hkdf.cpp b/src/lib/kdf/hkdf/hkdf.cpp
index f44ed81bd..20215125b 100644
--- a/src/lib/kdf/hkdf/hkdf.cpp
+++ b/src/lib/kdf/hkdf/hkdf.cpp
@@ -10,28 +10,28 @@
namespace Botan {
-size_t HKDF::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t HKDF::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
HKDF_Extract extract(m_prf->clone());
HKDF_Expand expand(m_prf->clone());
- secure_vector<byte> prk(m_prf->output_length());
+ secure_vector<uint8_t> prk(m_prf->output_length());
extract.kdf(prk.data(), prk.size(), secret, secret_len, salt, salt_len, nullptr, 0);
return expand.kdf(key, key_len, prk.data(), prk.size(), nullptr, 0, label, label_len);
}
-size_t HKDF_Extract::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte[], size_t) const
+size_t HKDF_Extract::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t[], size_t) const
{
- secure_vector<byte> prk;
+ secure_vector<uint8_t> prk;
if(salt_len == 0)
{
- m_prf->set_key(std::vector<byte>(m_prf->output_length()));
+ m_prf->set_key(std::vector<uint8_t>(m_prf->output_length()));
}
else
{
@@ -46,15 +46,15 @@ size_t HKDF_Extract::kdf(byte key[], size_t key_len,
return written;
}
-size_t HKDF_Expand::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t HKDF_Expand::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
m_prf->set_key(secret, secret_len);
- byte counter = 1;
- secure_vector<byte> h;
+ uint8_t counter = 1;
+ secure_vector<uint8_t> h;
size_t offset = 0;
while(offset != key_len && counter != 0)
diff --git a/src/lib/kdf/hkdf/hkdf.h b/src/lib/kdf/hkdf/hkdf.h
index 5ad389aeb..7a07f94e1 100644
--- a/src/lib/kdf/hkdf/hkdf.h
+++ b/src/lib/kdf/hkdf/hkdf.h
@@ -30,10 +30,10 @@ class BOTAN_DLL HKDF final : public KDF
std::string name() const override { return "HKDF(" + m_prf->name() + ")"; }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
private:
std::unique_ptr<MessageAuthenticationCode> m_prf;
@@ -54,10 +54,10 @@ class BOTAN_DLL HKDF_Extract final : public KDF
std::string name() const override { return "HKDF-Extract(" + m_prf->name() + ")"; }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
private:
std::unique_ptr<MessageAuthenticationCode> m_prf;
@@ -78,10 +78,10 @@ class BOTAN_DLL HKDF_Expand final : public KDF
std::string name() const override { return "HKDF-Expand(" + m_prf->name() + ")"; }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
private:
std::unique_ptr<MessageAuthenticationCode> m_prf;
diff --git a/src/lib/kdf/kdf.h b/src/lib/kdf/kdf.h
index 15336a966..8c188bfb4 100644
--- a/src/lib/kdf/kdf.h
+++ b/src/lib/kdf/kdf.h
@@ -64,10 +64,10 @@ class BOTAN_DLL KDF
* @param label_len size of label in bytes
* @return the derived key
*/
- virtual size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const = 0;
+ virtual size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const = 0;
/**
* Derive a key
@@ -80,15 +80,15 @@ class BOTAN_DLL KDF
* @param label_len size of label in bytes
* @return the derived key
*/
- secure_vector<byte> derive_key(size_t key_len,
- const byte secret[],
+ secure_vector<uint8_t> derive_key(size_t key_len,
+ const uint8_t secret[],
size_t secret_len,
- const byte salt[],
+ const uint8_t salt[],
size_t salt_len,
- const byte label[] = nullptr,
+ const uint8_t label[] = nullptr,
size_t label_len = 0) const
{
- secure_vector<byte> key(key_len);
+ secure_vector<uint8_t> key(key_len);
key.resize(kdf(key.data(), key.size(), secret, secret_len, salt, salt_len, label, label_len));
return key;
}
@@ -101,15 +101,15 @@ class BOTAN_DLL KDF
* @param label purpose for the derived keying material
* @return the derived key
*/
- secure_vector<byte> derive_key(size_t key_len,
- const secure_vector<byte>& secret,
+ secure_vector<uint8_t> derive_key(size_t key_len,
+ const secure_vector<uint8_t>& secret,
const std::string& salt = "",
const std::string& label = "") const
{
return derive_key(key_len, secret.data(), secret.size(),
- reinterpret_cast<const byte*>(salt.data()),
+ reinterpret_cast<const uint8_t*>(salt.data()),
salt.length(),
- reinterpret_cast<const byte*>(label.data()),
+ reinterpret_cast<const uint8_t*>(label.data()),
label.length());
}
@@ -123,10 +123,10 @@ class BOTAN_DLL KDF
* @return the derived key
*/
template<typename Alloc, typename Alloc2, typename Alloc3>
- secure_vector<byte> derive_key(size_t key_len,
- const std::vector<byte, Alloc>& secret,
- const std::vector<byte, Alloc2>& salt,
- const std::vector<byte, Alloc3>& label) const
+ secure_vector<uint8_t> derive_key(size_t key_len,
+ const std::vector<uint8_t, Alloc>& secret,
+ const std::vector<uint8_t, Alloc2>& salt,
+ const std::vector<uint8_t, Alloc3>& label) const
{
return derive_key(key_len,
secret.data(), secret.size(),
@@ -143,16 +143,16 @@ class BOTAN_DLL KDF
* @param label purpose for the derived keying material
* @return the derived key
*/
- secure_vector<byte> derive_key(size_t key_len,
- const secure_vector<byte>& secret,
- const byte salt[],
+ secure_vector<uint8_t> derive_key(size_t key_len,
+ const secure_vector<uint8_t>& secret,
+ const uint8_t salt[],
size_t salt_len,
const std::string& label = "") const
{
return derive_key(key_len,
secret.data(), secret.size(),
salt, salt_len,
- reinterpret_cast<const byte*>(label.data()),
+ reinterpret_cast<const uint8_t*>(label.data()),
label.size());
}
@@ -165,16 +165,16 @@ class BOTAN_DLL KDF
* @param label purpose for the derived keying material
* @return the derived key
*/
- secure_vector<byte> derive_key(size_t key_len,
- const byte secret[],
+ secure_vector<uint8_t> derive_key(size_t key_len,
+ const uint8_t secret[],
size_t secret_len,
const std::string& salt = "",
const std::string& label = "") const
{
return derive_key(key_len, secret, secret_len,
- reinterpret_cast<const byte*>(salt.data()),
+ reinterpret_cast<const uint8_t*>(salt.data()),
salt.length(),
- reinterpret_cast<const byte*>(label.data()),
+ reinterpret_cast<const uint8_t*>(label.data()),
label.length());
}
diff --git a/src/lib/kdf/kdf1/kdf1.cpp b/src/lib/kdf/kdf1/kdf1.cpp
index 14dddc5f4..be22b1e9f 100644
--- a/src/lib/kdf/kdf1/kdf1.cpp
+++ b/src/lib/kdf/kdf1/kdf1.cpp
@@ -9,10 +9,10 @@
namespace Botan {
-size_t KDF1::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t KDF1::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
m_hash->update(secret, secret_len);
m_hash->update(label, label_len);
@@ -20,7 +20,7 @@ size_t KDF1::kdf(byte key[], size_t key_len,
if(key_len < m_hash->output_length())
{
- secure_vector<byte> v = m_hash->final();
+ secure_vector<uint8_t> v = m_hash->final();
copy_mem(key, v.data(), key_len);
return key_len;
}
diff --git a/src/lib/kdf/kdf1/kdf1.h b/src/lib/kdf/kdf1/kdf1.h
index db8b3b062..2dc9dbb33 100644
--- a/src/lib/kdf/kdf1/kdf1.h
+++ b/src/lib/kdf/kdf1/kdf1.h
@@ -23,10 +23,10 @@ class BOTAN_DLL KDF1 final : public KDF
KDF* clone() const override { return new KDF1(m_hash->clone()); }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
/**
* @param h hash function to use
diff --git a/src/lib/kdf/kdf1_iso18033/kdf1_iso18033.cpp b/src/lib/kdf/kdf1_iso18033/kdf1_iso18033.cpp
index 7beca0862..05565e404 100644
--- a/src/lib/kdf/kdf1_iso18033/kdf1_iso18033.cpp
+++ b/src/lib/kdf/kdf1_iso18033/kdf1_iso18033.cpp
@@ -9,13 +9,13 @@
namespace Botan {
-size_t KDF1_18033::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t KDF1_18033::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
- u32bit counter = 0;
- secure_vector<byte> h;
+ uint32_t counter = 0;
+ secure_vector<uint8_t> h;
size_t offset = 0;
while(offset != key_len && counter != 0xFFFFFFFF)
diff --git a/src/lib/kdf/kdf1_iso18033/kdf1_iso18033.h b/src/lib/kdf/kdf1_iso18033/kdf1_iso18033.h
index 08e2d5c61..d77399aa4 100644
--- a/src/lib/kdf/kdf1_iso18033/kdf1_iso18033.h
+++ b/src/lib/kdf/kdf1_iso18033/kdf1_iso18033.h
@@ -23,10 +23,10 @@ class BOTAN_DLL KDF1_18033 : public KDF
KDF* clone() const override { return new KDF1_18033(m_hash->clone()); }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
/**
* @param h hash function to use
diff --git a/src/lib/kdf/kdf2/kdf2.cpp b/src/lib/kdf/kdf2/kdf2.cpp
index 760ebfc83..0f10b7b8f 100644
--- a/src/lib/kdf/kdf2/kdf2.cpp
+++ b/src/lib/kdf/kdf2/kdf2.cpp
@@ -9,13 +9,13 @@
namespace Botan {
-size_t KDF2::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t KDF2::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
- u32bit counter = 1;
- secure_vector<byte> h;
+ uint32_t counter = 1;
+ secure_vector<uint8_t> h;
size_t offset = 0;
while(offset != key_len && counter != 0)
diff --git a/src/lib/kdf/kdf2/kdf2.h b/src/lib/kdf/kdf2/kdf2.h
index 2ead49530..5683aeb8a 100644
--- a/src/lib/kdf/kdf2/kdf2.h
+++ b/src/lib/kdf/kdf2/kdf2.h
@@ -23,10 +23,10 @@ class BOTAN_DLL KDF2 final : public KDF
KDF* clone() const override { return new KDF2(m_hash->clone()); }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
/**
* @param h hash function to use
diff --git a/src/lib/kdf/prf_tls/prf_tls.cpp b/src/lib/kdf/prf_tls/prf_tls.cpp
index 6f247ab6e..ead41f505 100644
--- a/src/lib/kdf/prf_tls/prf_tls.cpp
+++ b/src/lib/kdf/prf_tls/prf_tls.cpp
@@ -21,10 +21,10 @@ namespace {
/*
* TLS PRF P_hash function
*/
-void P_hash(byte out[], size_t out_len,
+void P_hash(uint8_t out[], size_t out_len,
MessageAuthenticationCode& mac,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len)
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len)
{
try
{
@@ -37,8 +37,8 @@ void P_hash(byte out[], size_t out_len,
" bytes is too long for the PRF");
}
- secure_vector<byte> A(salt, salt + salt_len);
- secure_vector<byte> h;
+ secure_vector<uint8_t> A(salt, salt + salt_len);
+ secure_vector<uint8_t> h;
size_t offset = 0;
@@ -58,16 +58,16 @@ void P_hash(byte out[], size_t out_len,
}
-size_t TLS_PRF::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t TLS_PRF::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
const size_t S1_len = (secret_len + 1) / 2,
S2_len = (secret_len + 1) / 2;
- const byte* S1 = secret;
- const byte* S2 = secret + (secret_len - S2_len);
- secure_vector<byte> msg;
+ const uint8_t* S1 = secret;
+ const uint8_t* S2 = secret + (secret_len - S2_len);
+ secure_vector<uint8_t> msg;
msg.reserve(label_len + salt_len);
msg += std::make_pair(label, label_len);
@@ -78,12 +78,12 @@ size_t TLS_PRF::kdf(byte key[], size_t key_len,
return key_len;
}
-size_t TLS_12_PRF::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t TLS_12_PRF::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
- secure_vector<byte> msg;
+ secure_vector<uint8_t> msg;
msg.reserve(label_len + salt_len);
msg += std::make_pair(label, label_len);
diff --git a/src/lib/kdf/prf_tls/prf_tls.h b/src/lib/kdf/prf_tls/prf_tls.h
index 64891144a..3f1585913 100644
--- a/src/lib/kdf/prf_tls/prf_tls.h
+++ b/src/lib/kdf/prf_tls/prf_tls.h
@@ -23,10 +23,10 @@ class BOTAN_DLL TLS_PRF final : public KDF
KDF* clone() const override { return new TLS_PRF; }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
TLS_PRF();
private:
@@ -44,10 +44,10 @@ class BOTAN_DLL TLS_12_PRF final : public KDF
KDF* clone() const override { return new TLS_12_PRF(m_mac->clone()); }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
/**
* @param mac MAC algorithm to use
diff --git a/src/lib/kdf/prf_x942/prf_x942.cpp b/src/lib/kdf/prf_x942/prf_x942.cpp
index 206cf6ce6..1abb4e77e 100644
--- a/src/lib/kdf/prf_x942/prf_x942.cpp
+++ b/src/lib/kdf/prf_x942/prf_x942.cpp
@@ -19,27 +19,27 @@ namespace {
/*
* Encode an integer as an OCTET STRING
*/
-std::vector<byte> encode_x942_int(u32bit n)
+std::vector<uint8_t> encode_x942_int(uint32_t n)
{
- byte n_buf[4] = { 0 };
+ uint8_t n_buf[4] = { 0 };
store_be(n, n_buf);
return DER_Encoder().encode(n_buf, 4, OCTET_STRING).get_contents_unlocked();
}
}
-size_t X942_PRF::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t X942_PRF::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-160"));
const OID kek_algo(m_key_wrap_oid);
- secure_vector<byte> h;
- secure_vector<byte> in;
+ secure_vector<uint8_t> h;
+ secure_vector<uint8_t> in;
size_t offset = 0;
- u32bit counter = 1;
+ uint32_t counter = 1;
in.reserve(salt_len + label_len);
in += std::make_pair(label,label_len);
@@ -65,7 +65,7 @@ size_t X942_PRF::kdf(byte key[], size_t key_len,
)
.start_explicit(2)
- .raw_bytes(encode_x942_int(static_cast<u32bit>(8 * key_len)))
+ .raw_bytes(encode_x942_int(static_cast<uint32_t>(8 * key_len)))
.end_explicit()
.end_cons().get_contents()
diff --git a/src/lib/kdf/prf_x942/prf_x942.h b/src/lib/kdf/prf_x942/prf_x942.h
index 2c02f3b9e..fbc931637 100644
--- a/src/lib/kdf/prf_x942/prf_x942.h
+++ b/src/lib/kdf/prf_x942/prf_x942.h
@@ -22,10 +22,10 @@ class BOTAN_DLL X942_PRF final : public KDF
KDF* clone() const override { return new X942_PRF(m_key_wrap_oid); }
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
explicit X942_PRF(const std::string& oid);
private:
diff --git a/src/lib/kdf/sp800_108/sp800_108.cpp b/src/lib/kdf/sp800_108/sp800_108.cpp
index 77973600a..8b1af2ea7 100644
--- a/src/lib/kdf/sp800_108/sp800_108.cpp
+++ b/src/lib/kdf/sp800_108/sp800_108.cpp
@@ -12,18 +12,18 @@
namespace Botan {
-size_t SP800_108_Counter::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t SP800_108_Counter::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
const std::size_t prf_len = m_prf->output_length();
- const byte delim = 0;
- byte *p = key;
+ const uint8_t delim = 0;
+ uint8_t *p = key;
uint32_t counter = 1;
uint32_t length = key_len * 8;
- byte be_len[4] = { 0 };
- secure_vector<byte> tmp;
+ uint8_t be_len[4] = { 0 };
+ secure_vector<uint8_t> tmp;
store_be(length, be_len);
m_prf->set_key(secret, secret_len);
@@ -31,7 +31,7 @@ size_t SP800_108_Counter::kdf(byte key[], size_t key_len,
while(p < key + key_len && counter != 0)
{
const std::size_t to_copy = std::min< std::size_t >(key + key_len - p, prf_len);
- byte be_cnt[4] = { 0 };
+ uint8_t be_cnt[4] = { 0 };
store_be(counter, be_cnt);
@@ -54,21 +54,21 @@ size_t SP800_108_Counter::kdf(byte key[], size_t key_len,
return key_len;
}
-size_t SP800_108_Feedback::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t SP800_108_Feedback::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
const std::size_t prf_len = m_prf->output_length();
const std::size_t iv_len = (salt_len >= prf_len ? prf_len : 0);
- const byte delim = 0;
+ const uint8_t delim = 0;
- byte *p = key;
+ uint8_t *p = key;
uint32_t counter = 1;
uint32_t length = key_len * 8;
- byte be_len[4] = { 0 };
- secure_vector< byte > prev(salt, salt + iv_len);
- secure_vector< byte > ctx(salt + iv_len, salt + salt_len);
+ uint8_t be_len[4] = { 0 };
+ secure_vector< uint8_t > prev(salt, salt + iv_len);
+ secure_vector< uint8_t > ctx(salt + iv_len, salt + salt_len);
store_be(length, be_len);
m_prf->set_key(secret, secret_len);
@@ -76,7 +76,7 @@ size_t SP800_108_Feedback::kdf(byte key[], size_t key_len,
while(p < key + key_len && counter != 0)
{
const std::size_t to_copy = std::min< std::size_t >(key + key_len - p, prf_len);
- byte be_cnt[4] = { 0 };
+ uint8_t be_cnt[4] = { 0 };
store_be(counter, be_cnt);
@@ -100,19 +100,19 @@ size_t SP800_108_Feedback::kdf(byte key[], size_t key_len,
return key_len;
}
-size_t SP800_108_Pipeline::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t SP800_108_Pipeline::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
const std::size_t prf_len = m_prf->output_length();
- const byte delim = 0;
+ const uint8_t delim = 0;
- byte *p = key;
+ uint8_t *p = key;
uint32_t counter = 1;
uint32_t length = key_len * 8;
- byte be_len[4] = { 0 };
- secure_vector<byte> ai, ki;
+ uint8_t be_len[4] = { 0 };
+ secure_vector<uint8_t> ai, ki;
store_be(length, be_len);
m_prf->set_key(secret,secret_len);
@@ -131,7 +131,7 @@ size_t SP800_108_Pipeline::kdf(byte key[], size_t key_len,
// K(i)
const std::size_t to_copy = std::min< std::size_t >(key + key_len - p, prf_len);
- byte be_cnt[4] = { 0 };
+ uint8_t be_cnt[4] = { 0 };
store_be(counter, be_cnt);
diff --git a/src/lib/kdf/sp800_108/sp800_108.h b/src/lib/kdf/sp800_108/sp800_108.h
index e368457b4..848b9e2a2 100644
--- a/src/lib/kdf/sp800_108/sp800_108.h
+++ b/src/lib/kdf/sp800_108/sp800_108.h
@@ -40,10 +40,10 @@ class BOTAN_DLL SP800_108_Counter : public KDF
*
* @throws Invalid_Argument key_len > 2^32
*/
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
/**
* @param mac MAC algorithm to use
@@ -80,10 +80,10 @@ class BOTAN_DLL SP800_108_Feedback : public KDF
*
* @throws Invalid_Argument key_len > 2^32
*/
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
SP800_108_Feedback(MessageAuthenticationCode* mac) : m_prf(mac) {}
private:
@@ -117,10 +117,10 @@ class BOTAN_DLL SP800_108_Pipeline : public KDF
*
* @throws Invalid_Argument key_len > 2^32
*/
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
SP800_108_Pipeline(MessageAuthenticationCode* mac) : m_prf(mac) {}
diff --git a/src/lib/kdf/sp800_56c/sp800_56c.cpp b/src/lib/kdf/sp800_56c/sp800_56c.cpp
index f6d01ec2f..30a49e8ee 100644
--- a/src/lib/kdf/sp800_56c/sp800_56c.cpp
+++ b/src/lib/kdf/sp800_56c/sp800_56c.cpp
@@ -11,13 +11,13 @@
namespace Botan {
-size_t SP800_56C::kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const
+size_t SP800_56C::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
{
// Randomness Extraction
- secure_vector< byte > k_dk;
+ secure_vector< uint8_t > k_dk;
m_prf->set_key(salt, salt_len);
m_prf->update(secret, secret_len);
diff --git a/src/lib/kdf/sp800_56c/sp800_56c.h b/src/lib/kdf/sp800_56c/sp800_56c.h
index 5c5acb075..aa3087974 100644
--- a/src/lib/kdf/sp800_56c/sp800_56c.h
+++ b/src/lib/kdf/sp800_56c/sp800_56c.h
@@ -40,10 +40,10 @@ class BOTAN_DLL SP800_56C : public KDF
*
* @throws Invalid_Argument key_len > 2^32
*/
- size_t kdf(byte key[], size_t key_len,
- const byte secret[], size_t secret_len,
- const byte salt[], size_t salt_len,
- const byte label[], size_t label_len) const override;
+ size_t kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const override;
/**
* @param mac MAC algorithm used for randomness extraction
diff --git a/src/lib/mac/cbc_mac/cbc_mac.cpp b/src/lib/mac/cbc_mac/cbc_mac.cpp
index 741d550e5..b272fe3bc 100644
--- a/src/lib/mac/cbc_mac/cbc_mac.cpp
+++ b/src/lib/mac/cbc_mac/cbc_mac.cpp
@@ -12,7 +12,7 @@ namespace Botan {
/*
* Update an CBC-MAC Calculation
*/
-void CBC_MAC::add_data(const byte input[], size_t length)
+void CBC_MAC::add_data(const uint8_t input[], size_t length)
{
size_t xored = std::min(output_length() - m_position, length);
xor_buf(&m_state[m_position], input, xored);
@@ -39,7 +39,7 @@ void CBC_MAC::add_data(const byte input[], size_t length)
/*
* Finalize an CBC-MAC Calculation
*/
-void CBC_MAC::final_result(byte mac[])
+void CBC_MAC::final_result(uint8_t mac[])
{
if(m_position)
m_cipher->encrypt(m_state);
@@ -52,7 +52,7 @@ void CBC_MAC::final_result(byte mac[])
/*
* CBC-MAC Key Schedule
*/
-void CBC_MAC::key_schedule(const byte key[], size_t length)
+void CBC_MAC::key_schedule(const uint8_t key[], size_t length)
{
m_cipher->set_key(key, length);
}
diff --git a/src/lib/mac/cbc_mac/cbc_mac.h b/src/lib/mac/cbc_mac/cbc_mac.h
index dd4877d1c..9ac870cb4 100644
--- a/src/lib/mac/cbc_mac/cbc_mac.h
+++ b/src/lib/mac/cbc_mac/cbc_mac.h
@@ -34,12 +34,12 @@ class BOTAN_DLL CBC_MAC final : public MessageAuthenticationCode
*/
explicit CBC_MAC(BlockCipher* cipher);
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- void key_schedule(const byte[], size_t) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ void key_schedule(const uint8_t[], size_t) override;
std::unique_ptr<BlockCipher> m_cipher;
- secure_vector<byte> m_state;
+ secure_vector<uint8_t> m_state;
size_t m_position = 0;
};
diff --git a/src/lib/mac/cmac/cmac.cpp b/src/lib/mac/cmac/cmac.cpp
index 9afd86cdb..bb862196f 100644
--- a/src/lib/mac/cmac/cmac.cpp
+++ b/src/lib/mac/cmac/cmac.cpp
@@ -12,16 +12,16 @@ namespace Botan {
/*
* Perform CMAC's multiplication in GF(2^n)
*/
-secure_vector<byte> CMAC::poly_double(const secure_vector<byte>& in)
+secure_vector<uint8_t> CMAC::poly_double(const secure_vector<uint8_t>& in)
{
const bool top_carry = static_cast<bool>((in[0] & 0x80) != 0);
- secure_vector<byte> out = in;
+ secure_vector<uint8_t> out = in;
- byte carry = 0;
+ uint8_t carry = 0;
for(size_t i = out.size(); i != 0; --i)
{
- byte temp = out[i-1];
+ uint8_t temp = out[i-1];
out[i-1] = (temp << 1) | carry;
carry = (temp >> 7);
}
@@ -55,7 +55,7 @@ secure_vector<byte> CMAC::poly_double(const secure_vector<byte>& in)
/*
* Update an CMAC Calculation
*/
-void CMAC::add_data(const byte input[], size_t length)
+void CMAC::add_data(const uint8_t input[], size_t length)
{
buffer_insert(m_buffer, m_position, input, length);
if(m_position + length > output_length())
@@ -80,7 +80,7 @@ void CMAC::add_data(const byte input[], size_t length)
/*
* Finalize an CMAC Calculation
*/
-void CMAC::final_result(byte mac[])
+void CMAC::final_result(uint8_t mac[])
{
xor_buf(m_state, m_buffer, m_position);
@@ -107,7 +107,7 @@ void CMAC::final_result(byte mac[])
/*
* CMAC Key Schedule
*/
-void CMAC::key_schedule(const byte key[], size_t length)
+void CMAC::key_schedule(const uint8_t key[], size_t length)
{
clear();
m_cipher->set_key(key, length);
diff --git a/src/lib/mac/cmac/cmac.h b/src/lib/mac/cmac/cmac.h
index 6897665c0..7127f82f2 100644
--- a/src/lib/mac/cmac/cmac.h
+++ b/src/lib/mac/cmac/cmac.h
@@ -34,7 +34,7 @@ class BOTAN_DLL CMAC final : public MessageAuthenticationCode
* CMAC's polynomial doubling operation
* @param in the input
*/
- static secure_vector<byte> poly_double(const secure_vector<byte>& in);
+ static secure_vector<uint8_t> poly_double(const secure_vector<uint8_t>& in);
/**
* @param cipher the block cipher to use
@@ -44,12 +44,12 @@ class BOTAN_DLL CMAC final : public MessageAuthenticationCode
CMAC(const CMAC&) = delete;
CMAC& operator=(const CMAC&) = delete;
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- void key_schedule(const byte[], size_t) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ void key_schedule(const uint8_t[], size_t) override;
std::unique_ptr<BlockCipher> m_cipher;
- secure_vector<byte> m_buffer, m_state, m_B, m_P;
+ secure_vector<uint8_t> m_buffer, m_state, m_B, m_P;
size_t m_position;
};
diff --git a/src/lib/mac/gmac/gmac.cpp b/src/lib/mac/gmac/gmac.cpp
index 4461cf370..5e08a8827 100644
--- a/src/lib/mac/gmac/gmac.cpp
+++ b/src/lib/mac/gmac/gmac.cpp
@@ -37,7 +37,7 @@ size_t GMAC::output_length() const
return GCM_BS;
}
-void GMAC::add_data(const byte input[], size_t size)
+void GMAC::add_data(const uint8_t input[], size_t size)
{
m_ad_len += size;
@@ -57,16 +57,16 @@ void GMAC::add_data(const byte input[], size_t size)
}
}
-void GMAC::key_schedule(const byte key[], size_t size)
+void GMAC::key_schedule(const uint8_t key[], size_t size)
{
clear();
m_cipher->set_key(key, size);
m_cipher->encrypt(m_H_ad.data(), m_H.data());
}
-void GMAC::start_msg(const byte nonce[], size_t nonce_len)
+void GMAC::start_msg(const uint8_t nonce[], size_t nonce_len)
{
- secure_vector<byte> y0(GCM_BS);
+ secure_vector<uint8_t> y0(GCM_BS);
if(nonce_len == 12)
{
@@ -79,13 +79,13 @@ void GMAC::start_msg(const byte nonce[], size_t nonce_len)
add_final_block(y0, 0, nonce_len);
}
- secure_vector<byte> m_enc_y0(GCM_BS);
+ secure_vector<uint8_t> m_enc_y0(GCM_BS);
m_cipher->encrypt(y0.data(), m_enc_y0.data());
GHASH::start(m_enc_y0.data(), m_enc_y0.size());
m_initialized = true;
}
-void GMAC::final_result(byte mac[])
+void GMAC::final_result(uint8_t mac[])
{
// This ensures the GMAC computation has been initialized with a fresh
// nonce. The aim of this check is to prevent developers from re-using
@@ -101,7 +101,7 @@ void GMAC::final_result(byte mac[])
m_aad_buf.data(),
m_aad_buf.size());
}
- secure_vector<byte> result = GHASH::final();
+ secure_vector<uint8_t> result = GHASH::final();
std::copy(result.begin(), result.end(), mac);
clear();
}
diff --git a/src/lib/mac/gmac/gmac.h b/src/lib/mac/gmac/gmac.h
index b05c5451f..7735d3d32 100644
--- a/src/lib/mac/gmac/gmac.h
+++ b/src/lib/mac/gmac/gmac.h
@@ -35,7 +35,7 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode,
* @param nonce Initialization vector.
* @param nonce_len size of initialization vector.
*/
- void start(const byte nonce[], size_t nonce_len);
+ void start(const uint8_t nonce[], size_t nonce_len);
/**
* Must be called to set the initialization vector prior to GMAC
@@ -43,7 +43,7 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode,
*
* @param nonce Initialization vector.
*/
- void start(const secure_vector<byte>& nonce);
+ void start(const secure_vector<uint8_t>& nonce);
/**
* Must be called to set the initialization vector prior to GMAC
@@ -51,7 +51,7 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode,
*
* @param nonce Initialization vector.
*/
- void start(const std::vector<byte>& nonce);
+ void start(const std::vector<uint8_t>& nonce);
Key_Length_Specification key_spec() const override
{
@@ -69,13 +69,13 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode,
GMAC& operator=(const GMAC&) = delete;
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- void start_msg(const byte nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t size) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
+ void key_schedule(const uint8_t key[], size_t size) override;
static const size_t GCM_BS = 16;
- secure_vector<byte> m_aad_buf;
+ secure_vector<uint8_t> m_aad_buf;
std::unique_ptr<BlockCipher> m_cipher;
bool m_initialized;
};
diff --git a/src/lib/mac/hmac/hmac.cpp b/src/lib/mac/hmac/hmac.cpp
index a2021515f..aeadf4520 100644
--- a/src/lib/mac/hmac/hmac.cpp
+++ b/src/lib/mac/hmac/hmac.cpp
@@ -13,7 +13,7 @@ namespace Botan {
/*
* Update a HMAC Calculation
*/
-void HMAC::add_data(const byte input[], size_t length)
+void HMAC::add_data(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
@@ -21,7 +21,7 @@ void HMAC::add_data(const byte input[], size_t length)
/*
* Finalize a HMAC Calculation
*/
-void HMAC::final_result(byte mac[])
+void HMAC::final_result(uint8_t mac[])
{
m_hash->final(mac);
m_hash->update(m_okey);
@@ -33,7 +33,7 @@ void HMAC::final_result(byte mac[])
/*
* HMAC Key Schedule
*/
-void HMAC::key_schedule(const byte key[], size_t length)
+void HMAC::key_schedule(const uint8_t key[], size_t length)
{
m_hash->clear();
@@ -45,7 +45,7 @@ void HMAC::key_schedule(const byte key[], size_t length)
if(length > m_hash->hash_block_size())
{
- secure_vector<byte> hmac_key = m_hash->process(key, length);
+ secure_vector<uint8_t> hmac_key = m_hash->process(key, length);
xor_buf(m_ikey, hmac_key, hmac_key.size());
xor_buf(m_okey, hmac_key, hmac_key.size());
}
diff --git a/src/lib/mac/hmac/hmac.h b/src/lib/mac/hmac/hmac.h
index bfb425fa8..6627475d1 100644
--- a/src/lib/mac/hmac/hmac.h
+++ b/src/lib/mac/hmac/hmac.h
@@ -39,12 +39,12 @@ class BOTAN_DLL HMAC final : public MessageAuthenticationCode
HMAC(const HMAC&) = delete;
HMAC& operator=(const HMAC&) = delete;
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- void key_schedule(const byte[], size_t) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ void key_schedule(const uint8_t[], size_t) override;
std::unique_ptr<HashFunction> m_hash;
- secure_vector<byte> m_ikey, m_okey;
+ secure_vector<uint8_t> m_ikey, m_okey;
};
}
diff --git a/src/lib/mac/mac.cpp b/src/lib/mac/mac.cpp
index 2fa321a67..3dfe753b7 100644
--- a/src/lib/mac/mac.cpp
+++ b/src/lib/mac/mac.cpp
@@ -145,9 +145,9 @@ MessageAuthenticationCode::create_or_throw(const std::string& algo,
/*
* Default (deterministic) MAC verification operation
*/
-bool MessageAuthenticationCode::verify_mac(const byte mac[], size_t length)
+bool MessageAuthenticationCode::verify_mac(const uint8_t mac[], size_t length)
{
- secure_vector<byte> our_mac = final();
+ secure_vector<uint8_t> our_mac = final();
if(our_mac.size() != length)
return false;
diff --git a/src/lib/mac/mac.h b/src/lib/mac/mac.h
index d7808c1bf..44bdd3da4 100644
--- a/src/lib/mac/mac.h
+++ b/src/lib/mac/mac.h
@@ -63,7 +63,7 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation,
* Default implementation simply rejects all non-empty nonces
* since most hash/MAC algorithms do not support randomization
*/
- virtual void start_msg(const byte nonce[], size_t nonce_len)
+ virtual void start_msg(const uint8_t nonce[], size_t nonce_len)
{
BOTAN_UNUSED(nonce);
if(nonce_len > 0)
@@ -76,7 +76,7 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation,
* @param nonce the per message nonce
*/
template<typename Alloc>
- void start(const std::vector<byte, Alloc>& nonce)
+ void start(const std::vector<uint8_t, Alloc>& nonce)
{
start_msg(nonce.data(), nonce.size());
}
@@ -86,7 +86,7 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation,
* @param nonce the per message nonce
* @param nonce_len length of nonce
*/
- void start(const byte nonce[], size_t nonce_len)
+ void start(const uint8_t nonce[], size_t nonce_len)
{
start_msg(nonce, nonce_len);
}
@@ -105,14 +105,14 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation,
* @param length the length of param in
* @return true if the MAC is valid, false otherwise
*/
- virtual bool verify_mac(const byte in[], size_t length);
+ virtual bool verify_mac(const uint8_t in[], size_t length);
/**
* Verify a MAC.
* @param in the MAC to verify as a byte array
* @return true if the MAC is valid, false otherwise
*/
- virtual bool verify_mac(const std::vector<byte>& in)
+ virtual bool verify_mac(const std::vector<uint8_t>& in)
{
return verify_mac(in.data(), in.size());
}
@@ -122,7 +122,7 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation,
* @param in the MAC to verify as a byte array
* @return true if the MAC is valid, false otherwise
*/
- virtual bool verify_mac(const secure_vector<byte>& in)
+ virtual bool verify_mac(const secure_vector<uint8_t>& in)
{
return verify_mac(in.data(), in.size());
}
diff --git a/src/lib/mac/poly1305/poly1305.cpp b/src/lib/mac/poly1305/poly1305.cpp
index 0a62808f6..9fe0bad0a 100644
--- a/src/lib/mac/poly1305/poly1305.cpp
+++ b/src/lib/mac/poly1305/poly1305.cpp
@@ -17,11 +17,11 @@ namespace Botan {
namespace {
-void poly1305_init(secure_vector<u64bit>& X, const byte key[32])
+void poly1305_init(secure_vector<uint64_t>& X, const uint8_t key[32])
{
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
- const u64bit t0 = load_le<u64bit>(key, 0);
- const u64bit t1 = load_le<u64bit>(key, 1);
+ const uint64_t t0 = load_le<uint64_t>(key, 0);
+ const uint64_t t1 = load_le<uint64_t>(key, 1);
X[0] = ( t0 ) & 0xffc0fffffff;
X[1] = ((t0 >> 44) | (t1 << 20)) & 0xfffffc0ffff;
@@ -33,34 +33,34 @@ void poly1305_init(secure_vector<u64bit>& X, const byte key[32])
X[5] = 0;
/* save pad for later */
- X[6] = load_le<u64bit>(key, 2);
- X[7] = load_le<u64bit>(key, 3);
+ X[6] = load_le<uint64_t>(key, 2);
+ X[7] = load_le<uint64_t>(key, 3);
}
-void poly1305_blocks(secure_vector<u64bit>& X, const byte *m, size_t blocks, bool is_final = false)
+void poly1305_blocks(secure_vector<uint64_t>& X, const uint8_t *m, size_t blocks, bool is_final = false)
{
#if !defined(BOTAN_TARGET_HAS_NATIVE_UINT128)
typedef donna128 uint128_t;
#endif
- const u64bit hibit = is_final ? 0 : (static_cast<u64bit>(1) << 40); /* 1 << 128 */
+ const uint64_t hibit = is_final ? 0 : (static_cast<uint64_t>(1) << 40); /* 1 << 128 */
- const u64bit r0 = X[0];
- const u64bit r1 = X[1];
- const u64bit r2 = X[2];
+ const uint64_t r0 = X[0];
+ const uint64_t r1 = X[1];
+ const uint64_t r2 = X[2];
- u64bit h0 = X[3+0];
- u64bit h1 = X[3+1];
- u64bit h2 = X[3+2];
+ uint64_t h0 = X[3+0];
+ uint64_t h1 = X[3+1];
+ uint64_t h2 = X[3+2];
- const u64bit s1 = r1 * (5 << 2);
- const u64bit s2 = r2 * (5 << 2);
+ const uint64_t s1 = r1 * (5 << 2);
+ const uint64_t s2 = r2 * (5 << 2);
while(blocks--)
{
/* h += m[i] */
- const u64bit t0 = load_le<u64bit>(m, 0);
- const u64bit t1 = load_le<u64bit>(m, 1);
+ const uint64_t t0 = load_le<uint64_t>(m, 0);
+ const uint64_t t1 = load_le<uint64_t>(m, 1);
h0 += (( t0 ) & 0xfffffffffff);
h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff);
@@ -72,7 +72,7 @@ void poly1305_blocks(secure_vector<u64bit>& X, const byte *m, size_t blocks, boo
uint128_t d2 = uint128_t(h0) * r2 + uint128_t(h1) * r1 + uint128_t(h2) * r0;
/* (partial) h %= p */
- u64bit c = carry_shift(d0, 44); h0 = d0 & 0xfffffffffff;
+ uint64_t c = carry_shift(d0, 44); h0 = d0 & 0xfffffffffff;
d1 += c; c = carry_shift(d1, 44); h1 = d1 & 0xfffffffffff;
d2 += c; c = carry_shift(d2, 42); h2 = d2 & 0x3ffffffffff;
h0 += c * 5; c = carry_shift(h0, 44); h0 = h0 & 0xfffffffffff;
@@ -86,14 +86,14 @@ void poly1305_blocks(secure_vector<u64bit>& X, const byte *m, size_t blocks, boo
X[3+2] = h2;
}
-void poly1305_finish(secure_vector<u64bit>& X, byte mac[16])
+void poly1305_finish(secure_vector<uint64_t>& X, uint8_t mac[16])
{
/* fully carry h */
- u64bit h0 = X[3+0];
- u64bit h1 = X[3+1];
- u64bit h2 = X[3+2];
+ uint64_t h0 = X[3+0];
+ uint64_t h1 = X[3+1];
+ uint64_t h2 = X[3+2];
- u64bit c;
+ uint64_t c;
c = (h1 >> 44); h1 &= 0xfffffffffff;
h2 += c; c = (h2 >> 42); h2 &= 0x3ffffffffff;
h0 += c * 5; c = (h0 >> 44); h0 &= 0xfffffffffff;
@@ -103,12 +103,12 @@ void poly1305_finish(secure_vector<u64bit>& X, byte mac[16])
h1 += c;
/* compute h + -p */
- u64bit g0 = h0 + 5; c = (g0 >> 44); g0 &= 0xfffffffffff;
- u64bit g1 = h1 + c; c = (g1 >> 44); g1 &= 0xfffffffffff;
- u64bit g2 = h2 + c - (static_cast<u64bit>(1) << 42);
+ uint64_t g0 = h0 + 5; c = (g0 >> 44); g0 &= 0xfffffffffff;
+ uint64_t g1 = h1 + c; c = (g1 >> 44); g1 &= 0xfffffffffff;
+ uint64_t g2 = h2 + c - (static_cast<uint64_t>(1) << 42);
/* select h if h < p, or h + -p if h >= p */
- c = (g2 >> ((sizeof(u64bit) * 8) - 1)) - 1;
+ c = (g2 >> ((sizeof(uint64_t) * 8) - 1)) - 1;
g0 &= c;
g1 &= c;
g2 &= c;
@@ -118,8 +118,8 @@ void poly1305_finish(secure_vector<u64bit>& X, byte mac[16])
h2 = (h2 & c) | g2;
/* h = (h + pad) */
- const u64bit t0 = X[6];
- const u64bit t1 = X[7];
+ const uint64_t t0 = X[6];
+ const uint64_t t1 = X[7];
h0 += (( t0 ) & 0xfffffffffff) ; c = (h0 >> 44); h0 &= 0xfffffffffff;
h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff) + c; c = (h1 >> 44); h1 &= 0xfffffffffff;
@@ -144,7 +144,7 @@ void Poly1305::clear()
m_buf_pos = 0;
}
-void Poly1305::key_schedule(const byte key[], size_t)
+void Poly1305::key_schedule(const uint8_t key[], size_t)
{
m_buf_pos = 0;
m_buf.resize(16);
@@ -153,7 +153,7 @@ void Poly1305::key_schedule(const byte key[], size_t)
poly1305_init(m_poly, key);
}
-void Poly1305::add_data(const byte input[], size_t length)
+void Poly1305::add_data(const uint8_t input[], size_t length)
{
BOTAN_ASSERT_EQUAL(m_poly.size(), 8, "Initialized");
@@ -180,7 +180,7 @@ void Poly1305::add_data(const byte input[], size_t length)
m_buf_pos += remaining;
}
-void Poly1305::final_result(byte out[])
+void Poly1305::final_result(uint8_t out[])
{
BOTAN_ASSERT_EQUAL(m_poly.size(), 8, "Initialized");
diff --git a/src/lib/mac/poly1305/poly1305.h b/src/lib/mac/poly1305/poly1305.h
index 740313122..25ee70761 100644
--- a/src/lib/mac/poly1305/poly1305.h
+++ b/src/lib/mac/poly1305/poly1305.h
@@ -34,12 +34,12 @@ class BOTAN_DLL Poly1305 final : public MessageAuthenticationCode
}
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- void key_schedule(const byte[], size_t) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u64bit> m_poly;
- secure_vector<byte> m_buf;
+ secure_vector<uint64_t> m_poly;
+ secure_vector<uint8_t> m_buf;
size_t m_buf_pos = 0;
};
diff --git a/src/lib/mac/siphash/siphash.cpp b/src/lib/mac/siphash/siphash.cpp
index cb72f771c..c6ef68889 100644
--- a/src/lib/mac/siphash/siphash.cpp
+++ b/src/lib/mac/siphash/siphash.cpp
@@ -11,9 +11,9 @@ namespace Botan {
namespace {
-void SipRounds(u64bit M, secure_vector<u64bit>& V, size_t r)
+void SipRounds(uint64_t M, secure_vector<uint64_t>& V, size_t r)
{
- u64bit V0 = V[0], V1 = V[1], V2 = V[2], V3 = V[3];
+ uint64_t V0 = V[0], V1 = V[1], V2 = V[2], V3 = V[3];
V3 ^= M;
for(size_t i = 0; i != r; ++i)
@@ -37,7 +37,7 @@ void SipRounds(u64bit M, secure_vector<u64bit>& V, size_t r)
}
-void SipHash::add_data(const byte input[], size_t length)
+void SipHash::add_data(const uint8_t input[], size_t length)
{
m_words += length;
@@ -45,7 +45,7 @@ void SipHash::add_data(const byte input[], size_t length)
{
while(length && m_mbuf_pos != 8)
{
- m_mbuf = (m_mbuf >> 8) | (static_cast<u64bit>(input[0]) << 56);
+ m_mbuf = (m_mbuf >> 8) | (static_cast<uint64_t>(input[0]) << 56);
++m_mbuf_pos;
++input;
length--;
@@ -61,37 +61,37 @@ void SipHash::add_data(const byte input[], size_t length)
while(length >= 8)
{
- SipRounds(load_le<u64bit>(input, 0), m_V, m_C);
+ SipRounds(load_le<uint64_t>(input, 0), m_V, m_C);
input += 8;
length -= 8;
}
for(size_t i = 0; i != length; ++i)
{
- m_mbuf = (m_mbuf >> 8) | (static_cast<u64bit>(input[i]) << 56);
+ m_mbuf = (m_mbuf >> 8) | (static_cast<uint64_t>(input[i]) << 56);
m_mbuf_pos++;
}
}
-void SipHash::final_result(byte mac[])
+void SipHash::final_result(uint8_t mac[])
{
- m_mbuf = (m_mbuf >> (64-m_mbuf_pos*8)) | (static_cast<u64bit>(m_words) << 56);
+ m_mbuf = (m_mbuf >> (64-m_mbuf_pos*8)) | (static_cast<uint64_t>(m_words) << 56);
SipRounds(m_mbuf, m_V, m_C);
m_V[2] ^= 0xFF;
SipRounds(0, m_V, m_D);
- const u64bit X = m_V[0] ^ m_V[1] ^ m_V[2] ^ m_V[3];
+ const uint64_t X = m_V[0] ^ m_V[1] ^ m_V[2] ^ m_V[3];
store_le(X, mac);
clear();
}
-void SipHash::key_schedule(const byte key[], size_t)
+void SipHash::key_schedule(const uint8_t key[], size_t)
{
- const u64bit K0 = load_le<u64bit>(key, 0);
- const u64bit K1 = load_le<u64bit>(key, 1);
+ const uint64_t K0 = load_le<uint64_t>(key, 0);
+ const uint64_t K1 = load_le<uint64_t>(key, 1);
m_V.resize(4);
m_V[0] = K0 ^ 0x736F6D6570736575;
diff --git a/src/lib/mac/siphash/siphash.h b/src/lib/mac/siphash/siphash.h
index d774fe5e7..ebae6a91d 100644
--- a/src/lib/mac/siphash/siphash.h
+++ b/src/lib/mac/siphash/siphash.h
@@ -29,15 +29,15 @@ class BOTAN_DLL SipHash final : public MessageAuthenticationCode
return Key_Length_Specification(16);
}
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- void key_schedule(const byte[], size_t) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ void key_schedule(const uint8_t[], size_t) override;
const size_t m_C, m_D;
- secure_vector<u64bit> m_V;
- u64bit m_mbuf = 0;
+ secure_vector<uint64_t> m_V;
+ uint64_t m_mbuf = 0;
size_t m_mbuf_pos = 0;
- byte m_words = 0;
+ uint8_t m_words = 0;
};
}
diff --git a/src/lib/mac/x919_mac/x919_mac.cpp b/src/lib/mac/x919_mac/x919_mac.cpp
index 205d812c2..189108377 100644
--- a/src/lib/mac/x919_mac/x919_mac.cpp
+++ b/src/lib/mac/x919_mac/x919_mac.cpp
@@ -12,7 +12,7 @@ namespace Botan {
/*
* Update an ANSI X9.19 MAC Calculation
*/
-void ANSI_X919_MAC::add_data(const byte input[], size_t length)
+void ANSI_X919_MAC::add_data(const uint8_t input[], size_t length)
{
size_t xored = std::min(8 - m_position, length);
xor_buf(&m_state[m_position], input, xored);
@@ -38,7 +38,7 @@ void ANSI_X919_MAC::add_data(const byte input[], size_t length)
/*
* Finalize an ANSI X9.19 MAC Calculation
*/
-void ANSI_X919_MAC::final_result(byte mac[])
+void ANSI_X919_MAC::final_result(uint8_t mac[])
{
if(m_position)
m_des1->encrypt(m_state);
@@ -51,7 +51,7 @@ void ANSI_X919_MAC::final_result(byte mac[])
/*
* ANSI X9.19 MAC Key Schedule
*/
-void ANSI_X919_MAC::key_schedule(const byte key[], size_t length)
+void ANSI_X919_MAC::key_schedule(const uint8_t key[], size_t length)
{
m_des1->set_key(key, 8);
diff --git a/src/lib/mac/x919_mac/x919_mac.h b/src/lib/mac/x919_mac/x919_mac.h
index 904931d20..8e300cb34 100644
--- a/src/lib/mac/x919_mac/x919_mac.h
+++ b/src/lib/mac/x919_mac/x919_mac.h
@@ -35,12 +35,12 @@ class BOTAN_DLL ANSI_X919_MAC final : public MessageAuthenticationCode
ANSI_X919_MAC(const ANSI_X919_MAC&) = delete;
ANSI_X919_MAC& operator=(const ANSI_X919_MAC&) = delete;
private:
- void add_data(const byte[], size_t) override;
- void final_result(byte[]) override;
- void key_schedule(const byte[], size_t) override;
+ void add_data(const uint8_t[], size_t) override;
+ void final_result(uint8_t[]) override;
+ void key_schedule(const uint8_t[], size_t) override;
std::unique_ptr<BlockCipher> m_des1, m_des2;
- secure_vector<byte> m_state;
+ secure_vector<uint8_t> m_state;
size_t m_position;
};
diff --git a/src/lib/math/bigint/big_code.cpp b/src/lib/math/bigint/big_code.cpp
index c8687715d..f7ab53291 100644
--- a/src/lib/math/bigint/big_code.cpp
+++ b/src/lib/math/bigint/big_code.cpp
@@ -15,7 +15,7 @@ namespace Botan {
/*
* Encode a BigInt
*/
-void BigInt::encode(byte output[], const BigInt& n, Base base)
+void BigInt::encode(uint8_t output[], const BigInt& n, Base base)
{
if(base == Binary)
{
@@ -23,7 +23,7 @@ void BigInt::encode(byte output[], const BigInt& n, Base base)
}
else if(base == Hexadecimal)
{
- secure_vector<byte> binary(n.encoded_size(Binary));
+ secure_vector<uint8_t> binary(n.encoded_size(Binary));
n.binary_encode(binary.data());
hex_encode(reinterpret_cast<char*>(output),
@@ -39,7 +39,7 @@ void BigInt::encode(byte output[], const BigInt& n, Base base)
{
divide(copy, 10, copy, remainder);
output[output_size - 1 - j] =
- Charset::digit2char(static_cast<byte>(remainder.word_at(0)));
+ Charset::digit2char(static_cast<uint8_t>(remainder.word_at(0)));
if(copy.is_zero())
break;
}
@@ -51,9 +51,9 @@ void BigInt::encode(byte output[], const BigInt& n, Base base)
/*
* Encode a BigInt
*/
-std::vector<byte> BigInt::encode(const BigInt& n, Base base)
+std::vector<uint8_t> BigInt::encode(const BigInt& n, Base base)
{
- std::vector<byte> output(n.encoded_size(base));
+ std::vector<uint8_t> output(n.encoded_size(base));
encode(output.data(), n, base);
if(base != Binary)
for(size_t j = 0; j != output.size(); ++j)
@@ -65,9 +65,9 @@ std::vector<byte> BigInt::encode(const BigInt& n, Base base)
/*
* Encode a BigInt
*/
-secure_vector<byte> BigInt::encode_locked(const BigInt& n, Base base)
+secure_vector<uint8_t> BigInt::encode_locked(const BigInt& n, Base base)
{
- secure_vector<byte> output(n.encoded_size(base));
+ secure_vector<uint8_t> output(n.encoded_size(base));
encode(output.data(), n, base);
if(base != Binary)
for(size_t j = 0; j != output.size(); ++j)
@@ -79,15 +79,15 @@ secure_vector<byte> BigInt::encode_locked(const BigInt& n, Base base)
/*
* Encode a BigInt, with leading 0s if needed
*/
-secure_vector<byte> BigInt::encode_1363(const BigInt& n, size_t bytes)
+secure_vector<uint8_t> BigInt::encode_1363(const BigInt& n, size_t bytes)
{
- secure_vector<byte> output(bytes);
+ secure_vector<uint8_t> output(bytes);
BigInt::encode_1363(output.data(), output.size(), n);
return output;
}
//static
-void BigInt::encode_1363(byte output[], size_t bytes, const BigInt& n)
+void BigInt::encode_1363(uint8_t output[], size_t bytes, const BigInt& n)
{
const size_t n_bytes = n.bytes();
if(n_bytes > bytes)
@@ -100,9 +100,9 @@ void BigInt::encode_1363(byte output[], size_t bytes, const BigInt& n)
/*
* Encode two BigInt, with leading 0s if needed, and concatenate
*/
-secure_vector<byte> BigInt::encode_fixed_length_int_pair(const BigInt& n1, const BigInt& n2, size_t bytes)
+secure_vector<uint8_t> BigInt::encode_fixed_length_int_pair(const BigInt& n1, const BigInt& n2, size_t bytes)
{
- secure_vector<byte> output(2 * bytes);
+ secure_vector<uint8_t> output(2 * bytes);
BigInt::encode_1363(output.data(), bytes, n1);
BigInt::encode_1363(output.data() + bytes, bytes, n2);
return output;
@@ -111,14 +111,14 @@ secure_vector<byte> BigInt::encode_fixed_length_int_pair(const BigInt& n1, const
/*
* Decode a BigInt
*/
-BigInt BigInt::decode(const byte buf[], size_t length, Base base)
+BigInt BigInt::decode(const uint8_t buf[], size_t length, Base base)
{
BigInt r;
if(base == Binary)
r.binary_decode(buf, length);
else if(base == Hexadecimal)
{
- secure_vector<byte> binary;
+ secure_vector<uint8_t> binary;
if(length % 2)
{
@@ -149,7 +149,7 @@ BigInt BigInt::decode(const byte buf[], size_t length, Base base)
throw Invalid_Argument("BigInt::decode: "
"Invalid character in decimal input");
- const byte x = Charset::char2digit(buf[i]);
+ const uint8_t x = Charset::char2digit(buf[i]);
if(x >= 10)
throw Invalid_Argument("BigInt: Invalid decimal string");
diff --git a/src/lib/math/bigint/big_io.cpp b/src/lib/math/bigint/big_io.cpp
index 779f8ccb7..088b1daf7 100644
--- a/src/lib/math/bigint/big_io.cpp
+++ b/src/lib/math/bigint/big_io.cpp
@@ -27,7 +27,7 @@ std::ostream& operator<<(std::ostream& stream, const BigInt& n)
{
if(n < 0)
stream.write("-", 1);
- const std::vector<byte> buffer = BigInt::encode(n, base);
+ const std::vector<uint8_t> buffer = BigInt::encode(n, base);
size_t skip = 0;
while(skip < buffer.size() && buffer[skip] == '0')
++skip;
diff --git a/src/lib/math/bigint/big_ops2.cpp b/src/lib/math/bigint/big_ops2.cpp
index 6e234f036..48d547af0 100644
--- a/src/lib/math/bigint/big_ops2.cpp
+++ b/src/lib/math/bigint/big_ops2.cpp
@@ -27,7 +27,7 @@ BigInt& BigInt::operator+=(const BigInt& y)
bigint_add2(mutable_data(), reg_size - 1, y.data(), y_sw);
else
{
- s32bit relative_size = bigint_cmp(data(), x_sw, y.data(), y_sw);
+ int32_t relative_size = bigint_cmp(data(), x_sw, y.data(), y_sw);
if(relative_size < 0)
{
@@ -55,7 +55,7 @@ BigInt& BigInt::operator-=(const BigInt& y)
{
const size_t x_sw = sig_words(), y_sw = y.sig_words();
- s32bit relative_size = bigint_cmp(data(), x_sw, y.data(), y_sw);
+ int32_t relative_size = bigint_cmp(data(), x_sw, y.data(), y_sw);
const size_t reg_size = std::max(x_sw, y_sw) + 1;
grow_to(reg_size);
diff --git a/src/lib/math/bigint/big_ops3.cpp b/src/lib/math/bigint/big_ops3.cpp
index 24927b4fc..a864fa96c 100644
--- a/src/lib/math/bigint/big_ops3.cpp
+++ b/src/lib/math/bigint/big_ops3.cpp
@@ -27,7 +27,7 @@ BigInt operator+(const BigInt& x, const BigInt& y)
bigint_add3(z.mutable_data(), x.data(), x_sw, y.data(), y_sw);
else
{
- s32bit relative_size = bigint_cmp(x.data(), x_sw, y.data(), y_sw);
+ int32_t relative_size = bigint_cmp(x.data(), x_sw, y.data(), y_sw);
if(relative_size < 0)
{
@@ -50,7 +50,7 @@ BigInt operator-(const BigInt& x, const BigInt& y)
{
const size_t x_sw = x.sig_words(), y_sw = y.sig_words();
- s32bit relative_size = bigint_cmp(x.data(), x_sw, y.data(), y_sw);
+ int32_t relative_size = bigint_cmp(x.data(), x_sw, y.data(), y_sw);
BigInt z(BigInt::Positive, std::max(x_sw, y_sw) + 1);
diff --git a/src/lib/math/bigint/big_rand.cpp b/src/lib/math/bigint/big_rand.cpp
index 73f3cf070..506e9776a 100644
--- a/src/lib/math/bigint/big_rand.cpp
+++ b/src/lib/math/bigint/big_rand.cpp
@@ -25,7 +25,7 @@ void BigInt::randomize(RandomNumberGenerator& rng,
}
else
{
- secure_vector<byte> array = rng.random_vec(round_up(bitsize, 8) / 8);
+ secure_vector<uint8_t> array = rng.random_vec(round_up(bitsize, 8) / 8);
// Always cut unwanted bits
if(bitsize % 8)
diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp
index 2acfabb99..a91a685e0 100644
--- a/src/lib/math/bigint/bigint.cpp
+++ b/src/lib/math/bigint/bigint.cpp
@@ -17,12 +17,12 @@ namespace Botan {
/*
* Construct a BigInt from a regular number
*/
-BigInt::BigInt(u64bit n)
+BigInt::BigInt(uint64_t n)
{
if(n == 0)
return;
- const size_t limbs_needed = sizeof(u64bit) / sizeof(word);
+ const size_t limbs_needed = sizeof(uint64_t) / sizeof(word);
m_reg.resize(4*limbs_needed);
for(size_t i = 0; i != limbs_needed; ++i)
@@ -69,7 +69,7 @@ BigInt::BigInt(const std::string& str)
base = Hexadecimal;
}
- *this = decode(reinterpret_cast<const byte*>(str.data()) + markers,
+ *this = decode(reinterpret_cast<const uint8_t*>(str.data()) + markers,
str.length() - markers, base);
if(negative) set_sign(Negative);
@@ -79,7 +79,7 @@ BigInt::BigInt(const std::string& str)
/*
* Construct a BigInt from an encoded BigInt
*/
-BigInt::BigInt(const byte input[], size_t length, Base base)
+BigInt::BigInt(const uint8_t input[], size_t length, Base base)
{
*this = decode(input, length, base);
}
@@ -95,7 +95,7 @@ BigInt::BigInt(RandomNumberGenerator& rng, size_t bits, bool set_high_bit)
/*
* Comparison Function
*/
-s32bit BigInt::cmp(const BigInt& other, bool check_signs) const
+int32_t BigInt::cmp(const BigInt& other, bool check_signs) const
{
if(check_signs)
{
@@ -117,35 +117,35 @@ s32bit BigInt::cmp(const BigInt& other, bool check_signs) const
/*
* Return bits {offset...offset+length}
*/
-u32bit BigInt::get_substring(size_t offset, size_t length) const
+uint32_t BigInt::get_substring(size_t offset, size_t length) const
{
if(length > 32)
throw Invalid_Argument("BigInt::get_substring: Substring size too big");
- u64bit piece = 0;
+ uint64_t piece = 0;
for(size_t i = 0; i != 8; ++i)
{
- const byte part = byte_at((offset / 8) + (7-i));
+ const uint8_t part = byte_at((offset / 8) + (7-i));
piece = (piece << 8) | part;
}
- const u64bit mask = (static_cast<u64bit>(1) << length) - 1;
+ const uint64_t mask = (static_cast<uint64_t>(1) << length) - 1;
const size_t shift = (offset % 8);
- return static_cast<u32bit>((piece >> shift) & mask);
+ return static_cast<uint32_t>((piece >> shift) & mask);
}
/*
-* Convert this number to a u32bit, if possible
+* Convert this number to a uint32_t, if possible
*/
-u32bit BigInt::to_u32bit() const
+uint32_t BigInt::to_u32bit() const
{
if(is_negative())
throw Encoding_Error("BigInt::to_u32bit: Number is negative");
if(bits() > 32)
throw Encoding_Error("BigInt::to_u32bit: Number is too big to convert");
- u32bit out = 0;
+ uint32_t out = 0;
for(size_t i = 0; i != 4; ++i)
out = (out << 8) | byte_at(3-i);
return out;
@@ -267,7 +267,7 @@ void BigInt::grow_to(size_t n)
/*
* Encode this number into bytes
*/
-void BigInt::binary_encode(byte output[]) const
+void BigInt::binary_encode(uint8_t output[]) const
{
const size_t sig_bytes = bytes();
for(size_t i = 0; i != sig_bytes; ++i)
@@ -277,7 +277,7 @@ void BigInt::binary_encode(byte output[]) const
/*
* Set this number to the value in buf
*/
-void BigInt::binary_decode(const byte buf[], size_t length)
+void BigInt::binary_decode(const uint8_t buf[], size_t length)
{
const size_t WORD_BYTES = sizeof(word);
diff --git a/src/lib/math/bigint/bigint.h b/src/lib/math/bigint/bigint.h
index a61bee39c..42fe60e41 100644
--- a/src/lib/math/bigint/bigint.h
+++ b/src/lib/math/bigint/bigint.h
@@ -48,7 +48,7 @@ class BOTAN_DLL BigInt
* Create BigInt from 64 bit integer
* @param n initial value of this BigInt
*/
- BigInt(u64bit n);
+ BigInt(uint64_t n);
/**
* Copy Constructor
@@ -71,7 +71,7 @@ class BOTAN_DLL BigInt
* @param length size of buf
* @param base is the number base of the integer in buf
*/
- BigInt(const byte buf[], size_t length, Base base = Binary);
+ BigInt(const uint8_t buf[], size_t length, Base base = Binary);
/**
* \brief Create a random BigInt of the specified size
@@ -223,7 +223,7 @@ class BOTAN_DLL BigInt
* @result if (this<n) return -1, if (this>n) return 1, if both
* values are identical return 0 [like Perl's <=> operator]
*/
- s32bit cmp(const BigInt& n, bool check_signs = true) const;
+ int32_t cmp(const BigInt& n, bool check_signs = true) const;
/**
* Test if the integer has an even value
@@ -308,20 +308,20 @@ class BOTAN_DLL BigInt
* @result the integer extracted from the register starting at
* offset with specified length
*/
- u32bit get_substring(size_t offset, size_t length) const;
+ uint32_t get_substring(size_t offset, size_t length) const;
/**
- * Convert this value into a u32bit, if it is in the range
+ * Convert this value into a uint32_t, if it is in the range
* [0 ... 2**32-1], or otherwise throw an exception.
- * @result the value as a u32bit if conversion is possible
+ * @result the value as a uint32_t if conversion is possible
*/
- u32bit to_u32bit() const;
+ uint32_t to_u32bit() const;
/**
* @param n the offset to get a byte from
* @result byte at offset n
*/
- byte byte_at(size_t n) const
+ uint8_t byte_at(size_t n) const
{
return get_byte(sizeof(word) - (n % sizeof(word)) - 1,
word_at(n / sizeof(word)));
@@ -450,20 +450,20 @@ class BOTAN_DLL BigInt
* Store BigInt-value in a given byte array
* @param buf destination byte array for the integer value
*/
- void binary_encode(byte buf[]) const;
+ void binary_encode(uint8_t buf[]) const;
/**
* Read integer value from a byte array with given size
* @param buf byte array buffer containing the integer
* @param length size of buf
*/
- void binary_decode(const byte buf[], size_t length);
+ void binary_decode(const uint8_t buf[], size_t length);
/**
- * Read integer value from a byte array (secure_vector<byte>)
+ * Read integer value from a byte array (secure_vector<uint8_t>)
* @param buf the array to load from
*/
- void binary_decode(const secure_vector<byte>& buf)
+ void binary_decode(const secure_vector<uint8_t>& buf)
{
binary_decode(buf.data(), buf.size());
}
@@ -502,7 +502,7 @@ class BOTAN_DLL BigInt
* @param base number-base of resulting byte array representation
* @result secure_vector of bytes containing the integer with given base
*/
- static std::vector<byte> encode(const BigInt& n, Base base = Binary);
+ static std::vector<uint8_t> encode(const BigInt& n, Base base = Binary);
/**
* Encode the integer value from a BigInt to a secure_vector of bytes
@@ -510,7 +510,7 @@ class BOTAN_DLL BigInt
* @param base number-base of resulting byte array representation
* @result secure_vector of bytes containing the integer with given base
*/
- static secure_vector<byte> encode_locked(const BigInt& n,
+ static secure_vector<uint8_t> encode_locked(const BigInt& n,
Base base = Binary);
/**
@@ -520,7 +520,7 @@ class BOTAN_DLL BigInt
* @param n the BigInt to use as integer source
* @param base number-base of resulting byte array representation
*/
- static void encode(byte buf[], const BigInt& n, Base base = Binary);
+ static void encode(uint8_t buf[], const BigInt& n, Base base = Binary);
/**
* Create a BigInt from an integer in a byte array
@@ -529,7 +529,7 @@ class BOTAN_DLL BigInt
* @param base number-base of the integer in buf
* @result BigInt representing the integer in the byte array
*/
- static BigInt decode(const byte buf[], size_t length,
+ static BigInt decode(const uint8_t buf[], size_t length,
Base base = Binary);
/**
@@ -538,7 +538,7 @@ class BOTAN_DLL BigInt
* @param base number-base of the integer in buf
* @result BigInt representing the integer in the byte array
*/
- static BigInt decode(const secure_vector<byte>& buf,
+ static BigInt decode(const secure_vector<uint8_t>& buf,
Base base = Binary)
{
return BigInt::decode(buf.data(), buf.size(), base);
@@ -550,7 +550,7 @@ class BOTAN_DLL BigInt
* @param base number-base of the integer in buf
* @result BigInt representing the integer in the byte array
*/
- static BigInt decode(const std::vector<byte>& buf,
+ static BigInt decode(const std::vector<uint8_t>& buf,
Base base = Binary)
{
return BigInt::decode(buf.data(), buf.size(), base);
@@ -559,21 +559,21 @@ class BOTAN_DLL BigInt
/**
* Encode a BigInt to a byte array according to IEEE 1363
* @param n the BigInt to encode
- * @param bytes the length of the resulting secure_vector<byte>
- * @result a secure_vector<byte> containing the encoded BigInt
+ * @param bytes the length of the resulting secure_vector<uint8_t>
+ * @result a secure_vector<uint8_t> containing the encoded BigInt
*/
- static secure_vector<byte> encode_1363(const BigInt& n, size_t bytes);
+ static secure_vector<uint8_t> encode_1363(const BigInt& n, size_t bytes);
- static void encode_1363(byte out[], size_t bytes, const BigInt& n);
+ static void encode_1363(uint8_t out[], size_t bytes, const BigInt& n);
/**
* Encode two BigInt to a byte array according to IEEE 1363
* @param n1 the first BigInt to encode
* @param n2 the second BigInt to encode
* @param bytes the length of the encoding of each single BigInt
- * @result a secure_vector<byte> containing the concatenation of the two encoded BigInt
+ * @result a secure_vector<uint8_t> containing the concatenation of the two encoded BigInt
*/
- static secure_vector<byte> encode_fixed_length_int_pair(const BigInt& n1, const BigInt& n2, size_t bytes);
+ static secure_vector<uint8_t> encode_fixed_length_int_pair(const BigInt& n1, const BigInt& n2, size_t bytes);
private:
secure_vector<word> m_reg;
diff --git a/src/lib/math/bigint/divide.cpp b/src/lib/math/bigint/divide.cpp
index ec4ba3f9f..13696d6d3 100644
--- a/src/lib/math/bigint/divide.cpp
+++ b/src/lib/math/bigint/divide.cpp
@@ -69,7 +69,7 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r)
r.set_sign(BigInt::Positive);
y.set_sign(BigInt::Positive);
- s32bit compare = r.cmp(y);
+ int32_t compare = r.cmp(y);
if(compare == 0)
{
diff --git a/src/lib/math/ec_gfp/curve_nistp.cpp b/src/lib/math/ec_gfp/curve_nistp.cpp
index 176409dbf..fb94a81d2 100644
--- a/src/lib/math/ec_gfp/curve_nistp.cpp
+++ b/src/lib/math/ec_gfp/curve_nistp.cpp
@@ -89,12 +89,12 @@ namespace {
* Treating this MPI as a sequence of 32-bit words in big-endian
* order, return word i (or 0 if out of range)
*/
-inline u32bit get_u32bit(const BigInt& x, size_t i)
+inline uint32_t get_uint32_t(const BigInt& x, size_t i)
{
#if (BOTAN_MP_WORD_BITS == 32)
return x.word_at(i);
#elif (BOTAN_MP_WORD_BITS == 64)
- return static_cast<u32bit>(x.word_at(i/2) >> ((i % 2)*32));
+ return static_cast<uint32_t>(x.word_at(i/2) >> ((i % 2)*32));
#else
#error "Not implemented"
#endif
@@ -105,9 +105,9 @@ inline u32bit get_u32bit(const BigInt& x, size_t i)
* order, set word i to the value x
*/
template<typename T>
-inline void set_u32bit(BigInt& x, size_t i, T v_in)
+inline void set_uint32_t(BigInt& x, size_t i, T v_in)
{
- const u32bit v = static_cast<u32bit>(v_in);
+ const uint32_t v = static_cast<uint32_t>(v_in);
#if (BOTAN_MP_WORD_BITS == 32)
x.set_word_at(i, v);
#elif (BOTAN_MP_WORD_BITS == 64)
@@ -129,56 +129,56 @@ const BigInt& prime_p192()
void redc_p192(BigInt& x, secure_vector<word>& ws)
{
- const u32bit X6 = get_u32bit(x, 6);
- const u32bit X7 = get_u32bit(x, 7);
- const u32bit X8 = get_u32bit(x, 8);
- const u32bit X9 = get_u32bit(x, 9);
- const u32bit X10 = get_u32bit(x, 10);
- const u32bit X11 = get_u32bit(x, 11);
+ const uint32_t X6 = get_uint32_t(x, 6);
+ const uint32_t X7 = get_uint32_t(x, 7);
+ const uint32_t X8 = get_uint32_t(x, 8);
+ const uint32_t X9 = get_uint32_t(x, 9);
+ const uint32_t X10 = get_uint32_t(x, 10);
+ const uint32_t X11 = get_uint32_t(x, 11);
x.mask_bits(192);
- u64bit S = 0;
+ uint64_t S = 0;
- S += get_u32bit(x, 0);
+ S += get_uint32_t(x, 0);
S += X6;
S += X10;
- set_u32bit(x, 0, S);
+ set_uint32_t(x, 0, S);
S >>= 32;
- S += get_u32bit(x, 1);
+ S += get_uint32_t(x, 1);
S += X7;
S += X11;
- set_u32bit(x, 1, S);
+ set_uint32_t(x, 1, S);
S >>= 32;
- S += get_u32bit(x, 2);
+ S += get_uint32_t(x, 2);
S += X6;
S += X8;
S += X10;
- set_u32bit(x, 2, S);
+ set_uint32_t(x, 2, S);
S >>= 32;
- S += get_u32bit(x, 3);
+ S += get_uint32_t(x, 3);
S += X7;
S += X9;
S += X11;
- set_u32bit(x, 3, S);
+ set_uint32_t(x, 3, S);
S >>= 32;
- S += get_u32bit(x, 4);
+ S += get_uint32_t(x, 4);
S += X8;
S += X10;
- set_u32bit(x, 4, S);
+ set_uint32_t(x, 4, S);
S >>= 32;
- S += get_u32bit(x, 5);
+ S += get_uint32_t(x, 5);
S += X9;
S += X11;
- set_u32bit(x, 5, S);
+ set_uint32_t(x, 5, S);
S >>= 32;
- set_u32bit(x, 6, S);
+ set_uint32_t(x, 6, S);
// No underflow possible
@@ -193,13 +193,13 @@ const BigInt& prime_p224()
void redc_p224(BigInt& x, secure_vector<word>& ws)
{
- const u32bit X7 = get_u32bit(x, 7);
- const u32bit X8 = get_u32bit(x, 8);
- const u32bit X9 = get_u32bit(x, 9);
- const u32bit X10 = get_u32bit(x, 10);
- const u32bit X11 = get_u32bit(x, 11);
- const u32bit X12 = get_u32bit(x, 12);
- const u32bit X13 = get_u32bit(x, 13);
+ const uint32_t X7 = get_uint32_t(x, 7);
+ const uint32_t X8 = get_uint32_t(x, 8);
+ const uint32_t X9 = get_uint32_t(x, 9);
+ const uint32_t X10 = get_uint32_t(x, 10);
+ const uint32_t X11 = get_uint32_t(x, 11);
+ const uint32_t X12 = get_uint32_t(x, 12);
+ const uint32_t X13 = get_uint32_t(x, 13);
x.mask_bits(224);
@@ -207,56 +207,56 @@ void redc_p224(BigInt& x, secure_vector<word>& ws)
int64_t S = 0;
- S += get_u32bit(x, 0);
+ S += get_uint32_t(x, 0);
S += 1;
S -= X7;
S -= X11;
- set_u32bit(x, 0, S);
+ set_uint32_t(x, 0, S);
S >>= 32;
- S += get_u32bit(x, 1);
+ S += get_uint32_t(x, 1);
S -= X8;
S -= X12;
- set_u32bit(x, 1, S);
+ set_uint32_t(x, 1, S);
S >>= 32;
- S += get_u32bit(x, 2);
+ S += get_uint32_t(x, 2);
S -= X9;
S -= X13;
- set_u32bit(x, 2, S);
+ set_uint32_t(x, 2, S);
S >>= 32;
- S += get_u32bit(x, 3);
+ S += get_uint32_t(x, 3);
S += 0xFFFFFFFF;
S += X7;
S += X11;
S -= X10;
- set_u32bit(x, 3, S);
+ set_uint32_t(x, 3, S);
S >>= 32;
- S += get_u32bit(x, 4);
+ S += get_uint32_t(x, 4);
S += 0xFFFFFFFF;
S += X8;
S += X12;
S -= X11;
- set_u32bit(x, 4, S);
+ set_uint32_t(x, 4, S);
S >>= 32;
- S += get_u32bit(x, 5);
+ S += get_uint32_t(x, 5);
S += 0xFFFFFFFF;
S += X9;
S += X13;
S -= X12;
- set_u32bit(x, 5, S);
+ set_uint32_t(x, 5, S);
S >>= 32;
- S += get_u32bit(x, 6);
+ S += get_uint32_t(x, 6);
S += 0xFFFFFFFF;
S += X10;
S -= X13;
- set_u32bit(x, 6, S);
+ set_uint32_t(x, 6, S);
S >>= 32;
- set_u32bit(x, 7, S);
+ set_uint32_t(x, 7, S);
BOTAN_ASSERT_EQUAL(S >> 32, 0, "No underflow");
@@ -271,14 +271,14 @@ const BigInt& prime_p256()
void redc_p256(BigInt& x, secure_vector<word>& ws)
{
- const u32bit X8 = get_u32bit(x, 8);
- const u32bit X9 = get_u32bit(x, 9);
- const u32bit X10 = get_u32bit(x, 10);
- const u32bit X11 = get_u32bit(x, 11);
- const u32bit X12 = get_u32bit(x, 12);
- const u32bit X13 = get_u32bit(x, 13);
- const u32bit X14 = get_u32bit(x, 14);
- const u32bit X15 = get_u32bit(x, 15);
+ const uint32_t X8 = get_uint32_t(x, 8);
+ const uint32_t X9 = get_uint32_t(x, 9);
+ const uint32_t X10 = get_uint32_t(x, 10);
+ const uint32_t X11 = get_uint32_t(x, 11);
+ const uint32_t X12 = get_uint32_t(x, 12);
+ const uint32_t X13 = get_uint32_t(x, 13);
+ const uint32_t X14 = get_uint32_t(x, 14);
+ const uint32_t X15 = get_uint32_t(x, 15);
x.mask_bits(256);
@@ -286,7 +286,7 @@ void redc_p256(BigInt& x, secure_vector<word>& ws)
// Adds 6 * P-256 to prevent underflow
- S = get_u32bit(x, 0);
+ S = get_uint32_t(x, 0);
S += 0xFFFFFFFA;
S += X8;
S += X9;
@@ -294,10 +294,10 @@ void redc_p256(BigInt& x, secure_vector<word>& ws)
S -= X12;
S -= X13;
S -= X14;
- set_u32bit(x, 0, S);
+ set_uint32_t(x, 0, S);
S >>= 32;
- S += get_u32bit(x, 1);
+ S += get_uint32_t(x, 1);
S += 0xFFFFFFFF;
S += X9;
S += X10;
@@ -305,20 +305,20 @@ void redc_p256(BigInt& x, secure_vector<word>& ws)
S -= X13;
S -= X14;
S -= X15;
- set_u32bit(x, 1, S);
+ set_uint32_t(x, 1, S);
S >>= 32;
- S += get_u32bit(x, 2);
+ S += get_uint32_t(x, 2);
S += 0xFFFFFFFF;
S += X10;
S += X11;
S -= X13;
S -= X14;
S -= X15;
- set_u32bit(x, 2, S);
+ set_uint32_t(x, 2, S);
S >>= 32;
- S += get_u32bit(x, 3);
+ S += get_uint32_t(x, 3);
S += 5;
S += X11;
S += X11;
@@ -328,10 +328,10 @@ void redc_p256(BigInt& x, secure_vector<word>& ws)
S -= X15;
S -= X8;
S -= X9;
- set_u32bit(x, 3, S);
+ set_uint32_t(x, 3, S);
S >>= 32;
- S += get_u32bit(x, 4);
+ S += get_uint32_t(x, 4);
S += X12;
S += X12;
S += X13;
@@ -339,10 +339,10 @@ void redc_p256(BigInt& x, secure_vector<word>& ws)
S += X14;
S -= X9;
S -= X10;
- set_u32bit(x, 4, S);
+ set_uint32_t(x, 4, S);
S >>= 32;
- S += get_u32bit(x, 5);
+ S += get_uint32_t(x, 5);
S += X13;
S += X13;
S += X14;
@@ -350,10 +350,10 @@ void redc_p256(BigInt& x, secure_vector<word>& ws)
S += X15;
S -= X10;
S -= X11;
- set_u32bit(x, 5, S);
+ set_uint32_t(x, 5, S);
S >>= 32;
- S += get_u32bit(x, 6);
+ S += get_uint32_t(x, 6);
S += 6;
S += X14;
S += X14;
@@ -363,10 +363,10 @@ void redc_p256(BigInt& x, secure_vector<word>& ws)
S += X13;
S -= X8;
S -= X9;
- set_u32bit(x, 6, S);
+ set_uint32_t(x, 6, S);
S >>= 32;
- S += get_u32bit(x, 7);
+ S += get_uint32_t(x, 7);
S += 0xFFFFFFFA;
S += X15;
S += X15;
@@ -376,11 +376,11 @@ void redc_p256(BigInt& x, secure_vector<word>& ws)
S -= X11;
S -= X12;
S -= X13;
- set_u32bit(x, 7, S);
+ set_uint32_t(x, 7, S);
S >>= 32;
S += 5;
- set_u32bit(x, 8, S);
+ set_uint32_t(x, 8, S);
BOTAN_ASSERT_EQUAL(S >> 32, 0, "No underflow");
@@ -414,51 +414,51 @@ const BigInt& prime_p384()
void redc_p384(BigInt& x, secure_vector<word>& ws)
{
- const u32bit X12 = get_u32bit(x, 12);
- const u32bit X13 = get_u32bit(x, 13);
- const u32bit X14 = get_u32bit(x, 14);
- const u32bit X15 = get_u32bit(x, 15);
- const u32bit X16 = get_u32bit(x, 16);
- const u32bit X17 = get_u32bit(x, 17);
- const u32bit X18 = get_u32bit(x, 18);
- const u32bit X19 = get_u32bit(x, 19);
- const u32bit X20 = get_u32bit(x, 20);
- const u32bit X21 = get_u32bit(x, 21);
- const u32bit X22 = get_u32bit(x, 22);
- const u32bit X23 = get_u32bit(x, 23);
+ const uint32_t X12 = get_uint32_t(x, 12);
+ const uint32_t X13 = get_uint32_t(x, 13);
+ const uint32_t X14 = get_uint32_t(x, 14);
+ const uint32_t X15 = get_uint32_t(x, 15);
+ const uint32_t X16 = get_uint32_t(x, 16);
+ const uint32_t X17 = get_uint32_t(x, 17);
+ const uint32_t X18 = get_uint32_t(x, 18);
+ const uint32_t X19 = get_uint32_t(x, 19);
+ const uint32_t X20 = get_uint32_t(x, 20);
+ const uint32_t X21 = get_uint32_t(x, 21);
+ const uint32_t X22 = get_uint32_t(x, 22);
+ const uint32_t X23 = get_uint32_t(x, 23);
x.mask_bits(384);
int64_t S = 0;
// One copy of P-384 is added to prevent underflow
- S = get_u32bit(x, 0);
+ S = get_uint32_t(x, 0);
S += 0xFFFFFFFF;
S += X12;
S += X21;
S += X20;
S -= X23;
- set_u32bit(x, 0, S);
+ set_uint32_t(x, 0, S);
S >>= 32;
- S += get_u32bit(x, 1);
+ S += get_uint32_t(x, 1);
S += X13;
S += X22;
S += X23;
S -= X12;
S -= X20;
- set_u32bit(x, 1, S);
+ set_uint32_t(x, 1, S);
S >>= 32;
- S += get_u32bit(x, 2);
+ S += get_uint32_t(x, 2);
S += X14;
S += X23;
S -= X13;
S -= X21;
- set_u32bit(x, 2, S);
+ set_uint32_t(x, 2, S);
S >>= 32;
- S += get_u32bit(x, 3);
+ S += get_uint32_t(x, 3);
S += 0xFFFFFFFF;
S += X15;
S += X12;
@@ -467,10 +467,10 @@ void redc_p384(BigInt& x, secure_vector<word>& ws)
S -= X14;
S -= X22;
S -= X23;
- set_u32bit(x, 3, S);
+ set_uint32_t(x, 3, S);
S >>= 32;
- S += get_u32bit(x, 4);
+ S += get_uint32_t(x, 4);
S += 0xFFFFFFFE;
S += X21;
S += X21;
@@ -482,10 +482,10 @@ void redc_p384(BigInt& x, secure_vector<word>& ws)
S -= X15;
S -= X23;
S -= X23;
- set_u32bit(x, 4, S);
+ set_uint32_t(x, 4, S);
S >>= 32;
- S += get_u32bit(x, 5);
+ S += get_uint32_t(x, 5);
S += 0xFFFFFFFF;
S += X22;
S += X22;
@@ -495,10 +495,10 @@ void redc_p384(BigInt& x, secure_vector<word>& ws)
S += X21;
S += X23;
S -= X16;
- set_u32bit(x, 5, S);
+ set_uint32_t(x, 5, S);
S >>= 32;
- S += get_u32bit(x, 6);
+ S += get_uint32_t(x, 6);
S += 0xFFFFFFFF;
S += X23;
S += X23;
@@ -507,56 +507,56 @@ void redc_p384(BigInt& x, secure_vector<word>& ws)
S += X14;
S += X22;
S -= X17;
- set_u32bit(x, 6, S);
+ set_uint32_t(x, 6, S);
S >>= 32;
- S += get_u32bit(x, 7);
+ S += get_uint32_t(x, 7);
S += 0xFFFFFFFF;
S += X19;
S += X16;
S += X15;
S += X23;
S -= X18;
- set_u32bit(x, 7, S);
+ set_uint32_t(x, 7, S);
S >>= 32;
- S += get_u32bit(x, 8);
+ S += get_uint32_t(x, 8);
S += 0xFFFFFFFF;
S += X20;
S += X17;
S += X16;
S -= X19;
- set_u32bit(x, 8, S);
+ set_uint32_t(x, 8, S);
S >>= 32;
- S += get_u32bit(x, 9);
+ S += get_uint32_t(x, 9);
S += 0xFFFFFFFF;
S += X21;
S += X18;
S += X17;
S -= X20;
- set_u32bit(x, 9, S);
+ set_uint32_t(x, 9, S);
S >>= 32;
- S += get_u32bit(x, 10);
+ S += get_uint32_t(x, 10);
S += 0xFFFFFFFF;
S += X22;
S += X19;
S += X18;
S -= X21;
- set_u32bit(x, 10, S);
+ set_uint32_t(x, 10, S);
S >>= 32;
- S += get_u32bit(x, 11);
+ S += get_uint32_t(x, 11);
S += 0xFFFFFFFF;
S += X23;
S += X20;
S += X19;
S -= X22;
- set_u32bit(x, 11, S);
+ set_uint32_t(x, 11, S);
S >>= 32;
BOTAN_ASSERT_EQUAL(S >> 32, 0, "No underflow");
- set_u32bit(x, 12, S);
+ set_uint32_t(x, 12, S);
#if 0
if(S >= 2)
diff --git a/src/lib/math/ec_gfp/point_gfp.cpp b/src/lib/math/ec_gfp/point_gfp.cpp
index f15911db0..bb446566e 100644
--- a/src/lib/math/ec_gfp/point_gfp.cpp
+++ b/src/lib/math/ec_gfp/point_gfp.cpp
@@ -406,7 +406,7 @@ PointGFp Blinded_Point_Multiply::blinded_multiply(const BigInt& scalar_in,
if(windows > 0)
{
windows--;
- const u32bit nibble = scalar.get_substring(windows*m_h, m_h);
+ const uint32_t nibble = scalar.get_substring(windows*m_h, m_h);
R.add(m_U[nibble], m_ws);
/*
@@ -421,7 +421,7 @@ PointGFp Blinded_Point_Multiply::blinded_multiply(const BigInt& scalar_in,
for(size_t i = 0; i != m_h; ++i)
R.mult2(m_ws);
- const u32bit inner_nibble = scalar.get_substring((windows-1)*m_h, m_h);
+ const uint32_t inner_nibble = scalar.get_substring((windows-1)*m_h, m_h);
R.add(m_U[inner_nibble], m_ws);
windows--;
}
@@ -513,22 +513,22 @@ bool PointGFp::operator==(const PointGFp& other) const
}
// encoding and decoding
-secure_vector<byte> EC2OSP(const PointGFp& point, byte format)
+secure_vector<uint8_t> EC2OSP(const PointGFp& point, uint8_t format)
{
if(point.is_zero())
- return secure_vector<byte>(1); // single 0 byte
+ return secure_vector<uint8_t>(1); // single 0 byte
const size_t p_bytes = point.get_curve().get_p().bytes();
BigInt x = point.get_affine_x();
BigInt y = point.get_affine_y();
- secure_vector<byte> bX = BigInt::encode_1363(x, p_bytes);
- secure_vector<byte> bY = BigInt::encode_1363(y, p_bytes);
+ secure_vector<uint8_t> bX = BigInt::encode_1363(x, p_bytes);
+ secure_vector<uint8_t> bY = BigInt::encode_1363(y, p_bytes);
if(format == PointGFp::UNCOMPRESSED)
{
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
result.push_back(0x04);
result += bX;
@@ -538,8 +538,8 @@ secure_vector<byte> EC2OSP(const PointGFp& point, byte format)
}
else if(format == PointGFp::COMPRESSED)
{
- secure_vector<byte> result;
- result.push_back(0x02 | static_cast<byte>(y.get_bit(0)));
+ secure_vector<uint8_t> result;
+ result.push_back(0x02 | static_cast<uint8_t>(y.get_bit(0)));
result += bX;
@@ -547,8 +547,8 @@ secure_vector<byte> EC2OSP(const PointGFp& point, byte format)
}
else if(format == PointGFp::HYBRID)
{
- secure_vector<byte> result;
- result.push_back(0x06 | static_cast<byte>(y.get_bit(0)));
+ secure_vector<uint8_t> result;
+ result.push_back(0x06 | static_cast<uint8_t>(y.get_bit(0)));
result += bX;
result += bY;
@@ -587,13 +587,13 @@ BigInt decompress_point(bool yMod2,
}
-PointGFp OS2ECP(const byte data[], size_t data_len,
+PointGFp OS2ECP(const uint8_t data[], size_t data_len,
const CurveGFp& curve)
{
if(data_len <= 1)
return PointGFp(curve); // return zero
- const byte pc = data[0];
+ const uint8_t pc = data[0];
BigInt x, y;
diff --git a/src/lib/math/ec_gfp/point_gfp.h b/src/lib/math/ec_gfp/point_gfp.h
index c64963683..6f4c7e5f9 100644
--- a/src/lib/math/ec_gfp/point_gfp.h
+++ b/src/lib/math/ec_gfp/point_gfp.h
@@ -274,13 +274,13 @@ inline PointGFp operator*(const PointGFp& point, const BigInt& scalar)
}
// encoding and decoding
-secure_vector<byte> BOTAN_DLL EC2OSP(const PointGFp& point, byte format);
+secure_vector<uint8_t> BOTAN_DLL EC2OSP(const PointGFp& point, uint8_t format);
-PointGFp BOTAN_DLL OS2ECP(const byte data[], size_t data_len,
+PointGFp BOTAN_DLL OS2ECP(const uint8_t data[], size_t data_len,
const CurveGFp& curve);
template<typename Alloc>
-PointGFp OS2ECP(const std::vector<byte, Alloc>& data, const CurveGFp& curve)
+PointGFp OS2ECP(const std::vector<uint8_t, Alloc>& data, const CurveGFp& curve)
{ return OS2ECP(data.data(), data.size(), curve); }
/**
diff --git a/src/lib/math/mp/mp_core.cpp b/src/lib/math/mp/mp_core.cpp
index 2a0b08f67..ff4efd945 100644
--- a/src/lib/math/mp/mp_core.cpp
+++ b/src/lib/math/mp/mp_core.cpp
@@ -375,7 +375,7 @@ void bigint_shr2(word y[], const word x[], size_t x_size,
/*
* Compare two MP integers
*/
-s32bit bigint_cmp(const word x[], size_t x_size,
+int32_t bigint_cmp(const word x[], size_t x_size,
const word y[], size_t y_size)
{
if(x_size < y_size) { return (-bigint_cmp(y, y_size, x, x_size)); }
diff --git a/src/lib/math/mp/mp_core.h b/src/lib/math/mp/mp_core.h
index c4ce005ba..a22d3b6ad 100644
--- a/src/lib/math/mp/mp_core.h
+++ b/src/lib/math/mp/mp_core.h
@@ -150,7 +150,7 @@ void bigint_monty_sqr(BigInt& z, const BigInt& x,
/**
* Compare x and y
*/
-s32bit bigint_cmp(const word x[], size_t x_size,
+int32_t bigint_cmp(const word x[], size_t x_size,
const word y[], size_t y_size);
/**
diff --git a/src/lib/math/mp/mp_karat.cpp b/src/lib/math/mp/mp_karat.cpp
index 62a52b88c..994100c9b 100644
--- a/src/lib/math/mp/mp_karat.cpp
+++ b/src/lib/math/mp/mp_karat.cpp
@@ -75,8 +75,8 @@ void karatsuba_mul(word z[], const word x[], const word y[], size_t N,
word* z0 = z;
word* z1 = z + N;
- const s32bit cmp0 = bigint_cmp(x0, N2, x1, N2);
- const s32bit cmp1 = bigint_cmp(y1, N2, y0, N2);
+ const int32_t cmp0 = bigint_cmp(x0, N2, x1, N2);
+ const int32_t cmp1 = bigint_cmp(y1, N2, y0, N2);
clear_mem(workspace, 2*N);
@@ -143,7 +143,7 @@ void karatsuba_sqr(word z[], const word x[], size_t N, word workspace[])
word* z0 = z;
word* z1 = z + N;
- const s32bit cmp = bigint_cmp(x0, N2, x1, N2);
+ const int32_t cmp = bigint_cmp(x0, N2, x1, N2);
clear_mem(workspace, 2*N);
diff --git a/src/lib/math/mp/mp_madd.h b/src/lib/math/mp/mp_madd.h
index 0567622d9..2fa1d88ce 100644
--- a/src/lib/math/mp/mp_madd.h
+++ b/src/lib/math/mp/mp_madd.h
@@ -15,13 +15,13 @@
namespace Botan {
#if (BOTAN_MP_WORD_BITS == 8)
- typedef u16bit dword;
+ typedef uint16_t dword;
#define BOTAN_HAS_MP_DWORD
#elif (BOTAN_MP_WORD_BITS == 16)
- typedef u32bit dword;
+ typedef uint32_t dword;
#define BOTAN_HAS_MP_DWORD
#elif (BOTAN_MP_WORD_BITS == 32)
- typedef u64bit dword;
+ typedef uint64_t dword;
#define BOTAN_HAS_MP_DWORD
#elif (BOTAN_MP_WORD_BITS == 64)
#if defined(BOTAN_TARGET_HAS_NATIVE_UINT128)
diff --git a/src/lib/math/mp/mp_types.h b/src/lib/math/mp/mp_types.h
index 69dc911fd..0b5c5055e 100644
--- a/src/lib/math/mp/mp_types.h
+++ b/src/lib/math/mp/mp_types.h
@@ -13,13 +13,13 @@
namespace Botan {
#if (BOTAN_MP_WORD_BITS == 8)
- typedef byte word;
+ typedef uint8_t word;
#elif (BOTAN_MP_WORD_BITS == 16)
- typedef u16bit word;
+ typedef uint16_t word;
#elif (BOTAN_MP_WORD_BITS == 32)
- typedef u32bit word;
+ typedef uint32_t word;
#elif (BOTAN_MP_WORD_BITS == 64)
- typedef u64bit word;
+ typedef uint64_t word;
#else
#error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64
#endif
diff --git a/src/lib/math/numbertheory/dsa_gen.cpp b/src/lib/math/numbertheory/dsa_gen.cpp
index 29d1fe9bc..a01810025 100644
--- a/src/lib/math/numbertheory/dsa_gen.cpp
+++ b/src/lib/math/numbertheory/dsa_gen.cpp
@@ -39,7 +39,7 @@ bool fips186_3_valid_size(size_t pbits, size_t qbits)
bool generate_dsa_primes(RandomNumberGenerator& rng,
BigInt& p, BigInt& q,
size_t pbits, size_t qbits,
- const std::vector<byte>& seed_c)
+ const std::vector<uint8_t>& seed_c)
{
if(!fips186_3_valid_size(pbits, qbits))
throw Invalid_Argument(
@@ -59,9 +59,9 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
class Seed
{
public:
- explicit Seed(const std::vector<byte>& s) : m_seed(s) {}
+ explicit Seed(const std::vector<uint8_t>& s) : m_seed(s) {}
- operator std::vector<byte>& () { return m_seed; }
+ operator std::vector<uint8_t>& () { return m_seed; }
Seed& operator++()
{
@@ -71,7 +71,7 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
return (*this);
}
private:
- std::vector<byte> m_seed;
+ std::vector<uint8_t> m_seed;
};
Seed seed(seed_c);
@@ -87,7 +87,7 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
b = (pbits-1) % (HASH_SIZE * 8);
BigInt X;
- std::vector<byte> V(HASH_SIZE * (n+1));
+ std::vector<uint8_t> V(HASH_SIZE * (n+1));
for(size_t j = 0; j != 4*pbits; ++j)
{
@@ -113,13 +113,13 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
/*
* Generate DSA Primes
*/
-std::vector<byte> generate_dsa_primes(RandomNumberGenerator& rng,
+std::vector<uint8_t> generate_dsa_primes(RandomNumberGenerator& rng,
BigInt& p, BigInt& q,
size_t pbits, size_t qbits)
{
while(true)
{
- std::vector<byte> seed(qbits / 8);
+ std::vector<uint8_t> seed(qbits / 8);
rng.randomize(seed.data(), seed.size());
if(generate_dsa_primes(rng, p, q, pbits, qbits, seed))
diff --git a/src/lib/math/numbertheory/jacobi.cpp b/src/lib/math/numbertheory/jacobi.cpp
index 0077fb10e..d3e8d7557 100644
--- a/src/lib/math/numbertheory/jacobi.cpp
+++ b/src/lib/math/numbertheory/jacobi.cpp
@@ -12,7 +12,7 @@ namespace Botan {
/*
* Calculate the Jacobi symbol
*/
-s32bit jacobi(const BigInt& a, const BigInt& n)
+int32_t jacobi(const BigInt& a, const BigInt& n)
{
if(a.is_negative())
throw Invalid_Argument("jacobi: first argument must be non-negative");
@@ -20,7 +20,7 @@ s32bit jacobi(const BigInt& a, const BigInt& n)
throw Invalid_Argument("jacobi: second argument must be odd and > 1");
BigInt x = a, y = n;
- s32bit J = 1;
+ int32_t J = 1;
while(y > 1)
{
diff --git a/src/lib/math/numbertheory/make_prm.cpp b/src/lib/math/numbertheory/make_prm.cpp
index acd187063..9443bb9a1 100644
--- a/src/lib/math/numbertheory/make_prm.cpp
+++ b/src/lib/math/numbertheory/make_prm.cpp
@@ -63,10 +63,10 @@ BigInt random_prime(RandomNumberGenerator& rng,
p += (modulo - p % modulo) + equiv;
const size_t sieve_size = std::min(bits / 2, PRIME_TABLE_SIZE);
- secure_vector<u16bit> sieve(sieve_size);
+ secure_vector<uint16_t> sieve(sieve_size);
for(size_t j = 0; j != sieve.size(); ++j)
- sieve[j] = static_cast<u16bit>(p % PRIMES[j]);
+ sieve[j] = static_cast<uint16_t>(p % PRIMES[j]);
size_t counter = 0;
while(true)
diff --git a/src/lib/math/numbertheory/numthry.cpp b/src/lib/math/numbertheory/numthry.cpp
index 71dbf6aba..4e8a5d8cc 100644
--- a/src/lib/math/numbertheory/numthry.cpp
+++ b/src/lib/math/numbertheory/numthry.cpp
@@ -449,7 +449,7 @@ bool is_prime(const BigInt& n, RandomNumberGenerator& rng,
// Fast path testing for small numbers (<= 65521)
if(n <= PRIMES[PRIME_TABLE_SIZE-1])
{
- const u16bit num = static_cast<u16bit>(n.word_at(0));
+ const uint16_t num = static_cast<uint16_t>(n.word_at(0));
return std::binary_search(PRIMES, PRIMES + PRIME_TABLE_SIZE, num);
}
diff --git a/src/lib/math/numbertheory/numthry.h b/src/lib/math/numbertheory/numthry.h
index 172c56a34..6d6991c15 100644
--- a/src/lib/math/numbertheory/numthry.h
+++ b/src/lib/math/numbertheory/numthry.h
@@ -116,7 +116,7 @@ BigInt BOTAN_DLL normalized_montgomery_inverse(const BigInt& a, const BigInt& b)
* @param n is an odd integer > 1
* @return (n / m)
*/
-s32bit BOTAN_DLL jacobi(const BigInt& a,
+int32_t BOTAN_DLL jacobi(const BigInt& a,
const BigInt& n);
/**
@@ -210,7 +210,7 @@ BigInt BOTAN_DLL random_safe_prime(RandomNumberGenerator& rng,
* @param qbits how long q will be in bits
* @return random seed used to generate this parameter set
*/
-std::vector<byte> BOTAN_DLL
+std::vector<uint8_t> BOTAN_DLL
generate_dsa_primes(RandomNumberGenerator& rng,
BigInt& p_out, BigInt& q_out,
size_t pbits, size_t qbits);
@@ -230,7 +230,7 @@ bool BOTAN_DLL
generate_dsa_primes(RandomNumberGenerator& rng,
BigInt& p_out, BigInt& q_out,
size_t pbits, size_t qbits,
- const std::vector<byte>& seed);
+ const std::vector<uint8_t>& seed);
/**
* The size of the PRIMES[] array
@@ -240,7 +240,7 @@ const size_t PRIME_TABLE_SIZE = 6541;
/**
* A const array of all primes less than 65535
*/
-extern const u16bit BOTAN_DLL PRIMES[];
+extern const uint16_t BOTAN_DLL PRIMES[];
}
diff --git a/src/lib/math/numbertheory/powm_fw.cpp b/src/lib/math/numbertheory/powm_fw.cpp
index 7d69a2602..770f345c6 100644
--- a/src/lib/math/numbertheory/powm_fw.cpp
+++ b/src/lib/math/numbertheory/powm_fw.cpp
@@ -48,7 +48,7 @@ BigInt Fixed_Window_Exponentiator::execute() const
for(size_t j = 0; j != m_window_bits; ++j)
x = m_reducer.square(x);
- const u32bit nibble = m_exp.get_substring(m_window_bits*(i-1), m_window_bits);
+ const uint32_t nibble = m_exp.get_substring(m_window_bits*(i-1), m_window_bits);
x = m_reducer.multiply(x, m_g[nibble]);
}
diff --git a/src/lib/math/numbertheory/powm_mnt.cpp b/src/lib/math/numbertheory/powm_mnt.cpp
index 546a2739a..ba7fddef2 100644
--- a/src/lib/math/numbertheory/powm_mnt.cpp
+++ b/src/lib/math/numbertheory/powm_mnt.cpp
@@ -86,7 +86,7 @@ BigInt Montgomery_Exponentiator::execute() const
x = z;
}
- const u32bit nibble = m_exp.get_substring(m_window_bits*(i-1), m_window_bits);
+ const uint32_t nibble = m_exp.get_substring(m_window_bits*(i-1), m_window_bits);
const BigInt& y = m_g[nibble];
diff --git a/src/lib/math/numbertheory/primes.cpp b/src/lib/math/numbertheory/primes.cpp
index 50229ad15..4a3eb46f2 100644
--- a/src/lib/math/numbertheory/primes.cpp
+++ b/src/lib/math/numbertheory/primes.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-const u16bit PRIMES[PRIME_TABLE_SIZE+1] = {
+const uint16_t PRIMES[PRIME_TABLE_SIZE+1] = {
3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,
41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,
89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139,
diff --git a/src/lib/misc/aont/package.cpp b/src/lib/misc/aont/package.cpp
index cec07d298..9c106e1d0 100644
--- a/src/lib/misc/aont/package.cpp
+++ b/src/lib/misc/aont/package.cpp
@@ -15,8 +15,8 @@ namespace Botan {
void aont_package(RandomNumberGenerator& rng,
BlockCipher* cipher,
- const byte input[], size_t input_len,
- byte output[])
+ const uint8_t input[], size_t input_len,
+ uint8_t output[])
{
const size_t BLOCK_SIZE = cipher->block_size();
@@ -37,12 +37,12 @@ void aont_package(RandomNumberGenerator& rng,
// Set K0 (the all zero key)
cipher->set_key(SymmetricKey(all_zeros));
- secure_vector<byte> buf(BLOCK_SIZE);
+ secure_vector<uint8_t> buf(BLOCK_SIZE);
const size_t blocks =
(input_len + BLOCK_SIZE - 1) / BLOCK_SIZE;
- byte* final_block = output + input_len;
+ uint8_t* final_block = output + input_len;
clear_mem(final_block, BLOCK_SIZE);
// XOR the hash blocks into the final block
@@ -67,8 +67,8 @@ void aont_package(RandomNumberGenerator& rng,
}
void aont_unpackage(BlockCipher* cipher,
- const byte input[], size_t input_len,
- byte output[])
+ const uint8_t input[], size_t input_len,
+ uint8_t output[])
{
const size_t BLOCK_SIZE = cipher->block_size();
@@ -83,8 +83,8 @@ void aont_unpackage(BlockCipher* cipher,
cipher->set_key(SymmetricKey(all_zeros));
- secure_vector<byte> package_key(BLOCK_SIZE);
- secure_vector<byte> buf(BLOCK_SIZE);
+ secure_vector<uint8_t> package_key(BLOCK_SIZE);
+ secure_vector<uint8_t> buf(BLOCK_SIZE);
// Copy the package key (masked with the block hashes)
copy_mem(package_key.data(),
diff --git a/src/lib/misc/aont/package.h b/src/lib/misc/aont/package.h
index 76e679490..48d4b44e0 100644
--- a/src/lib/misc/aont/package.h
+++ b/src/lib/misc/aont/package.h
@@ -24,8 +24,8 @@ namespace Botan {
*/
void BOTAN_DLL aont_package(RandomNumberGenerator& rng,
BlockCipher* cipher,
- const byte input[], size_t input_len,
- byte output[]);
+ const uint8_t input[], size_t input_len,
+ uint8_t output[]);
/**
* Rivest's Package Tranform (Inversion)
@@ -36,8 +36,8 @@ void BOTAN_DLL aont_package(RandomNumberGenerator& rng,
* input_len - cipher->BLOCK_SIZE bytes long)
*/
void BOTAN_DLL aont_unpackage(BlockCipher* cipher,
- const byte input[], size_t input_len,
- byte output[]);
+ const uint8_t input[], size_t input_len,
+ uint8_t output[]);
}
diff --git a/src/lib/misc/cryptobox/cryptobox.cpp b/src/lib/misc/cryptobox/cryptobox.cpp
index 95cdda149..944adef49 100644
--- a/src/lib/misc/cryptobox/cryptobox.cpp
+++ b/src/lib/misc/cryptobox/cryptobox.cpp
@@ -25,7 +25,7 @@ namespace {
First 24 bits of SHA-256("Botan Cryptobox"), followed by 8 0 bits
for later use as flags, etc if needed
*/
-const u32bit CRYPTOBOX_VERSION_CODE = 0xEFC22400;
+const uint32_t CRYPTOBOX_VERSION_CODE = 0xEFC22400;
const size_t VERSION_CODE_LEN = 4;
const size_t CIPHER_KEY_LEN = 32;
@@ -39,11 +39,11 @@ const size_t PBKDF_OUTPUT_LEN = CIPHER_KEY_LEN + CIPHER_IV_LEN + MAC_KEY_LEN;
}
-std::string encrypt(const byte input[], size_t input_len,
+std::string encrypt(const uint8_t input[], size_t input_len,
const std::string& passphrase,
RandomNumberGenerator& rng)
{
- secure_vector<byte> pbkdf_salt(PBKDF_SALT_LEN);
+ secure_vector<uint8_t> pbkdf_salt(PBKDF_SALT_LEN);
rng.randomize(pbkdf_salt.data(), pbkdf_salt.size());
PKCS5_PBKDF2 pbkdf(new HMAC(new SHA_512));
@@ -55,7 +55,7 @@ std::string encrypt(const byte input[], size_t input_len,
pbkdf_salt.size(),
PBKDF_ITERATIONS);
- const byte* mk = master_key.begin();
+ const uint8_t* mk = master_key.begin();
SymmetricKey cipher_key(mk, CIPHER_KEY_LEN);
SymmetricKey mac_key(&mk[CIPHER_KEY_LEN], MAC_KEY_LEN);
@@ -78,7 +78,7 @@ std::string encrypt(const byte input[], size_t input_len,
*/
const size_t ciphertext_len = pipe.remaining(0);
- std::vector<byte> out_buf(VERSION_CODE_LEN +
+ std::vector<uint8_t> out_buf(VERSION_CODE_LEN +
PBKDF_SALT_LEN +
MAC_OUTPUT_LEN +
ciphertext_len);
@@ -99,11 +99,11 @@ std::string encrypt(const byte input[], size_t input_len,
return PEM_Code::encode(out_buf, "BOTAN CRYPTOBOX MESSAGE");
}
-std::string decrypt(const byte input[], size_t input_len,
+std::string decrypt(const uint8_t input[], size_t input_len,
const std::string& passphrase)
{
DataSource_Memory input_src(input, input_len);
- secure_vector<byte> ciphertext =
+ secure_vector<uint8_t> ciphertext =
PEM_Code::decode_check_label(input_src,
"BOTAN CRYPTOBOX MESSAGE");
@@ -114,7 +114,7 @@ std::string decrypt(const byte input[], size_t input_len,
if(ciphertext[i] != get_byte(i, CRYPTOBOX_VERSION_CODE))
throw Decoding_Error("Bad CryptoBox version");
- const byte* pbkdf_salt = &ciphertext[VERSION_CODE_LEN];
+ const uint8_t* pbkdf_salt = &ciphertext[VERSION_CODE_LEN];
PKCS5_PBKDF2 pbkdf(new HMAC(new SHA_512));
@@ -125,7 +125,7 @@ std::string decrypt(const byte input[], size_t input_len,
PBKDF_SALT_LEN,
PBKDF_ITERATIONS);
- const byte* mk = master_key.begin();
+ const uint8_t* mk = master_key.begin();
SymmetricKey cipher_key(mk, CIPHER_KEY_LEN);
SymmetricKey mac_key(&mk[CIPHER_KEY_LEN], MAC_KEY_LEN);
@@ -142,7 +142,7 @@ std::string decrypt(const byte input[], size_t input_len,
pipe.process_msg(&ciphertext[ciphertext_offset],
ciphertext.size() - ciphertext_offset);
- byte computed_mac[MAC_OUTPUT_LEN];
+ uint8_t computed_mac[MAC_OUTPUT_LEN];
BOTAN_ASSERT_EQUAL(MAC_OUTPUT_LEN, pipe.read(computed_mac, MAC_OUTPUT_LEN, 1), "MAC size");
if(!same_mem(computed_mac,
@@ -156,7 +156,7 @@ std::string decrypt(const byte input[], size_t input_len,
std::string decrypt(const std::string& input,
const std::string& passphrase)
{
- return decrypt(reinterpret_cast<const byte*>(input.data()),
+ return decrypt(reinterpret_cast<const uint8_t*>(input.data()),
input.size(),
passphrase);
}
diff --git a/src/lib/misc/cryptobox/cryptobox.h b/src/lib/misc/cryptobox/cryptobox.h
index 27dc55a68..8a524c93c 100644
--- a/src/lib/misc/cryptobox/cryptobox.h
+++ b/src/lib/misc/cryptobox/cryptobox.h
@@ -26,7 +26,7 @@ namespace CryptoBox {
* @param passphrase the passphrase used to encrypt the message
* @param rng a ref to a random number generator, such as AutoSeeded_RNG
*/
-BOTAN_DLL std::string encrypt(const byte input[], size_t input_len,
+BOTAN_DLL std::string encrypt(const uint8_t input[], size_t input_len,
const std::string& passphrase,
RandomNumberGenerator& rng);
@@ -37,7 +37,7 @@ BOTAN_DLL std::string encrypt(const byte input[], size_t input_len,
* @param input_len the length of input in bytes
* @param passphrase the passphrase used to encrypt the message
*/
-BOTAN_DLL std::string decrypt(const byte input[], size_t input_len,
+BOTAN_DLL std::string decrypt(const uint8_t input[], size_t input_len,
const std::string& passphrase);
/**
diff --git a/src/lib/misc/fpe_fe1/fpe_fe1.cpp b/src/lib/misc/fpe_fe1/fpe_fe1.cpp
index c59e41e78..72e154374 100644
--- a/src/lib/misc/fpe_fe1/fpe_fe1.cpp
+++ b/src/lib/misc/fpe_fe1/fpe_fe1.cpp
@@ -80,31 +80,31 @@ class FPE_Encryptor
public:
FPE_Encryptor(const SymmetricKey& key,
const BigInt& n,
- const std::vector<byte>& tweak);
+ const std::vector<uint8_t>& tweak);
BigInt operator()(size_t i, const BigInt& R);
private:
std::unique_ptr<MessageAuthenticationCode> m_mac;
- std::vector<byte> m_mac_n_t;
+ std::vector<uint8_t> m_mac_n_t;
};
FPE_Encryptor::FPE_Encryptor(const SymmetricKey& key,
const BigInt& n,
- const std::vector<byte>& tweak)
+ const std::vector<uint8_t>& tweak)
{
m_mac.reset(new HMAC(new SHA_256));
m_mac->set_key(key);
- std::vector<byte> n_bin = BigInt::encode(n);
+ std::vector<uint8_t> n_bin = BigInt::encode(n);
if(n_bin.size() > MAX_N_BYTES)
throw Exception("N is too large for FPE encryption");
- m_mac->update_be(static_cast<u32bit>(n_bin.size()));
+ m_mac->update_be(static_cast<uint32_t>(n_bin.size()));
m_mac->update(n_bin.data(), n_bin.size());
- m_mac->update_be(static_cast<u32bit>(tweak.size()));
+ m_mac->update_be(static_cast<uint32_t>(tweak.size()));
m_mac->update(tweak.data(), tweak.size());
m_mac_n_t = unlock(m_mac->final());
@@ -112,15 +112,15 @@ FPE_Encryptor::FPE_Encryptor(const SymmetricKey& key,
BigInt FPE_Encryptor::operator()(size_t round_no, const BigInt& R)
{
- secure_vector<byte> r_bin = BigInt::encode_locked(R);
+ secure_vector<uint8_t> r_bin = BigInt::encode_locked(R);
m_mac->update(m_mac_n_t);
- m_mac->update_be(static_cast<u32bit>(round_no));
+ m_mac->update_be(static_cast<uint32_t>(round_no));
- m_mac->update_be(static_cast<u32bit>(r_bin.size()));
+ m_mac->update_be(static_cast<uint32_t>(r_bin.size()));
m_mac->update(r_bin.data(), r_bin.size());
- secure_vector<byte> X = m_mac->final();
+ secure_vector<uint8_t> X = m_mac->final();
return BigInt(X.data(), X.size());
}
@@ -131,7 +131,7 @@ BigInt FPE_Encryptor::operator()(size_t round_no, const BigInt& R)
*/
BigInt fe1_encrypt(const BigInt& n, const BigInt& X0,
const SymmetricKey& key,
- const std::vector<byte>& tweak)
+ const std::vector<uint8_t>& tweak)
{
FPE_Encryptor F(key, n, tweak);
@@ -159,7 +159,7 @@ BigInt fe1_encrypt(const BigInt& n, const BigInt& X0,
*/
BigInt fe1_decrypt(const BigInt& n, const BigInt& X0,
const SymmetricKey& key,
- const std::vector<byte>& tweak)
+ const std::vector<uint8_t>& tweak)
{
FPE_Encryptor F(key, n, tweak);
diff --git a/src/lib/misc/fpe_fe1/fpe_fe1.h b/src/lib/misc/fpe_fe1/fpe_fe1.h
index a1cae9917..fe86f0718 100644
--- a/src/lib/misc/fpe_fe1/fpe_fe1.h
+++ b/src/lib/misc/fpe_fe1/fpe_fe1.h
@@ -28,7 +28,7 @@ namespace FPE {
*/
BigInt BOTAN_DLL fe1_encrypt(const BigInt& n, const BigInt& X,
const SymmetricKey& key,
- const std::vector<byte>& tweak);
+ const std::vector<uint8_t>& tweak);
/**
* Decrypt X from and onto the group Z_n using key and tweak
@@ -39,7 +39,7 @@ BigInt BOTAN_DLL fe1_encrypt(const BigInt& n, const BigInt& X,
*/
BigInt BOTAN_DLL fe1_decrypt(const BigInt& n, const BigInt& X,
const SymmetricKey& key,
- const std::vector<byte>& tweak);
+ const std::vector<uint8_t>& tweak);
}
diff --git a/src/lib/misc/rfc3394/rfc3394.cpp b/src/lib/misc/rfc3394/rfc3394.cpp
index 9ec053ef3..2ec49ac65 100644
--- a/src/lib/misc/rfc3394/rfc3394.cpp
+++ b/src/lib/misc/rfc3394/rfc3394.cpp
@@ -12,7 +12,7 @@
namespace Botan {
-secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key,
+secure_vector<uint8_t> rfc3394_keywrap(const secure_vector<uint8_t>& key,
const SymmetricKey& kek)
{
if(key.size() % 8 != 0)
@@ -27,8 +27,8 @@ secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key,
const size_t n = key.size() / 8;
- secure_vector<byte> R((n + 1) * 8);
- secure_vector<byte> A(16);
+ secure_vector<uint8_t> R((n + 1) * 8);
+ secure_vector<uint8_t> A(16);
for(size_t i = 0; i != 8; ++i)
A[i] = 0xA6;
@@ -39,14 +39,14 @@ secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key,
{
for(size_t i = 1; i <= n; ++i)
{
- const u32bit t = (n * j) + i;
+ const uint32_t t = (n * j) + i;
copy_mem(&A[8], &R[8*i], 8);
aes->encrypt(A.data());
copy_mem(&R[8*i], &A[8], 8);
- byte t_buf[4] = { 0 };
+ uint8_t t_buf[4] = { 0 };
store_be(t, t_buf);
xor_buf(&A[4], t_buf, 4);
}
@@ -57,7 +57,7 @@ secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key,
return R;
}
-secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key,
+secure_vector<uint8_t> rfc3394_keyunwrap(const secure_vector<uint8_t>& key,
const SymmetricKey& kek)
{
if(key.size() < 16 || key.size() % 8 != 0)
@@ -72,8 +72,8 @@ secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key,
const size_t n = (key.size() - 8) / 8;
- secure_vector<byte> R(n * 8);
- secure_vector<byte> A(16);
+ secure_vector<uint8_t> R(n * 8);
+ secure_vector<uint8_t> A(16);
for(size_t i = 0; i != 8; ++i)
A[i] = key[i];
@@ -84,9 +84,9 @@ secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key,
{
for(size_t i = n; i != 0; --i)
{
- const u32bit t = (5 - j) * n + i;
+ const uint32_t t = (5 - j) * n + i;
- byte t_buf[4] = { 0 };
+ uint8_t t_buf[4] = { 0 };
store_be(t, t_buf);
xor_buf(&A[4], t_buf, 4);
@@ -99,7 +99,7 @@ secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key,
}
}
- if(load_be<u64bit>(A.data(), 0) != 0xA6A6A6A6A6A6A6A6)
+ if(load_be<uint64_t>(A.data(), 0) != 0xA6A6A6A6A6A6A6A6)
throw Integrity_Failure("NIST key unwrap failed");
return R;
diff --git a/src/lib/misc/rfc3394/rfc3394.h b/src/lib/misc/rfc3394/rfc3394.h
index af869505a..5690c4713 100644
--- a/src/lib/misc/rfc3394/rfc3394.h
+++ b/src/lib/misc/rfc3394/rfc3394.h
@@ -20,7 +20,7 @@ namespace Botan {
* @param kek the key encryption key
* @return key encrypted under kek
*/
-secure_vector<byte> BOTAN_DLL rfc3394_keywrap(const secure_vector<byte>& key,
+secure_vector<uint8_t> BOTAN_DLL rfc3394_keywrap(const secure_vector<uint8_t>& key,
const SymmetricKey& kek);
/**
@@ -31,7 +31,7 @@ secure_vector<byte> BOTAN_DLL rfc3394_keywrap(const secure_vector<byte>& key,
* @param kek the key encryption key
* @return key decrypted under kek
*/
-secure_vector<byte> BOTAN_DLL rfc3394_keyunwrap(const secure_vector<byte>& key,
+secure_vector<uint8_t> BOTAN_DLL rfc3394_keyunwrap(const secure_vector<uint8_t>& key,
const SymmetricKey& kek);
}
diff --git a/src/lib/misc/srp6/srp6.cpp b/src/lib/misc/srp6/srp6.cpp
index f54726151..12107715f 100644
--- a/src/lib/misc/srp6/srp6.cpp
+++ b/src/lib/misc/srp6/srp6.cpp
@@ -29,7 +29,7 @@ BigInt hash_seq(const std::string& hash_id,
BigInt compute_x(const std::string& hash_id,
const std::string& identifier,
const std::string& password,
- const std::vector<byte>& salt)
+ const std::vector<uint8_t>& salt)
{
std::unique_ptr<HashFunction> hash_fn(HashFunction::create_or_throw(hash_id));
@@ -37,12 +37,12 @@ BigInt compute_x(const std::string& hash_id,
hash_fn->update(":");
hash_fn->update(password);
- secure_vector<byte> inner_h = hash_fn->final();
+ secure_vector<uint8_t> inner_h = hash_fn->final();
hash_fn->update(salt);
hash_fn->update(inner_h);
- secure_vector<byte> outer_h = hash_fn->final();
+ secure_vector<uint8_t> outer_h = hash_fn->final();
return BigInt::decode(outer_h);
}
@@ -77,7 +77,7 @@ srp6_client_agree(const std::string& identifier,
const std::string& password,
const std::string& group_id,
const std::string& hash_id,
- const std::vector<byte>& salt,
+ const std::vector<uint8_t>& salt,
const BigInt& B,
RandomNumberGenerator& rng)
{
@@ -109,7 +109,7 @@ srp6_client_agree(const std::string& identifier,
BigInt generate_srp6_verifier(const std::string& identifier,
const std::string& password,
- const std::vector<byte>& salt,
+ const std::vector<uint8_t>& salt,
const std::string& group_id,
const std::string& hash_id)
{
diff --git a/src/lib/misc/srp6/srp6.h b/src/lib/misc/srp6/srp6.h
index 5db433ad6..af9f427d0 100644
--- a/src/lib/misc/srp6/srp6.h
+++ b/src/lib/misc/srp6/srp6.h
@@ -33,7 +33,7 @@ BOTAN_DLL srp6_client_agree(const std::string& username,
const std::string& password,
const std::string& group_id,
const std::string& hash_id,
- const std::vector<byte>& salt,
+ const std::vector<uint8_t>& salt,
const BigInt& B,
RandomNumberGenerator& rng);
@@ -47,7 +47,7 @@ BOTAN_DLL srp6_client_agree(const std::string& username,
*/
BigInt BOTAN_DLL generate_srp6_verifier(const std::string& identifier,
const std::string& password,
- const std::vector<byte>& salt,
+ const std::vector<uint8_t>& salt,
const std::string& group_id,
const std::string& hash_id);
diff --git a/src/lib/misc/srp6/srp6_files.cpp b/src/lib/misc/srp6/srp6_files.cpp
index 606c12ad7..0e1569a1c 100644
--- a/src/lib/misc/srp6/srp6_files.cpp
+++ b/src/lib/misc/srp6/srp6_files.cpp
@@ -28,7 +28,7 @@ SRP6_Authenticator_File::SRP6_Authenticator_File(std::istream& in)
std::string username = parts[0];
BigInt v = BigInt::decode(base64_decode(parts[1]));
- std::vector<byte> salt = unlock(base64_decode(parts[2]));
+ std::vector<uint8_t> salt = unlock(base64_decode(parts[2]));
BigInt group_id_idx = BigInt::decode(base64_decode(parts[3]));
std::string group_id;
@@ -48,7 +48,7 @@ SRP6_Authenticator_File::SRP6_Authenticator_File(std::istream& in)
bool SRP6_Authenticator_File::lookup_user(const std::string& username,
BigInt& v,
- std::vector<byte>& salt,
+ std::vector<uint8_t>& salt,
std::string& group_id) const
{
std::map<std::string, SRP6_Data>::const_iterator i = m_entries.find(username);
diff --git a/src/lib/misc/srp6/srp6_files.h b/src/lib/misc/srp6/srp6_files.h
index 8c899aad6..124bfc86a 100644
--- a/src/lib/misc/srp6/srp6_files.h
+++ b/src/lib/misc/srp6/srp6_files.h
@@ -37,7 +37,7 @@ class BOTAN_DLL SRP6_Authenticator_File
*/
bool lookup_user(const std::string& username,
BigInt& v,
- std::vector<byte>& salt,
+ std::vector<uint8_t>& salt,
std::string& group_id) const;
private:
struct SRP6_Data
@@ -45,7 +45,7 @@ class BOTAN_DLL SRP6_Authenticator_File
SRP6_Data() {}
SRP6_Data(const BigInt& v_,
- const std::vector<byte>& salt_,
+ const std::vector<uint8_t>& salt_,
const std::string& group_id_) :
v(v_), salt(salt_), group_id(group_id_) {}
@@ -53,7 +53,7 @@ class BOTAN_DLL SRP6_Authenticator_File
BigInt v;
// public member variable:
- std::vector<byte> salt;
+ std::vector<uint8_t> salt;
// public member variable:
std::string group_id;
diff --git a/src/lib/misc/tss/tss.cpp b/src/lib/misc/tss/tss.cpp
index b77e6c2b9..a7b0c4eac 100644
--- a/src/lib/misc/tss/tss.cpp
+++ b/src/lib/misc/tss/tss.cpp
@@ -18,7 +18,7 @@ namespace {
/**
Table for GF(2^8) arithmetic (exponentials)
*/
-const byte RTSS_EXP[256] = {
+const uint8_t RTSS_EXP[256] = {
0x01, 0x03, 0x05, 0x0F, 0x11, 0x33, 0x55, 0xFF, 0x1A, 0x2E, 0x72,
0x96, 0xA1, 0xF8, 0x13, 0x35, 0x5F, 0xE1, 0x38, 0x48, 0xD8, 0x73,
0x95, 0xA4, 0xF7, 0x02, 0x06, 0x0A, 0x1E, 0x22, 0x66, 0xAA, 0xE5,
@@ -47,7 +47,7 @@ const byte RTSS_EXP[256] = {
/**
Table for GF(2^8) arithmetic (logarithms)
*/
-const byte RTSS_LOG[] = {
+const uint8_t RTSS_LOG[] = {
0x90, 0x00, 0x19, 0x01, 0x32, 0x02, 0x1A, 0xC6, 0x4B, 0xC7, 0x1B,
0x68, 0x33, 0xEE, 0xDF, 0x03, 0x64, 0x04, 0xE0, 0x0E, 0x34, 0x8D,
0x81, 0xEF, 0x4C, 0x71, 0x08, 0xC8, 0xF8, 0x69, 0x1C, 0xC1, 0x7D,
@@ -73,14 +73,14 @@ const byte RTSS_LOG[] = {
0xED, 0xDE, 0xC5, 0x31, 0xFE, 0x18, 0x0D, 0x63, 0x8C, 0x80, 0xC0,
0xF7, 0x70, 0x07 };
-byte gfp_mul(byte x, byte y)
+uint8_t gfp_mul(uint8_t x, uint8_t y)
{
if(x == 0 || y == 0)
return 0;
return RTSS_EXP[(RTSS_LOG[x] + RTSS_LOG[y]) % 255];
}
-byte rtss_hash_id(const std::string& hash_name)
+uint8_t rtss_hash_id(const std::string& hash_name)
{
if(hash_name == "SHA-160")
return 1;
@@ -90,7 +90,7 @@ byte rtss_hash_id(const std::string& hash_name)
throw Invalid_Argument("RTSS only supports SHA-1 and SHA-256");
}
-HashFunction* get_rtss_hash_by_id(byte id)
+HashFunction* get_rtss_hash_by_id(uint8_t id)
{
if(id == 1)
return new SHA_160;
@@ -107,7 +107,7 @@ RTSS_Share::RTSS_Share(const std::string& hex_input)
m_contents = hex_decode_locked(hex_input);
}
-byte RTSS_Share::share_id() const
+uint8_t RTSS_Share::share_id() const
{
if(!initialized())
throw Invalid_State("RTSS_Share::share_id not initialized");
@@ -121,9 +121,9 @@ std::string RTSS_Share::to_string() const
}
std::vector<RTSS_Share>
-RTSS_Share::split(byte M, byte N,
- const byte S[], u16bit S_len,
- const byte identifier[16],
+RTSS_Share::split(uint8_t M, uint8_t N,
+ const uint8_t S[], uint16_t S_len,
+ const uint8_t identifier[16],
RandomNumberGenerator& rng)
{
if(M == 0 || N == 0 || M > N)
@@ -134,7 +134,7 @@ RTSS_Share::split(byte M, byte N,
std::vector<RTSS_Share> shares(N);
// Create RTSS header in each share
- for(byte i = 0; i != N; ++i)
+ for(uint8_t i = 0; i != N; ++i)
{
shares[i].m_contents += std::make_pair(identifier, 16);
shares[i].m_contents += rtss_hash_id(hash.name());
@@ -144,24 +144,24 @@ RTSS_Share::split(byte M, byte N,
}
// Choose sequential values for X starting from 1
- for(byte i = 0; i != N; ++i)
+ for(uint8_t i = 0; i != N; ++i)
shares[i].m_contents.push_back(i+1);
// secret = S || H(S)
- secure_vector<byte> secret(S, S + S_len);
+ secure_vector<uint8_t> secret(S, S + S_len);
secret += hash.process(S, S_len);
for(size_t i = 0; i != secret.size(); ++i)
{
- std::vector<byte> coefficients(M-1);
+ std::vector<uint8_t> coefficients(M-1);
rng.randomize(coefficients.data(), coefficients.size());
- for(byte j = 0; j != N; ++j)
+ for(uint8_t j = 0; j != N; ++j)
{
- const byte X = j + 1;
+ const uint8_t X = j + 1;
- byte sum = secret[i];
- byte X_i = X;
+ uint8_t sum = secret[i];
+ uint8_t X_i = X;
for(size_t k = 0; k != coefficients.size(); ++k)
{
@@ -176,7 +176,7 @@ RTSS_Share::split(byte M, byte N,
return shares;
}
-secure_vector<byte>
+secure_vector<uint8_t>
RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares)
{
const size_t RTSS_HEADER_SIZE = 20;
@@ -198,41 +198,41 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares)
if(shares.size() < shares[0].m_contents[17])
throw Decoding_Error("Insufficient shares to do TSS reconstruction");
- u16bit secret_len = make_u16bit(shares[0].m_contents[18],
+ uint16_t secret_len = make_uint16(shares[0].m_contents[18],
shares[0].m_contents[19]);
- byte hash_id = shares[0].m_contents[16];
+ uint8_t hash_id = shares[0].m_contents[16];
std::unique_ptr<HashFunction> hash(get_rtss_hash_by_id(hash_id));
if(shares[0].size() != secret_len + hash->output_length() + RTSS_HEADER_SIZE + 1)
throw Decoding_Error("Bad RTSS length field in header");
- std::vector<byte> V(shares.size());
- secure_vector<byte> secret;
+ std::vector<uint8_t> V(shares.size());
+ secure_vector<uint8_t> secret;
for(size_t i = RTSS_HEADER_SIZE + 1; i != shares[0].size(); ++i)
{
for(size_t j = 0; j != V.size(); ++j)
V[j] = shares[j].m_contents[i];
- byte r = 0;
+ uint8_t r = 0;
for(size_t k = 0; k != shares.size(); ++k)
{
// L_i function:
- byte r2 = 1;
+ uint8_t r2 = 1;
for(size_t l = 0; l != shares.size(); ++l)
{
if(k == l)
continue;
- byte share_k = shares[k].share_id();
- byte share_l = shares[l].share_id();
+ uint8_t share_k = shares[k].share_id();
+ uint8_t share_l = shares[l].share_id();
if(share_k == share_l)
throw Decoding_Error("Duplicate shares found in RTSS recovery");
- byte div = RTSS_EXP[(255 +
+ uint8_t div = RTSS_EXP[(255 +
RTSS_LOG[share_l] -
RTSS_LOG[share_k ^ share_l]) % 255];
@@ -248,13 +248,13 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares)
throw Decoding_Error("Bad length in RTSS output");
hash->update(secret.data(), secret_len);
- secure_vector<byte> hash_check = hash->final();
+ secure_vector<uint8_t> hash_check = hash->final();
if(!same_mem(hash_check.data(),
&secret[secret_len], hash->output_length()))
throw Decoding_Error("RTSS hash check failed");
- return secure_vector<byte>(secret.cbegin(), secret.cbegin() + secret_len);
+ return secure_vector<uint8_t>(secret.cbegin(), secret.cbegin() + secret_len);
}
}
diff --git a/src/lib/misc/tss/tss.h b/src/lib/misc/tss/tss.h
index 6ff47a0cc..79aa417c3 100644
--- a/src/lib/misc/tss/tss.h
+++ b/src/lib/misc/tss/tss.h
@@ -30,15 +30,15 @@ class BOTAN_DLL RTSS_Share
* @param rng the random number generator to use
*/
static std::vector<RTSS_Share>
- split(byte M, byte N,
- const byte secret[], u16bit secret_len,
- const byte identifier[16],
+ split(uint8_t M, uint8_t N,
+ const uint8_t secret[], uint16_t secret_len,
+ const uint8_t identifier[16],
RandomNumberGenerator& rng);
/**
* @param shares the list of shares
*/
- static secure_vector<byte>
+ static secure_vector<uint8_t>
reconstruct(const std::vector<RTSS_Share>& shares);
RTSS_Share() {}
@@ -56,7 +56,7 @@ class BOTAN_DLL RTSS_Share
/**
* @return share identifier
*/
- byte share_id() const;
+ uint8_t share_id() const;
/**
* @return size of this share in bytes
@@ -68,7 +68,7 @@ class BOTAN_DLL RTSS_Share
*/
bool initialized() const { return (m_contents.size() > 0); }
private:
- secure_vector<byte> m_contents;
+ secure_vector<uint8_t> m_contents;
};
}
diff --git a/src/lib/modes/aead/aead.h b/src/lib/modes/aead/aead.h
index 2cdc6137e..3d3c7287f 100644
--- a/src/lib/modes/aead/aead.h
+++ b/src/lib/modes/aead/aead.h
@@ -36,7 +36,7 @@ class BOTAN_DLL AEAD_Mode : public Cipher_Mode
* @param ad the associated data
* @param ad_len length of add in bytes
*/
- virtual void set_associated_data(const byte ad[], size_t ad_len) = 0;
+ virtual void set_associated_data(const uint8_t ad[], size_t ad_len) = 0;
/**
* Set associated data that is not included in the ciphertext but
@@ -48,7 +48,7 @@ class BOTAN_DLL AEAD_Mode : public Cipher_Mode
* @param ad the associated data
*/
template<typename Alloc>
- void set_associated_data_vec(const std::vector<byte, Alloc>& ad)
+ void set_associated_data_vec(const std::vector<uint8_t, Alloc>& ad)
{
set_associated_data(ad.data(), ad.size());
}
@@ -63,7 +63,7 @@ class BOTAN_DLL AEAD_Mode : public Cipher_Mode
* @param ad the associated data
*/
template<typename Alloc>
- void set_ad(const std::vector<byte, Alloc>& ad)
+ void set_ad(const std::vector<uint8_t, Alloc>& ad)
{
set_associated_data(ad.data(), ad.size());
}
diff --git a/src/lib/modes/aead/ccm/ccm.cpp b/src/lib/modes/aead/ccm/ccm.cpp
index de639f23a..db0d2d58b 100644
--- a/src/lib/modes/aead/ccm/ccm.cpp
+++ b/src/lib/modes/aead/ccm/ccm.cpp
@@ -65,7 +65,7 @@ size_t CCM_Mode::update_granularity() const
/*
This value does not particularly matter as regardless CCM_Mode::update
buffers all input, so in theory this could be 1. However as for instance
- Transform_Filter creates update_granularity() byte buffers, use a
+ Transform_Filter creates update_granularity() uint8_t buffers, use a
somewhat large size to avoid bouncing on a tiny buffer.
*/
return m_cipher->parallel_bytes();
@@ -76,12 +76,12 @@ Key_Length_Specification CCM_Mode::key_spec() const
return m_cipher->key_spec();
}
-void CCM_Mode::key_schedule(const byte key[], size_t length)
+void CCM_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_cipher->set_key(key, length);
}
-void CCM_Mode::set_associated_data(const byte ad[], size_t length)
+void CCM_Mode::set_associated_data(const uint8_t ad[], size_t length)
{
m_ad_buf.clear();
@@ -90,15 +90,15 @@ void CCM_Mode::set_associated_data(const byte ad[], size_t length)
// FIXME: support larger AD using length encoding rules
BOTAN_ASSERT(length < (0xFFFF - 0xFF), "Supported CCM AD length");
- m_ad_buf.push_back(get_byte(0, static_cast<u16bit>(length)));
- m_ad_buf.push_back(get_byte(1, static_cast<u16bit>(length)));
+ m_ad_buf.push_back(get_byte(0, static_cast<uint16_t>(length)));
+ m_ad_buf.push_back(get_byte(1, static_cast<uint16_t>(length)));
m_ad_buf += std::make_pair(ad, length);
while(m_ad_buf.size() % CCM_BS)
m_ad_buf.push_back(0); // pad with zeros to full block size
}
}
-void CCM_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void CCM_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -113,7 +113,7 @@ size_t CCM_Mode::process(uint8_t buf[], size_t sz)
return 0; // no output until finished
}
-void CCM_Mode::encode_length(size_t len, byte out[])
+void CCM_Mode::encode_length(size_t len, uint8_t out[])
{
const size_t len_bytes = L();
@@ -125,18 +125,18 @@ void CCM_Mode::encode_length(size_t len, byte out[])
BOTAN_ASSERT((len >> (len_bytes*8)) == 0, "Message length fits in field");
}
-void CCM_Mode::inc(secure_vector<byte>& C)
+void CCM_Mode::inc(secure_vector<uint8_t>& C)
{
for(size_t i = 0; i != C.size(); ++i)
if(++C[C.size()-i-1])
break;
}
-secure_vector<byte> CCM_Mode::format_b0(size_t sz)
+secure_vector<uint8_t> CCM_Mode::format_b0(size_t sz)
{
- secure_vector<byte> B0(CCM_BS);
+ secure_vector<uint8_t> B0(CCM_BS);
- const byte b_flags = (m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1);
+ const uint8_t b_flags = (m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1);
B0[0] = b_flags;
copy_mem(&B0[1], m_nonce.data(), m_nonce.size());
@@ -145,11 +145,11 @@ secure_vector<byte> CCM_Mode::format_b0(size_t sz)
return B0;
}
-secure_vector<byte> CCM_Mode::format_c0()
+secure_vector<uint8_t> CCM_Mode::format_c0()
{
- secure_vector<byte> C(CCM_BS);
+ secure_vector<uint8_t> C(CCM_BS);
- const byte a_flags = L()-1;
+ const uint8_t a_flags = L()-1;
C[0] = a_flags;
copy_mem(&C[1], m_nonce.data(), m_nonce.size());
@@ -157,21 +157,21 @@ secure_vector<byte> CCM_Mode::format_c0()
return C;
}
-void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CCM_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
- const secure_vector<byte>& ad = ad_buf();
+ const secure_vector<uint8_t>& ad = ad_buf();
BOTAN_ASSERT(ad.size() % CCM_BS == 0, "AD is block size multiple");
const BlockCipher& E = cipher();
- secure_vector<byte> T(CCM_BS);
+ secure_vector<uint8_t> T(CCM_BS);
E.encrypt(format_b0(sz), T);
for(size_t i = 0; i != ad.size(); i += CCM_BS)
@@ -180,14 +180,14 @@ void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
E.encrypt(T);
}
- secure_vector<byte> C = format_c0();
- secure_vector<byte> S0(CCM_BS);
+ secure_vector<uint8_t> C = format_c0();
+ secure_vector<uint8_t> S0(CCM_BS);
E.encrypt(C, S0);
inc(C);
- secure_vector<byte> X(CCM_BS);
+ secure_vector<uint8_t> X(CCM_BS);
- const byte* buf_end = &buf[sz];
+ const uint8_t* buf_end = &buf[sz];
while(buf != buf_end)
{
@@ -208,23 +208,23 @@ void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer += std::make_pair(T.data(), tag_size());
}
-void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CCM_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
- const secure_vector<byte>& ad = ad_buf();
+ const secure_vector<uint8_t>& ad = ad_buf();
BOTAN_ASSERT(ad.size() % CCM_BS == 0, "AD is block size multiple");
const BlockCipher& E = cipher();
- secure_vector<byte> T(CCM_BS);
+ secure_vector<uint8_t> T(CCM_BS);
E.encrypt(format_b0(sz - tag_size()), T);
for(size_t i = 0; i != ad.size(); i += CCM_BS)
@@ -233,15 +233,15 @@ void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
E.encrypt(T);
}
- secure_vector<byte> C = format_c0();
+ secure_vector<uint8_t> C = format_c0();
- secure_vector<byte> S0(CCM_BS);
+ secure_vector<uint8_t> S0(CCM_BS);
E.encrypt(C, S0);
inc(C);
- secure_vector<byte> X(CCM_BS);
+ secure_vector<uint8_t> X(CCM_BS);
- const byte* buf_end = &buf[sz - tag_size()];
+ const uint8_t* buf_end = &buf[sz - tag_size()];
while(buf != buf_end)
{
diff --git a/src/lib/modes/aead/ccm/ccm.h b/src/lib/modes/aead/ccm/ccm.h
index 9795354fc..93dd0d7e1 100644
--- a/src/lib/modes/aead/ccm/ccm.h
+++ b/src/lib/modes/aead/ccm/ccm.h
@@ -25,7 +25,7 @@ class BOTAN_DLL CCM_Mode : public AEAD_Mode
public:
size_t process(uint8_t buf[], size_t sz) override;
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override;
@@ -50,26 +50,26 @@ class BOTAN_DLL CCM_Mode : public AEAD_Mode
const BlockCipher& cipher() const { return *m_cipher; }
- void encode_length(size_t len, byte out[]);
+ void encode_length(size_t len, uint8_t out[]);
- void inc(secure_vector<byte>& C);
+ void inc(secure_vector<uint8_t>& C);
- const secure_vector<byte>& ad_buf() const { return m_ad_buf; }
+ const secure_vector<uint8_t>& ad_buf() const { return m_ad_buf; }
- secure_vector<byte>& msg_buf() { return m_msg_buf; }
+ secure_vector<uint8_t>& msg_buf() { return m_msg_buf; }
- secure_vector<byte> format_b0(size_t msg_size);
- secure_vector<byte> format_c0();
+ secure_vector<uint8_t> format_b0(size_t msg_size);
+ secure_vector<uint8_t> format_c0();
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
const size_t m_tag_size;
const size_t m_L;
std::unique_ptr<BlockCipher> m_cipher;
- secure_vector<byte> m_nonce, m_msg_buf, m_ad_buf;
+ secure_vector<uint8_t> m_nonce, m_msg_buf, m_ad_buf;
};
/**
@@ -88,7 +88,7 @@ class BOTAN_DLL CCM_Encryption final : public CCM_Mode
CCM_Encryption(BlockCipher* cipher, size_t tag_size = 16, size_t L = 3) :
CCM_Mode(cipher, tag_size, L) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override
{ return input_length + tag_size(); }
@@ -112,7 +112,7 @@ class BOTAN_DLL CCM_Decryption final : public CCM_Mode
CCM_Decryption(BlockCipher* cipher, size_t tag_size = 16, size_t L = 3) :
CCM_Mode(cipher, tag_size, L) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override
{
diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
index 197d6f921..64169a9b8 100644
--- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
+++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
@@ -37,12 +37,12 @@ void ChaCha20Poly1305_Mode::reset()
m_nonce_len = 0;
}
-void ChaCha20Poly1305_Mode::key_schedule(const byte key[], size_t length)
+void ChaCha20Poly1305_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_chacha->set_key(key, length);
}
-void ChaCha20Poly1305_Mode::set_associated_data(const byte ad[], size_t length)
+void ChaCha20Poly1305_Mode::set_associated_data(const uint8_t ad[], size_t length)
{
if(m_ctext_len)
throw Exception("Too late to set AD for ChaCha20Poly1305");
@@ -51,12 +51,12 @@ void ChaCha20Poly1305_Mode::set_associated_data(const byte ad[], size_t length)
void ChaCha20Poly1305_Mode::update_len(size_t len)
{
- byte len8[8] = { 0 };
- store_le(static_cast<u64bit>(len), len8);
+ uint8_t len8[8] = { 0 };
+ store_le(static_cast<uint64_t>(len), len8);
m_poly1305->update(len8, 8);
}
-void ChaCha20Poly1305_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void ChaCha20Poly1305_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -66,7 +66,7 @@ void ChaCha20Poly1305_Mode::start_msg(const byte nonce[], size_t nonce_len)
m_chacha->set_iv(nonce, nonce_len);
- secure_vector<byte> init(64); // zeros
+ secure_vector<uint8_t> init(64); // zeros
m_chacha->encrypt(init);
m_poly1305->set_key(init.data(), 32);
@@ -78,7 +78,7 @@ void ChaCha20Poly1305_Mode::start_msg(const byte nonce[], size_t nonce_len)
{
if(m_ad.size() % 16)
{
- const byte zeros[16] = { 0 };
+ const uint8_t zeros[16] = { 0 };
m_poly1305->update(zeros, 16 - m_ad.size() % 16);
}
}
@@ -96,21 +96,21 @@ size_t ChaCha20Poly1305_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void ChaCha20Poly1305_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void ChaCha20Poly1305_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
update(buffer, offset);
if(cfrg_version())
{
if(m_ctext_len % 16)
{
- const byte zeros[16] = { 0 };
+ const uint8_t zeros[16] = { 0 };
m_poly1305->update(zeros, 16 - m_ctext_len % 16);
}
update_len(m_ad.size());
}
update_len(m_ctext_len);
- const secure_vector<byte> mac = m_poly1305->final();
+ const secure_vector<uint8_t> mac = m_poly1305->final();
buffer += std::make_pair(mac.data(), tag_size());
m_ctext_len = 0;
}
@@ -123,11 +123,11 @@ size_t ChaCha20Poly1305_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void ChaCha20Poly1305_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void ChaCha20Poly1305_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "Have the tag as part of final input");
@@ -144,16 +144,16 @@ void ChaCha20Poly1305_Decryption::finish(secure_vector<byte>& buffer, size_t off
{
if(m_ctext_len % 16)
{
- const byte zeros[16] = { 0 };
+ const uint8_t zeros[16] = { 0 };
m_poly1305->update(zeros, 16 - m_ctext_len % 16);
}
update_len(m_ad.size());
}
update_len(m_ctext_len);
- const secure_vector<byte> mac = m_poly1305->final();
+ const secure_vector<uint8_t> mac = m_poly1305->final();
- const byte* included_tag = &buf[remaining];
+ const uint8_t* included_tag = &buf[remaining];
m_ctext_len = 0;
diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h
index 58328ac5b..4245e5e01 100644
--- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h
+++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h
@@ -24,7 +24,7 @@ namespace Botan {
class BOTAN_DLL ChaCha20Poly1305_Mode : public AEAD_Mode
{
public:
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override { return "ChaCha20Poly1305"; }
@@ -47,16 +47,16 @@ class BOTAN_DLL ChaCha20Poly1305_Mode : public AEAD_Mode
ChaCha20Poly1305_Mode();
- secure_vector<byte> m_ad;
+ secure_vector<uint8_t> m_ad;
size_t m_nonce_len = 0;
size_t m_ctext_len = 0;
bool cfrg_version() const { return m_nonce_len == 12; }
void update_len(size_t len);
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
};
/**
@@ -72,7 +72,7 @@ class BOTAN_DLL ChaCha20Poly1305_Encryption final : public ChaCha20Poly1305_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -91,7 +91,7 @@ class BOTAN_DLL ChaCha20Poly1305_Decryption final : public ChaCha20Poly1305_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
}
diff --git a/src/lib/modes/aead/eax/eax.cpp b/src/lib/modes/aead/eax/eax.cpp
index ba52efcfd..4889ac21a 100644
--- a/src/lib/modes/aead/eax/eax.cpp
+++ b/src/lib/modes/aead/eax/eax.cpp
@@ -18,9 +18,9 @@ namespace {
/*
* EAX MAC-based PRF
*/
-secure_vector<byte> eax_prf(byte tag, size_t block_size,
+secure_vector<uint8_t> eax_prf(uint8_t tag, size_t block_size,
MessageAuthenticationCode& mac,
- const byte in[], size_t length)
+ const uint8_t in[], size_t length)
{
for(size_t i = 0; i != block_size - 1; ++i)
{
@@ -78,7 +78,7 @@ Key_Length_Specification EAX_Mode::key_spec() const
/*
* Set the EAX key
*/
-void EAX_Mode::key_schedule(const byte key[], size_t length)
+void EAX_Mode::key_schedule(const uint8_t key[], size_t length)
{
/*
* These could share the key schedule, which is one nice part of EAX,
@@ -91,12 +91,12 @@ void EAX_Mode::key_schedule(const byte key[], size_t length)
/*
* Set the EAX associated data
*/
-void EAX_Mode::set_associated_data(const byte ad[], size_t length)
+void EAX_Mode::set_associated_data(const uint8_t ad[], size_t length)
{
m_ad_mac = eax_prf(1, block_size(), *m_cmac, ad, length);
}
-void EAX_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void EAX_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -117,11 +117,11 @@ size_t EAX_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void EAX_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void EAX_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
update(buffer, offset);
- secure_vector<byte> data_mac = m_cmac->final();
+ secure_vector<uint8_t> data_mac = m_cmac->final();
xor_buf(data_mac, m_nonce_mac, data_mac.size());
if(m_ad_mac.empty())
@@ -141,11 +141,11 @@ size_t EAX_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void EAX_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void EAX_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "Have the tag as part of final input");
@@ -157,9 +157,9 @@ void EAX_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
m_ctr->cipher(buf, buf, remaining);
}
- const byte* included_tag = &buf[remaining];
+ const uint8_t* included_tag = &buf[remaining];
- secure_vector<byte> mac = m_cmac->final();
+ secure_vector<uint8_t> mac = m_cmac->final();
mac ^= m_nonce_mac;
if(m_ad_mac.empty())
diff --git a/src/lib/modes/aead/eax/eax.h b/src/lib/modes/aead/eax/eax.h
index c0b6bcf42..fc991ab1f 100644
--- a/src/lib/modes/aead/eax/eax.h
+++ b/src/lib/modes/aead/eax/eax.h
@@ -22,7 +22,7 @@ namespace Botan {
class BOTAN_DLL EAX_Mode : public AEAD_Mode
{
public:
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override;
@@ -54,13 +54,13 @@ class BOTAN_DLL EAX_Mode : public AEAD_Mode
std::unique_ptr<StreamCipher> m_ctr;
std::unique_ptr<MessageAuthenticationCode> m_cmac;
- secure_vector<byte> m_ad_mac;
+ secure_vector<uint8_t> m_ad_mac;
- secure_vector<byte> m_nonce_mac;
+ secure_vector<uint8_t> m_nonce_mac;
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
};
/**
@@ -83,7 +83,7 @@ class BOTAN_DLL EAX_Encryption final : public EAX_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -109,7 +109,7 @@ class BOTAN_DLL EAX_Decryption final : public EAX_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
}
diff --git a/src/lib/modes/aead/gcm/clmul/clmul.cpp b/src/lib/modes/aead/gcm/clmul/clmul.cpp
index 725ef3da3..ed3473b4e 100644
--- a/src/lib/modes/aead/gcm/clmul/clmul.cpp
+++ b/src/lib/modes/aead/gcm/clmul/clmul.cpp
@@ -12,7 +12,7 @@
namespace Botan {
BOTAN_FUNC_ISA("pclmul,ssse3")
-void gcm_multiply_clmul(byte x[16], const byte H[16])
+void gcm_multiply_clmul(uint8_t x[16], const uint8_t H[16])
{
/*
* Algorithms 1 and 5 from Intel's CLMUL guide
diff --git a/src/lib/modes/aead/gcm/clmul/clmul.h b/src/lib/modes/aead/gcm/clmul/clmul.h
index a3d8d9851..5e4a0de35 100644
--- a/src/lib/modes/aead/gcm/clmul/clmul.h
+++ b/src/lib/modes/aead/gcm/clmul/clmul.h
@@ -12,7 +12,7 @@
namespace Botan {
-void gcm_multiply_clmul(byte x[16], const byte H[16]);
+void gcm_multiply_clmul(uint8_t x[16], const uint8_t H[16]);
}
diff --git a/src/lib/modes/aead/gcm/gcm.cpp b/src/lib/modes/aead/gcm/gcm.cpp
index e0bc59a8d..0d0cbff3c 100644
--- a/src/lib/modes/aead/gcm/gcm.cpp
+++ b/src/lib/modes/aead/gcm/gcm.cpp
@@ -20,21 +20,21 @@ namespace Botan {
static const size_t GCM_BS = 16;
-void GHASH::gcm_multiply(secure_vector<byte>& x) const
+void GHASH::gcm_multiply(secure_vector<uint8_t>& x) const
{
#if defined(BOTAN_HAS_GCM_CLMUL)
if(CPUID::has_clmul())
return gcm_multiply_clmul(x.data(), m_H.data());
#endif
- static const u64bit R = 0xE100000000000000;
+ static const uint64_t R = 0xE100000000000000;
- u64bit H[2] = {
- load_be<u64bit>(m_H.data(), 0),
- load_be<u64bit>(m_H.data(), 1)
+ uint64_t H[2] = {
+ load_be<uint64_t>(m_H.data(), 0),
+ load_be<uint64_t>(m_H.data(), 1)
};
- u64bit Z[2] = { 0, 0 };
+ uint64_t Z[2] = { 0, 0 };
CT::poison(H, 2);
CT::poison(Z, 2);
@@ -44,30 +44,30 @@ void GHASH::gcm_multiply(secure_vector<byte>& x) const
for(size_t i = 0; i != 2; ++i)
{
- const u64bit X = load_be<u64bit>(x.data(), i);
+ const uint64_t X = load_be<uint64_t>(x.data(), i);
- u64bit mask = 0x8000000000000000;
+ uint64_t mask = 0x8000000000000000;
for(size_t j = 0; j != 64; ++j)
{
- const u64bit XMASK = CT::expand_mask<u64bit>(X & mask);
+ const uint64_t XMASK = CT::expand_mask<uint64_t>(X & mask);
mask >>= 1;
Z[0] ^= H[0] & XMASK;
Z[1] ^= H[1] & XMASK;
// GCM's bit ops are reversed so we carry out of the bottom
- const u64bit carry = R & CT::expand_mask<u64bit>(H[1] & 1);
+ const uint64_t carry = R & CT::expand_mask<uint64_t>(H[1] & 1);
H[1] = (H[1] >> 1) | (H[0] << 63);
H[0] = (H[0] >> 1) ^ carry;
}
}
- store_be<u64bit>(x.data(), Z[0], Z[1]);
+ store_be<uint64_t>(x.data(), Z[0], Z[1]);
CT::unpoison(x.data(), x.size());
}
-void GHASH::ghash_update(secure_vector<byte>& ghash,
- const byte input[], size_t length)
+void GHASH::ghash_update(secure_vector<uint8_t>& ghash,
+ const uint8_t input[], size_t length)
{
/*
This assumes if less than block size input then we're just on the
@@ -86,7 +86,7 @@ void GHASH::ghash_update(secure_vector<byte>& ghash,
}
}
-void GHASH::key_schedule(const byte key[], size_t length)
+void GHASH::key_schedule(const uint8_t key[], size_t length)
{
m_H.assign(key, key+length);
m_H_ad.resize(GCM_BS);
@@ -94,13 +94,13 @@ void GHASH::key_schedule(const byte key[], size_t length)
m_text_len = 0;
}
-void GHASH::start(const byte nonce[], size_t len)
+void GHASH::start(const uint8_t nonce[], size_t len)
{
m_nonce.assign(nonce, nonce + len);
m_ghash = m_H_ad;
}
-void GHASH::set_associated_data(const byte input[], size_t length)
+void GHASH::set_associated_data(const uint8_t input[], size_t length)
{
zeroise(m_H_ad);
@@ -108,7 +108,7 @@ void GHASH::set_associated_data(const byte input[], size_t length)
m_ad_len = length;
}
-void GHASH::update(const byte input[], size_t length)
+void GHASH::update(const uint8_t input[], size_t length)
{
BOTAN_ASSERT(m_ghash.size() == GCM_BS, "Key was set");
@@ -117,19 +117,19 @@ void GHASH::update(const byte input[], size_t length)
ghash_update(m_ghash, input, length);
}
-void GHASH::add_final_block(secure_vector<byte>& hash,
+void GHASH::add_final_block(secure_vector<uint8_t>& hash,
size_t ad_len, size_t text_len)
{
- secure_vector<byte> final_block(GCM_BS);
- store_be<u64bit>(final_block.data(), 8*ad_len, 8*text_len);
+ secure_vector<uint8_t> final_block(GCM_BS);
+ store_be<uint64_t>(final_block.data(), 8*ad_len, 8*text_len);
ghash_update(hash, final_block.data(), final_block.size());
}
-secure_vector<byte> GHASH::final()
+secure_vector<uint8_t> GHASH::final()
{
add_final_block(m_ghash, m_ad_len, m_text_len);
- secure_vector<byte> mac;
+ secure_vector<uint8_t> mac;
mac.swap(m_ghash);
mac ^= m_nonce;
@@ -137,10 +137,10 @@ secure_vector<byte> GHASH::final()
return mac;
}
-secure_vector<byte> GHASH::nonce_hash(const byte nonce[], size_t nonce_len)
+secure_vector<uint8_t> GHASH::nonce_hash(const uint8_t nonce[], size_t nonce_len)
{
BOTAN_ASSERT(m_ghash.size() == 0, "nonce_hash called during wrong time");
- secure_vector<byte> y0(GCM_BS);
+ secure_vector<uint8_t> y0(GCM_BS);
ghash_update(y0, nonce, nonce_len);
add_final_block(y0, 0, nonce_len);
@@ -217,29 +217,29 @@ Key_Length_Specification GCM_Mode::key_spec() const
return m_ctr->key_spec();
}
-void GCM_Mode::key_schedule(const byte key[], size_t keylen)
+void GCM_Mode::key_schedule(const uint8_t key[], size_t keylen)
{
m_ctr->set_key(key, keylen);
- const std::vector<byte> zeros(GCM_BS);
+ const std::vector<uint8_t> zeros(GCM_BS);
m_ctr->set_iv(zeros.data(), zeros.size());
- secure_vector<byte> H(GCM_BS);
+ secure_vector<uint8_t> H(GCM_BS);
m_ctr->encipher(H);
m_ghash->set_key(H);
}
-void GCM_Mode::set_associated_data(const byte ad[], size_t ad_len)
+void GCM_Mode::set_associated_data(const uint8_t ad[], size_t ad_len)
{
m_ghash->set_associated_data(ad, ad_len);
}
-void GCM_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void GCM_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
- secure_vector<byte> y0(GCM_BS);
+ secure_vector<uint8_t> y0(GCM_BS);
if(nonce_len == 12)
{
@@ -253,7 +253,7 @@ void GCM_Mode::start_msg(const byte nonce[], size_t nonce_len)
m_ctr->set_iv(y0.data(), y0.size());
- secure_vector<byte> m_enc_y0(GCM_BS);
+ secure_vector<uint8_t> m_enc_y0(GCM_BS);
m_ctr->encipher(m_enc_y0);
m_ghash->start(m_enc_y0.data(), m_enc_y0.size());
@@ -267,11 +267,11 @@ size_t GCM_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void GCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void GCM_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ARG_CHECK(offset <= buffer.size());
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
m_ctr->cipher(buf, buf, sz);
m_ghash->update(buf, sz);
@@ -287,11 +287,11 @@ size_t GCM_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void GCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void GCM_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ARG_CHECK(offset <= buffer.size());
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
if(sz < tag_size())
throw Exception("Insufficient input for GCM decryption, tag missing");
@@ -307,7 +307,7 @@ void GCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
auto mac = m_ghash->final();
- const byte* included_tag = &buffer[remaining+offset];
+ const uint8_t* included_tag = &buffer[remaining+offset];
if(!same_mem(mac.data(), included_tag, tag_size()))
throw Integrity_Failure("GCM tag check failed");
diff --git a/src/lib/modes/aead/gcm/gcm.h b/src/lib/modes/aead/gcm/gcm.h
index 65b6b0474..e2e3a2c9d 100644
--- a/src/lib/modes/aead/gcm/gcm.h
+++ b/src/lib/modes/aead/gcm/gcm.h
@@ -23,7 +23,7 @@ class GHASH;
class BOTAN_DLL GCM_Mode : public AEAD_Mode
{
public:
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override;
@@ -52,9 +52,9 @@ class BOTAN_DLL GCM_Mode : public AEAD_Mode
std::unique_ptr<StreamCipher> m_ctr;
std::unique_ptr<GHASH> m_ghash;
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
};
/**
@@ -77,7 +77,7 @@ class BOTAN_DLL GCM_Encryption final : public GCM_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -103,7 +103,7 @@ class BOTAN_DLL GCM_Decryption final : public GCM_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -113,18 +113,18 @@ class BOTAN_DLL GCM_Decryption final : public GCM_Mode
class BOTAN_DLL GHASH : public SymmetricAlgorithm
{
public:
- void set_associated_data(const byte ad[], size_t ad_len);
+ void set_associated_data(const uint8_t ad[], size_t ad_len);
- secure_vector<byte> nonce_hash(const byte nonce[], size_t len);
+ secure_vector<uint8_t> nonce_hash(const uint8_t nonce[], size_t len);
- void start(const byte nonce[], size_t len);
+ void start(const uint8_t nonce[], size_t len);
/*
* Assumes input len is multiple of 16
*/
- void update(const byte in[], size_t len);
+ void update(const uint8_t in[], size_t len);
- secure_vector<byte> final();
+ secure_vector<uint8_t> final();
Key_Length_Specification key_spec() const override
{ return Key_Length_Specification(16); }
@@ -135,23 +135,23 @@ class BOTAN_DLL GHASH : public SymmetricAlgorithm
std::string name() const override { return "GHASH"; }
protected:
- void ghash_update(secure_vector<byte>& x,
- const byte input[], size_t input_len);
+ void ghash_update(secure_vector<uint8_t>& x,
+ const uint8_t input[], size_t input_len);
- void add_final_block(secure_vector<byte>& x,
+ void add_final_block(secure_vector<uint8_t>& x,
size_t ad_len, size_t pt_len);
- secure_vector<byte> m_H;
- secure_vector<byte> m_H_ad;
- secure_vector<byte> m_ghash;
+ secure_vector<uint8_t> m_H;
+ secure_vector<uint8_t> m_H_ad;
+ secure_vector<uint8_t> m_ghash;
size_t m_ad_len = 0;
private:
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
- void gcm_multiply(secure_vector<byte>& x) const;
+ void gcm_multiply(secure_vector<uint8_t>& x) const;
- secure_vector<byte> m_nonce;
+ secure_vector<uint8_t> m_nonce;
size_t m_text_len = 0;
};
diff --git a/src/lib/modes/aead/ocb/ocb.cpp b/src/lib/modes/aead/ocb/ocb.cpp
index c530dda5d..84787ad38 100644
--- a/src/lib/modes/aead/ocb/ocb.cpp
+++ b/src/lib/modes/aead/ocb/ocb.cpp
@@ -24,13 +24,13 @@ class L_computer
m_L.push_back(poly_double(dollar()));
}
- const secure_vector<byte>& star() const { return m_L_star; }
+ const secure_vector<uint8_t>& star() const { return m_L_star; }
- const secure_vector<byte>& dollar() const { return m_L_dollar; }
+ const secure_vector<uint8_t>& dollar() const { return m_L_dollar; }
- const secure_vector<byte>& operator()(size_t i) const { return get(i); }
+ const secure_vector<uint8_t>& operator()(size_t i) const { return get(i); }
- const secure_vector<byte>& compute_offsets(secure_vector<byte>& offset,
+ const secure_vector<uint8_t>& compute_offsets(secure_vector<uint8_t>& offset,
size_t block_index,
size_t blocks) const
{
@@ -46,7 +46,7 @@ class L_computer
}
private:
- const secure_vector<byte>& get(size_t i) const
+ const secure_vector<uint8_t>& get(size_t i) const
{
while(m_L.size() <= i)
m_L.push_back(poly_double(m_L.back()));
@@ -54,14 +54,14 @@ class L_computer
return m_L.at(i);
}
- secure_vector<byte> poly_double(const secure_vector<byte>& in) const
+ secure_vector<uint8_t> poly_double(const secure_vector<uint8_t>& in) const
{
return CMAC::poly_double(in);
}
- secure_vector<byte> m_L_dollar, m_L_star;
- mutable std::vector<secure_vector<byte>> m_L;
- mutable secure_vector<byte> m_offset_buf;
+ secure_vector<uint8_t> m_L_dollar, m_L_star;
+ mutable std::vector<secure_vector<uint8_t>> m_L;
+ mutable secure_vector<uint8_t> m_offset_buf;
};
namespace {
@@ -69,14 +69,14 @@ namespace {
/*
* OCB's HASH
*/
-secure_vector<byte> ocb_hash(const L_computer& L,
+secure_vector<uint8_t> ocb_hash(const L_computer& L,
const BlockCipher& cipher,
- const byte ad[], size_t ad_len)
+ const uint8_t ad[], size_t ad_len)
{
- secure_vector<byte> sum(16);
- secure_vector<byte> offset(16);
+ secure_vector<uint8_t> sum(16);
+ secure_vector<uint8_t> offset(16);
- secure_vector<byte> buf(16);
+ secure_vector<uint8_t> buf(16);
const size_t ad_blocks = (ad_len / 16);
const size_t ad_remainder = (ad_len % 16);
@@ -165,30 +165,30 @@ Key_Length_Specification OCB_Mode::key_spec() const
return m_cipher->key_spec();
}
-void OCB_Mode::key_schedule(const byte key[], size_t length)
+void OCB_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_cipher->set_key(key, length);
m_L.reset(new L_computer(*m_cipher));
}
-void OCB_Mode::set_associated_data(const byte ad[], size_t ad_len)
+void OCB_Mode::set_associated_data(const uint8_t ad[], size_t ad_len)
{
BOTAN_ASSERT(m_L, "A key was set");
m_ad_hash = ocb_hash(*m_L, *m_cipher, ad, ad_len);
}
-secure_vector<byte>
-OCB_Mode::update_nonce(const byte nonce[], size_t nonce_len)
+secure_vector<uint8_t>
+OCB_Mode::update_nonce(const uint8_t nonce[], size_t nonce_len)
{
BOTAN_ASSERT(nonce_len < 16, "OCB nonce is less than cipher block size");
- secure_vector<byte> nonce_buf(16);
+ secure_vector<uint8_t> nonce_buf(16);
copy_mem(&nonce_buf[16 - nonce_len], nonce, nonce_len);
nonce_buf[0] = ((tag_size() * 8) % 128) << 1;
nonce_buf[16 - nonce_len - 1] = 1;
- const byte bottom = nonce_buf[16-1] & 0x3F;
+ const uint8_t bottom = nonce_buf[16-1] & 0x3F;
nonce_buf[16-1] &= 0xC0;
const bool need_new_stretch = (m_last_nonce != nonce_buf);
@@ -210,7 +210,7 @@ OCB_Mode::update_nonce(const byte nonce[], size_t nonce_len)
const size_t shift_bytes = bottom / 8;
const size_t shift_bits = bottom % 8;
- secure_vector<byte> offset(16);
+ secure_vector<uint8_t> offset(16);
for(size_t i = 0; i != 16; ++i)
{
offset[i] = (m_stretch[i+shift_bytes] << shift_bits);
@@ -220,7 +220,7 @@ OCB_Mode::update_nonce(const byte nonce[], size_t nonce_len)
return offset;
}
-void OCB_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void OCB_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -232,7 +232,7 @@ void OCB_Mode::start_msg(const byte nonce[], size_t nonce_len)
m_block_index = 0;
}
-void OCB_Encryption::encrypt(byte buffer[], size_t blocks)
+void OCB_Encryption::encrypt(uint8_t buffer[], size_t blocks)
{
const size_t par_blocks = m_checksum.size() / 16;
@@ -262,11 +262,11 @@ size_t OCB_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void OCB_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
if(sz)
{
@@ -278,27 +278,27 @@ void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
if(remainder_bytes)
{
BOTAN_ASSERT(remainder_bytes < 16, "Only a partial block left");
- byte* remainder = &buf[sz - remainder_bytes];
+ uint8_t* remainder = &buf[sz - remainder_bytes];
xor_buf(m_checksum.data(), remainder, remainder_bytes);
m_checksum[remainder_bytes] ^= 0x80;
m_offset ^= m_L->star(); // Offset_*
- secure_vector<byte> zeros(16);
+ secure_vector<uint8_t> zeros(16);
m_cipher->encrypt(m_offset, zeros);
xor_buf(remainder, zeros.data(), remainder_bytes);
}
}
- secure_vector<byte> checksum(16);
+ secure_vector<uint8_t> checksum(16);
// fold checksum
for(size_t i = 0; i != m_checksum.size(); ++i)
checksum[i % checksum.size()] ^= m_checksum[i];
// now compute the tag
- secure_vector<byte> mac = m_offset;
+ secure_vector<uint8_t> mac = m_offset;
mac ^= checksum;
mac ^= m_L->dollar();
@@ -313,7 +313,7 @@ void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
m_block_index = 0;
}
-void OCB_Decryption::decrypt(byte buffer[], size_t blocks)
+void OCB_Decryption::decrypt(uint8_t buffer[], size_t blocks)
{
const size_t par_bytes = m_cipher->parallel_bytes();
@@ -347,11 +347,11 @@ size_t OCB_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void OCB_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
@@ -368,11 +368,11 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(final_bytes < 16, "Only a partial block left");
- byte* remainder = &buf[remaining - final_bytes];
+ uint8_t* remainder = &buf[remaining - final_bytes];
m_offset ^= m_L->star(); // Offset_*
- secure_vector<byte> pad(16);
+ secure_vector<uint8_t> pad(16);
m_cipher->encrypt(m_offset, pad); // P_*
xor_buf(remainder, pad.data(), final_bytes);
@@ -382,14 +382,14 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
}
}
- secure_vector<byte> checksum(16);
+ secure_vector<uint8_t> checksum(16);
// fold checksum
for(size_t i = 0; i != m_checksum.size(); ++i)
checksum[i % checksum.size()] ^= m_checksum[i];
// compute the mac
- secure_vector<byte> mac = m_offset;
+ secure_vector<uint8_t> mac = m_offset;
mac ^= checksum;
mac ^= m_L->dollar();
@@ -403,7 +403,7 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
m_block_index = 0;
// compare mac
- const byte* included_tag = &buf[remaining];
+ const uint8_t* included_tag = &buf[remaining];
if(!same_mem(mac.data(), included_tag, tag_size()))
throw Integrity_Failure("OCB tag check failed");
diff --git a/src/lib/modes/aead/ocb/ocb.h b/src/lib/modes/aead/ocb/ocb.h
index dfdb8c18c..cac87ddb6 100644
--- a/src/lib/modes/aead/ocb/ocb.h
+++ b/src/lib/modes/aead/ocb/ocb.h
@@ -28,7 +28,7 @@ class L_computer;
class BOTAN_DLL OCB_Mode : public AEAD_Mode
{
public:
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override;
@@ -58,19 +58,19 @@ class BOTAN_DLL OCB_Mode : public AEAD_Mode
size_t m_block_index = 0;
- secure_vector<byte> m_checksum;
- secure_vector<byte> m_offset;
- secure_vector<byte> m_ad_hash;
+ secure_vector<uint8_t> m_checksum;
+ secure_vector<uint8_t> m_offset;
+ secure_vector<uint8_t> m_ad_hash;
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<byte> update_nonce(const byte nonce[], size_t nonce_len);
+ secure_vector<uint8_t> update_nonce(const uint8_t nonce[], size_t nonce_len);
size_t m_tag_size = 0;
- secure_vector<byte> m_last_nonce;
- secure_vector<byte> m_stretch;
+ secure_vector<uint8_t> m_last_nonce;
+ secure_vector<uint8_t> m_stretch;
};
class BOTAN_DLL OCB_Encryption final : public OCB_Mode
@@ -90,9 +90,9 @@ class BOTAN_DLL OCB_Encryption final : public OCB_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
private:
- void encrypt(byte input[], size_t blocks);
+ void encrypt(uint8_t input[], size_t blocks);
};
class BOTAN_DLL OCB_Decryption final : public OCB_Mode
@@ -115,9 +115,9 @@ class BOTAN_DLL OCB_Decryption final : public OCB_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
private:
- void decrypt(byte input[], size_t blocks);
+ void decrypt(uint8_t input[], size_t blocks);
};
}
diff --git a/src/lib/modes/aead/siv/siv.cpp b/src/lib/modes/aead/siv/siv.cpp
index 373a2627c..c4db3d785 100644
--- a/src/lib/modes/aead/siv/siv.cpp
+++ b/src/lib/modes/aead/siv/siv.cpp
@@ -51,7 +51,7 @@ size_t SIV_Mode::update_granularity() const
/*
This value does not particularly matter as regardless SIV_Mode::update
buffers all input, so in theory this could be 1. However as for instance
- Transform_Filter creates update_granularity() byte buffers, use a
+ Transform_Filter creates update_granularity() uint8_t buffers, use a
somewhat large size to avoid bouncing on a tiny buffer.
*/
return 128;
@@ -62,7 +62,7 @@ Key_Length_Specification SIV_Mode::key_spec() const
return m_cmac->key_spec().multiple(2);
}
-void SIV_Mode::key_schedule(const byte key[], size_t length)
+void SIV_Mode::key_schedule(const uint8_t key[], size_t length)
{
const size_t keylen = length / 2;
m_cmac->set_key(key, keylen);
@@ -70,7 +70,7 @@ void SIV_Mode::key_schedule(const byte key[], size_t length)
m_ad_macs.clear();
}
-void SIV_Mode::set_associated_data_n(size_t n, const byte ad[], size_t length)
+void SIV_Mode::set_associated_data_n(size_t n, const uint8_t ad[], size_t length)
{
if(n >= m_ad_macs.size())
m_ad_macs.resize(n+1);
@@ -78,7 +78,7 @@ void SIV_Mode::set_associated_data_n(size_t n, const byte ad[], size_t length)
m_ad_macs[n] = m_cmac->process(ad, length);
}
-void SIV_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void SIV_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -98,11 +98,11 @@ size_t SIV_Mode::process(uint8_t buf[], size_t sz)
return 0;
}
-secure_vector<byte> SIV_Mode::S2V(const byte* text, size_t text_len)
+secure_vector<uint8_t> SIV_Mode::S2V(const uint8_t* text, size_t text_len)
{
- const byte zero[16] = { 0 };
+ const uint8_t zero[16] = { 0 };
- secure_vector<byte> V = m_cmac->process(zero, 16);
+ secure_vector<uint8_t> V = m_cmac->process(zero, 16);
for(size_t i = 0; i != m_ad_macs.size(); ++i)
{
@@ -131,7 +131,7 @@ secure_vector<byte> SIV_Mode::S2V(const byte* text, size_t text_len)
return m_cmac->final();
}
-void SIV_Mode::set_ctr_iv(secure_vector<byte> V)
+void SIV_Mode::set_ctr_iv(secure_vector<uint8_t> V)
{
V[8] &= 0x7F;
V[12] &= 0x7F;
@@ -139,13 +139,13 @@ void SIV_Mode::set_ctr_iv(secure_vector<byte> V)
ctr().set_iv(V.data(), V.size());
}
-void SIV_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void SIV_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
- secure_vector<byte> V = S2V(buffer.data() + offset, buffer.size() - offset);
+ secure_vector<uint8_t> V = S2V(buffer.data() + offset, buffer.size() - offset);
buffer.insert(buffer.begin() + offset, V.begin(), V.end());
@@ -153,7 +153,7 @@ void SIV_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
ctr().cipher1(&buffer[offset + V.size()], buffer.size() - offset - V.size());
}
-void SIV_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void SIV_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
@@ -163,7 +163,7 @@ void SIV_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
- secure_vector<byte> V(buffer.data() + offset, buffer.data() + offset + 16);
+ secure_vector<uint8_t> V(buffer.data() + offset, buffer.data() + offset + 16);
set_ctr_iv(V);
@@ -171,7 +171,7 @@ void SIV_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer.data() + offset,
buffer.size() - offset - V.size());
- secure_vector<byte> T = S2V(buffer.data() + offset, buffer.size() - offset - V.size());
+ secure_vector<uint8_t> T = S2V(buffer.data() + offset, buffer.size() - offset - V.size());
if(T != V)
throw Integrity_Failure("SIV tag check failed");
diff --git a/src/lib/modes/aead/siv/siv.h b/src/lib/modes/aead/siv/siv.h
index 711d9e30c..ea6ad8234 100644
--- a/src/lib/modes/aead/siv/siv.h
+++ b/src/lib/modes/aead/siv/siv.h
@@ -30,9 +30,9 @@ class BOTAN_DLL SIV_Mode : public AEAD_Mode
* @param ad associated data
* @param ad_len length of associated data in bytes
*/
- void set_associated_data_n(size_t n, const byte ad[], size_t ad_len);
+ void set_associated_data_n(size_t n, const uint8_t ad[], size_t ad_len);
- void set_associated_data(const byte ad[], size_t ad_len) override
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override
{
set_associated_data_n(0, ad, ad_len);
}
@@ -56,21 +56,21 @@ class BOTAN_DLL SIV_Mode : public AEAD_Mode
StreamCipher& ctr() { return *m_ctr; }
- void set_ctr_iv(secure_vector<byte> V);
+ void set_ctr_iv(secure_vector<uint8_t> V);
- secure_vector<byte>& msg_buf() { return m_msg_buf; }
+ secure_vector<uint8_t>& msg_buf() { return m_msg_buf; }
- secure_vector<byte> S2V(const byte text[], size_t text_len);
+ secure_vector<uint8_t> S2V(const uint8_t text[], size_t text_len);
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
const std::string m_name;
std::unique_ptr<StreamCipher> m_ctr;
std::unique_ptr<MessageAuthenticationCode> m_cmac;
- secure_vector<byte> m_nonce, m_msg_buf;
- std::vector<secure_vector<byte>> m_ad_macs;
+ secure_vector<uint8_t> m_nonce, m_msg_buf;
+ std::vector<secure_vector<uint8_t>> m_ad_macs;
};
/**
@@ -84,7 +84,7 @@ class BOTAN_DLL SIV_Encryption final : public SIV_Mode
*/
explicit SIV_Encryption(BlockCipher* cipher) : SIV_Mode(cipher) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override
{ return input_length + tag_size(); }
@@ -103,7 +103,7 @@ class BOTAN_DLL SIV_Decryption final : public SIV_Mode
*/
explicit SIV_Decryption(BlockCipher* cipher) : SIV_Mode(cipher) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override
{
diff --git a/src/lib/modes/cbc/cbc.cpp b/src/lib/modes/cbc/cbc.cpp
index 9fbb7023f..188b4a0aa 100644
--- a/src/lib/modes/cbc/cbc.cpp
+++ b/src/lib/modes/cbc/cbc.cpp
@@ -62,12 +62,12 @@ bool CBC_Mode::valid_nonce_length(size_t n) const
return (n == 0 || n == cipher().block_size());
}
-void CBC_Mode::key_schedule(const byte key[], size_t length)
+void CBC_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_cipher->set_key(key, length);
}
-void CBC_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void CBC_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -101,7 +101,7 @@ size_t CBC_Encryption::process(uint8_t buf[], size_t sz)
BOTAN_ASSERT(sz % BS == 0, "CBC input is full blocks");
const size_t blocks = sz / BS;
- const byte* prev_block = state_ptr();
+ const uint8_t* prev_block = state_ptr();
if(blocks)
{
@@ -118,7 +118,7 @@ size_t CBC_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void CBC_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CBC_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
@@ -149,10 +149,10 @@ size_t CTS_Encryption::output_length(size_t input_length) const
return input_length; // no ciphertext expansion in CTS
}
-void CTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CTS_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
const size_t sz = buffer.size() - offset;
const size_t BS = cipher().block_size();
@@ -174,7 +174,7 @@ void CTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
const size_t final_bytes = sz - full_blocks;
BOTAN_ASSERT(final_bytes > BS && final_bytes < 2*BS, "Left over size in expected range");
- secure_vector<byte> last(buf + full_blocks, buf + full_blocks + final_bytes);
+ secure_vector<uint8_t> last(buf + full_blocks, buf + full_blocks + final_bytes);
buffer.resize(full_blocks + offset);
update(buffer, offset);
@@ -229,7 +229,7 @@ size_t CBC_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void CBC_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CBC_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
@@ -265,11 +265,11 @@ size_t CTS_Decryption::minimum_final_size() const
return cipher().block_size() + 1;
}
-void CTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CTS_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
@@ -291,7 +291,7 @@ void CTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
const size_t final_bytes = sz - full_blocks;
BOTAN_ASSERT(final_bytes > BS && final_bytes < 2*BS, "Left over size in expected range");
- secure_vector<byte> last(buf + full_blocks, buf + full_blocks + final_bytes);
+ secure_vector<uint8_t> last(buf + full_blocks, buf + full_blocks + final_bytes);
buffer.resize(full_blocks + offset);
update(buffer, offset);
diff --git a/src/lib/modes/cbc/cbc.h b/src/lib/modes/cbc/cbc.h
index 1b7cbd323..a44a9b5d9 100644
--- a/src/lib/modes/cbc/cbc.h
+++ b/src/lib/modes/cbc/cbc.h
@@ -46,18 +46,18 @@ class BOTAN_DLL CBC_Mode : public Cipher_Mode
return *m_padding;
}
- secure_vector<byte>& state() { return m_state; }
+ secure_vector<uint8_t>& state() { return m_state; }
- byte* state_ptr() { return m_state.data(); }
+ uint8_t* state_ptr() { return m_state.data(); }
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
std::unique_ptr<BlockCipher> m_cipher;
std::unique_ptr<BlockCipherModePaddingMethod> m_padding;
- secure_vector<byte> m_state;
+ secure_vector<uint8_t> m_state;
};
/**
@@ -75,7 +75,7 @@ class BOTAN_DLL CBC_Encryption : public CBC_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override;
@@ -95,7 +95,7 @@ class BOTAN_DLL CTS_Encryption final : public CBC_Encryption
size_t output_length(size_t input_length) const override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t minimum_final_size() const override;
@@ -117,7 +117,7 @@ class BOTAN_DLL CBC_Decryption : public CBC_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override;
@@ -126,7 +126,7 @@ class BOTAN_DLL CBC_Decryption : public CBC_Mode
void reset() override;
private:
- secure_vector<byte> m_tempbuf;
+ secure_vector<uint8_t> m_tempbuf;
};
/**
@@ -140,7 +140,7 @@ class BOTAN_DLL CTS_Decryption final : public CBC_Decryption
*/
explicit CTS_Decryption(BlockCipher* cipher) : CBC_Decryption(cipher, nullptr) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t minimum_final_size() const override;
diff --git a/src/lib/modes/cfb/cfb.cpp b/src/lib/modes/cfb/cfb.cpp
index 2d1477e27..148e16c6c 100644
--- a/src/lib/modes/cfb/cfb.cpp
+++ b/src/lib/modes/cfb/cfb.cpp
@@ -70,12 +70,12 @@ bool CFB_Mode::valid_nonce_length(size_t n) const
return (n == cipher().block_size());
}
-void CFB_Mode::key_schedule(const byte key[], size_t length)
+void CFB_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_cipher->set_key(key, length);
}
-void CFB_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void CFB_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -89,7 +89,7 @@ size_t CFB_Encryption::process(uint8_t buf[], size_t sz)
{
const size_t BS = cipher().block_size();
- secure_vector<byte>& state = shift_register();
+ secure_vector<uint8_t>& state = shift_register();
const size_t shift = feedback();
size_t left = sz;
@@ -112,7 +112,7 @@ size_t CFB_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void CFB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CFB_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
update(buffer, offset);
}
@@ -121,7 +121,7 @@ size_t CFB_Decryption::process(uint8_t buf[], size_t sz)
{
const size_t BS = cipher().block_size();
- secure_vector<byte>& state = shift_register();
+ secure_vector<uint8_t>& state = shift_register();
const size_t shift = feedback();
size_t left = sz;
@@ -148,7 +148,7 @@ size_t CFB_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void CFB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CFB_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
update(buffer, offset);
}
diff --git a/src/lib/modes/cfb/cfb.h b/src/lib/modes/cfb/cfb.h
index 18611f3f2..a128539a4 100644
--- a/src/lib/modes/cfb/cfb.h
+++ b/src/lib/modes/cfb/cfb.h
@@ -44,17 +44,17 @@ class BOTAN_DLL CFB_Mode : public Cipher_Mode
size_t feedback() const { return m_feedback_bytes; }
- secure_vector<byte>& shift_register() { return m_shift_register; }
+ secure_vector<uint8_t>& shift_register() { return m_shift_register; }
- secure_vector<byte>& keystream_buf() { return m_keystream_buf; }
+ secure_vector<uint8_t>& keystream_buf() { return m_keystream_buf; }
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
std::unique_ptr<BlockCipher> m_cipher;
- secure_vector<byte> m_shift_register;
- secure_vector<byte> m_keystream_buf;
+ secure_vector<uint8_t> m_shift_register;
+ secure_vector<uint8_t> m_keystream_buf;
size_t m_feedback_bytes;
};
@@ -75,7 +75,7 @@ class BOTAN_DLL CFB_Encryption final : public CFB_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -95,7 +95,7 @@ class BOTAN_DLL CFB_Decryption final : public CFB_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
}
diff --git a/src/lib/modes/cipher_mode.h b/src/lib/modes/cipher_mode.h
index 8bf58f10a..cdf16e37c 100644
--- a/src/lib/modes/cipher_mode.h
+++ b/src/lib/modes/cipher_mode.h
@@ -28,14 +28,14 @@ class BOTAN_DLL Cipher_Mode
/*
* Prepare for processing a message under the specified nonce
*/
- virtual void start_msg(const byte nonce[], size_t nonce_len) = 0;
+ virtual void start_msg(const uint8_t nonce[], size_t nonce_len) = 0;
/**
* Begin processing a message.
* @param nonce the per message nonce
*/
template<typename Alloc>
- void start(const std::vector<byte, Alloc>& nonce)
+ void start(const std::vector<uint8_t, Alloc>& nonce)
{
start_msg(nonce.data(), nonce.size());
}
@@ -45,7 +45,7 @@ class BOTAN_DLL Cipher_Mode
* @param nonce the per message nonce
* @param nonce_len length of nonce
*/
- void start(const byte nonce[], size_t nonce_len)
+ void start(const uint8_t nonce[], size_t nonce_len)
{
start_msg(nonce, nonce_len);
}
@@ -74,14 +74,14 @@ class BOTAN_DLL Cipher_Mode
virtual size_t process(uint8_t msg[], size_t msg_len) = 0;
/**
- * Process some data. Input must be in size update_granularity() byte blocks.
+ * Process some data. Input must be in size update_granularity() uint8_t blocks.
* @param buffer in/out parameter which will possibly be resized
* @param offset an offset into blocks to begin processing
*/
- void update(secure_vector<byte>& buffer, size_t offset = 0)
+ void update(secure_vector<uint8_t>& buffer, size_t offset = 0)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset ok");
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
const size_t buf_size = buffer.size() - offset;
const size_t written = process(buf, buf_size);
@@ -95,7 +95,7 @@ class BOTAN_DLL Cipher_Mode
* minimum_final_size() bytes, and will be set to any final output
* @param offset an offset into final_block to begin processing
*/
- virtual void finish(secure_vector<byte>& final_block, size_t offset = 0) = 0;
+ virtual void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) = 0;
/**
* Returns the size of the output if this transform is used to process a
@@ -169,7 +169,7 @@ class BOTAN_DLL Cipher_Mode
* @param key contains the key material
*/
template<typename Alloc>
- void set_key(const std::vector<byte, Alloc>& key)
+ void set_key(const std::vector<uint8_t, Alloc>& key)
{
set_key(key.data(), key.size());
}
@@ -188,7 +188,7 @@ class BOTAN_DLL Cipher_Mode
* @param key contains the key material
* @param length in bytes of key param
*/
- void set_key(const byte key[], size_t length)
+ void set_key(const uint8_t key[], size_t length)
{
if(!valid_keylength(length))
throw Invalid_Key_Length(name(), length);
@@ -202,7 +202,7 @@ class BOTAN_DLL Cipher_Mode
virtual std::string provider() const { return "base"; }
private:
- virtual void key_schedule(const byte key[], size_t length) = 0;
+ virtual void key_schedule(const uint8_t key[], size_t length) = 0;
};
/**
diff --git a/src/lib/modes/mode_pad/mode_pad.cpp b/src/lib/modes/mode_pad/mode_pad.cpp
index c84c2030e..afcce786d 100644
--- a/src/lib/modes/mode_pad/mode_pad.cpp
+++ b/src/lib/modes/mode_pad/mode_pad.cpp
@@ -38,11 +38,11 @@ BlockCipherModePaddingMethod* get_bc_pad(const std::string& algo_spec)
/*
* Pad with PKCS #7 Method
*/
-void PKCS7_Padding::add_padding(secure_vector<byte>& buffer,
+void PKCS7_Padding::add_padding(secure_vector<uint8_t>& buffer,
size_t last_byte_pos,
size_t block_size) const
{
- const byte pad_value = static_cast<byte>(block_size - last_byte_pos);
+ const uint8_t pad_value = static_cast<uint8_t>(block_size - last_byte_pos);
for(size_t i = 0; i != pad_value; ++i)
buffer.push_back(pad_value);
@@ -51,11 +51,11 @@ void PKCS7_Padding::add_padding(secure_vector<byte>& buffer,
/*
* Unpad with PKCS #7 Method
*/
-size_t PKCS7_Padding::unpad(const byte block[], size_t size) const
+size_t PKCS7_Padding::unpad(const uint8_t block[], size_t size) const
{
CT::poison(block,size);
size_t bad_input = 0;
- const byte last_byte = block[size-1];
+ const uint8_t last_byte = block[size-1];
bad_input |= CT::expand_mask(last_byte > size);
@@ -76,11 +76,11 @@ size_t PKCS7_Padding::unpad(const byte block[], size_t size) const
/*
* Pad with ANSI X9.23 Method
*/
-void ANSI_X923_Padding::add_padding(secure_vector<byte>& buffer,
+void ANSI_X923_Padding::add_padding(secure_vector<uint8_t>& buffer,
size_t last_byte_pos,
size_t block_size) const
{
- const byte pad_value = static_cast<byte>(block_size - last_byte_pos);
+ const uint8_t pad_value = static_cast<uint8_t>(block_size - last_byte_pos);
for(size_t i = last_byte_pos; i < block_size-1; ++i)
{
@@ -92,7 +92,7 @@ void ANSI_X923_Padding::add_padding(secure_vector<byte>& buffer,
/*
* Unpad with ANSI X9.23 Method
*/
-size_t ANSI_X923_Padding::unpad(const byte block[], size_t size) const
+size_t ANSI_X923_Padding::unpad(const uint8_t block[], size_t size) const
{
CT::poison(block,size);
size_t bad_input = 0;
@@ -116,7 +116,7 @@ size_t ANSI_X923_Padding::unpad(const byte block[], size_t size) const
/*
* Pad with One and Zeros Method
*/
-void OneAndZeros_Padding::add_padding(secure_vector<byte>& buffer,
+void OneAndZeros_Padding::add_padding(secure_vector<uint8_t>& buffer,
size_t last_byte_pos,
size_t block_size) const
{
@@ -129,19 +129,19 @@ void OneAndZeros_Padding::add_padding(secure_vector<byte>& buffer,
/*
* Unpad with One and Zeros Method
*/
-size_t OneAndZeros_Padding::unpad(const byte block[], size_t size) const
+size_t OneAndZeros_Padding::unpad(const uint8_t block[], size_t size) const
{
CT::poison(block, size);
- byte bad_input = 0;
- byte seen_one = 0;
+ uint8_t bad_input = 0;
+ uint8_t seen_one = 0;
size_t pad_pos = size - 1;
size_t i = size;
while(i)
{
- seen_one |= CT::is_equal<byte>(block[i-1],0x80);
- pad_pos -= CT::select<byte>(~seen_one, 1, 0);
- bad_input |= ~CT::is_zero<byte>(block[i-1]) & ~seen_one;
+ seen_one |= CT::is_equal<uint8_t>(block[i-1],0x80);
+ pad_pos -= CT::select<uint8_t>(~seen_one, 1, 0);
+ bad_input |= ~CT::is_zero<uint8_t>(block[i-1]) & ~seen_one;
i--;
}
bad_input |= ~seen_one;
@@ -156,11 +156,11 @@ size_t OneAndZeros_Padding::unpad(const byte block[], size_t size) const
/*
* Pad with ESP Padding Method
*/
-void ESP_Padding::add_padding(secure_vector<byte>& buffer,
+void ESP_Padding::add_padding(secure_vector<uint8_t>& buffer,
size_t last_byte_pos,
size_t block_size) const
{
- byte pad_value = 0x01;
+ uint8_t pad_value = 0x01;
for(size_t i = last_byte_pos; i < block_size; ++i)
{
@@ -171,7 +171,7 @@ void ESP_Padding::add_padding(secure_vector<byte>& buffer,
/*
* Unpad with ESP Padding Method
*/
-size_t ESP_Padding::unpad(const byte block[], size_t size) const
+size_t ESP_Padding::unpad(const uint8_t block[], size_t size) const
{
CT::poison(block,size);
diff --git a/src/lib/modes/mode_pad/mode_pad.h b/src/lib/modes/mode_pad/mode_pad.h
index 4f07bc6ae..cfa27463b 100644
--- a/src/lib/modes/mode_pad/mode_pad.h
+++ b/src/lib/modes/mode_pad/mode_pad.h
@@ -32,7 +32,7 @@ class BOTAN_DLL BlockCipherModePaddingMethod
* @param final_block_bytes size of the final block in bytes
* @param block_size size of each block in bytes
*/
- virtual void add_padding(secure_vector<byte>& buffer,
+ virtual void add_padding(secure_vector<uint8_t>& buffer,
size_t final_block_bytes,
size_t block_size) const = 0;
@@ -42,7 +42,7 @@ class BOTAN_DLL BlockCipherModePaddingMethod
* @param size the size of the block in bytes
* @return number of padding bytes
*/
- virtual size_t unpad(const byte block[],
+ virtual size_t unpad(const uint8_t block[],
size_t size) const = 0;
/**
@@ -68,11 +68,11 @@ class BOTAN_DLL BlockCipherModePaddingMethod
class BOTAN_DLL PKCS7_Padding final : public BlockCipherModePaddingMethod
{
public:
- void add_padding(secure_vector<byte>& buffer,
+ void add_padding(secure_vector<uint8_t>& buffer,
size_t final_block_bytes,
size_t block_size) const override;
- size_t unpad(const byte[], size_t) const override;
+ size_t unpad(const uint8_t[], size_t) const override;
bool valid_blocksize(size_t bs) const override { return (bs > 0 && bs < 256); }
@@ -85,11 +85,11 @@ class BOTAN_DLL PKCS7_Padding final : public BlockCipherModePaddingMethod
class BOTAN_DLL ANSI_X923_Padding final : public BlockCipherModePaddingMethod
{
public:
- void add_padding(secure_vector<byte>& buffer,
+ void add_padding(secure_vector<uint8_t>& buffer,
size_t final_block_bytes,
size_t block_size) const override;
- size_t unpad(const byte[], size_t) const override;
+ size_t unpad(const uint8_t[], size_t) const override;
bool valid_blocksize(size_t bs) const override { return (bs > 0 && bs < 256); }
@@ -102,11 +102,11 @@ class BOTAN_DLL ANSI_X923_Padding final : public BlockCipherModePaddingMethod
class BOTAN_DLL OneAndZeros_Padding final : public BlockCipherModePaddingMethod
{
public:
- void add_padding(secure_vector<byte>& buffer,
+ void add_padding(secure_vector<uint8_t>& buffer,
size_t final_block_bytes,
size_t block_size) const override;
- size_t unpad(const byte[], size_t) const override;
+ size_t unpad(const uint8_t[], size_t) const override;
bool valid_blocksize(size_t bs) const override { return (bs > 0); }
@@ -119,11 +119,11 @@ class BOTAN_DLL OneAndZeros_Padding final : public BlockCipherModePaddingMethod
class BOTAN_DLL ESP_Padding final : public BlockCipherModePaddingMethod
{
public:
- void add_padding(secure_vector<byte>& buffer,
+ void add_padding(secure_vector<uint8_t>& buffer,
size_t final_block_bytes,
size_t block_size) const override;
- size_t unpad(const byte[], size_t) const override;
+ size_t unpad(const uint8_t[], size_t) const override;
bool valid_blocksize(size_t bs) const override { return (bs > 0); }
@@ -136,9 +136,9 @@ class BOTAN_DLL ESP_Padding final : public BlockCipherModePaddingMethod
class BOTAN_DLL Null_Padding final : public BlockCipherModePaddingMethod
{
public:
- void add_padding(secure_vector<byte>&, size_t, size_t) const override {}
+ void add_padding(secure_vector<uint8_t>&, size_t, size_t) const override {}
- size_t unpad(const byte[], size_t size) const override { return size; }
+ size_t unpad(const uint8_t[], size_t size) const override { return size; }
bool valid_blocksize(size_t) const override { return true; }
diff --git a/src/lib/modes/stream_mode.h b/src/lib/modes/stream_mode.h
index 83b0543c9..e32044a4b 100644
--- a/src/lib/modes/stream_mode.h
+++ b/src/lib/modes/stream_mode.h
@@ -27,7 +27,7 @@ class BOTAN_DLL Stream_Cipher_Mode : public Cipher_Mode
return sz;
}
- void finish(secure_vector<byte>& buf, size_t offset) override
+ void finish(secure_vector<uint8_t>& buf, size_t offset) override
{ return update(buf, offset); }
size_t output_length(size_t input_length) const override { return input_length; }
@@ -54,12 +54,12 @@ class BOTAN_DLL Stream_Cipher_Mode : public Cipher_Mode
void reset() override { /* no msg state */ return; }
private:
- void start_msg(const byte nonce[], size_t nonce_len) override
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override
{
m_cipher->set_iv(nonce, nonce_len);
}
- void key_schedule(const byte key[], size_t length) override
+ void key_schedule(const uint8_t key[], size_t length) override
{
m_cipher->set_key(key, length);
}
diff --git a/src/lib/modes/xts/xts.cpp b/src/lib/modes/xts/xts.cpp
index 13dc932ea..9487bd835 100644
--- a/src/lib/modes/xts/xts.cpp
+++ b/src/lib/modes/xts/xts.cpp
@@ -13,10 +13,10 @@ namespace Botan {
namespace {
-void poly_double_128(byte out[], const byte in[])
+void poly_double_128(uint8_t out[], const uint8_t in[])
{
- u64bit X0 = load_le<u64bit>(in, 0);
- u64bit X1 = load_le<u64bit>(in, 1);
+ uint64_t X0 = load_le<uint64_t>(in, 0);
+ uint64_t X1 = load_le<uint64_t>(in, 1);
const bool carry = static_cast<bool>((X1 >> 63) != 0);
@@ -29,9 +29,9 @@ void poly_double_128(byte out[], const byte in[])
store_le(out, X0, X1);
}
-void poly_double_64(byte out[], const byte in[])
+void poly_double_64(uint8_t out[], const uint8_t in[])
{
- u64bit X = load_le<u64bit>(in, 0);
+ uint64_t X = load_le<uint64_t>(in, 0);
const bool carry = static_cast<bool>((X >> 63) != 0);
X <<= 1;
if(carry)
@@ -39,7 +39,7 @@ void poly_double_64(byte out[], const byte in[])
store_le(X, out);
}
-inline void poly_double(byte out[], const byte in[], size_t size)
+inline void poly_double(uint8_t out[], const uint8_t in[], size_t size)
{
if(size == 8)
poly_double_64(out, in);
@@ -100,7 +100,7 @@ bool XTS_Mode::valid_nonce_length(size_t n) const
return cipher().block_size() == n;
}
-void XTS_Mode::key_schedule(const byte key[], size_t length)
+void XTS_Mode::key_schedule(const uint8_t key[], size_t length)
{
const size_t key_half = length / 2;
@@ -111,7 +111,7 @@ void XTS_Mode::key_schedule(const byte key[], size_t length)
m_tweak_cipher->set_key(&key[key_half], key_half);
}
-void XTS_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void XTS_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -167,11 +167,11 @@ size_t XTS_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void XTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void XTS_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= minimum_final_size(), "Have sufficient final input");
@@ -188,7 +188,7 @@ void XTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
const size_t final_bytes = sz - full_blocks;
BOTAN_ASSERT(final_bytes > BS && final_bytes < 2*BS, "Left over size in expected range");
- secure_vector<byte> last(buf + full_blocks, buf + full_blocks + final_bytes);
+ secure_vector<uint8_t> last(buf + full_blocks, buf + full_blocks + final_bytes);
buffer.resize(full_blocks + offset);
update(buffer, offset);
@@ -243,11 +243,11 @@ size_t XTS_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void XTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void XTS_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= minimum_final_size(), "Have sufficient final input");
@@ -264,7 +264,7 @@ void XTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
const size_t final_bytes = sz - full_blocks;
BOTAN_ASSERT(final_bytes > BS && final_bytes < 2*BS, "Left over size in expected range");
- secure_vector<byte> last(buf + full_blocks, buf + full_blocks + final_bytes);
+ secure_vector<uint8_t> last(buf + full_blocks, buf + full_blocks + final_bytes);
buffer.resize(full_blocks + offset);
update(buffer, offset);
diff --git a/src/lib/modes/xts/xts.h b/src/lib/modes/xts/xts.h
index 6d53b4312..69715c8b9 100644
--- a/src/lib/modes/xts/xts.h
+++ b/src/lib/modes/xts/xts.h
@@ -39,18 +39,18 @@ class BOTAN_DLL XTS_Mode : public Cipher_Mode
protected:
explicit XTS_Mode(BlockCipher* cipher);
- const byte* tweak() const { return m_tweak.data(); }
+ const uint8_t* tweak() const { return m_tweak.data(); }
const BlockCipher& cipher() const { return *m_cipher; }
void update_tweak(size_t last_used);
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
std::unique_ptr<BlockCipher> m_cipher, m_tweak_cipher;
- secure_vector<byte> m_tweak;
+ secure_vector<uint8_t> m_tweak;
};
/**
@@ -66,7 +66,7 @@ class BOTAN_DLL XTS_Encryption final : public XTS_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override;
};
@@ -84,7 +84,7 @@ class BOTAN_DLL XTS_Decryption final : public XTS_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override;
};
diff --git a/src/lib/passhash/bcrypt/bcrypt.cpp b/src/lib/passhash/bcrypt/bcrypt.cpp
index f7cf390e9..8cea34a97 100644
--- a/src/lib/passhash/bcrypt/bcrypt.cpp
+++ b/src/lib/passhash/bcrypt/bcrypt.cpp
@@ -14,10 +14,10 @@ namespace Botan {
namespace {
-std::string bcrypt_base64_encode(const byte input[], size_t length)
+std::string bcrypt_base64_encode(const uint8_t input[], size_t length)
{
// Bcrypt uses a non-standard base64 alphabet
- const byte OPENBSD_BASE64_SUB[256] = {
+ const uint8_t OPENBSD_BASE64_SUB[256] = {
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
@@ -48,14 +48,14 @@ std::string bcrypt_base64_encode(const byte input[], size_t length)
b64 = b64.substr(0, b64.size() - 1);
for(size_t i = 0; i != b64.size(); ++i)
- b64[i] = OPENBSD_BASE64_SUB[static_cast<byte>(b64[i])];
+ b64[i] = OPENBSD_BASE64_SUB[static_cast<uint8_t>(b64[i])];
return b64;
}
-std::vector<byte> bcrypt_base64_decode(std::string input)
+std::vector<uint8_t> bcrypt_base64_decode(std::string input)
{
- const byte OPENBSD_BASE64_SUB[256] = {
+ const uint8_t OPENBSD_BASE64_SUB[256] = {
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
@@ -81,27 +81,27 @@ std::vector<byte> bcrypt_base64_decode(std::string input)
};
for(size_t i = 0; i != input.size(); ++i)
- input[i] = OPENBSD_BASE64_SUB[static_cast<byte>(input[i])];
+ input[i] = OPENBSD_BASE64_SUB[static_cast<uint8_t>(input[i])];
return unlock(base64_decode(input));
}
std::string make_bcrypt(const std::string& pass,
- const std::vector<byte>& salt,
- u16bit work_factor)
+ const std::vector<uint8_t>& salt,
+ uint16_t work_factor)
{
- auto magic = std::vector<byte>{
+ auto magic = std::vector<uint8_t>{
0x4F, 0x72, 0x70, 0x68, 0x65, 0x61, 0x6E, 0x42,
0x65, 0x68, 0x6F, 0x6C, 0x64, 0x65, 0x72, 0x53,
0x63, 0x72, 0x79, 0x44, 0x6F, 0x75, 0x62, 0x74
};
- std::vector<byte> ctext = magic;
+ std::vector<uint8_t> ctext = magic;
Blowfish blowfish;
// Include the trailing NULL byte
- blowfish.eks_key_schedule(reinterpret_cast<const byte*>(pass.c_str()),
+ blowfish.eks_key_schedule(reinterpret_cast<const uint8_t*>(pass.c_str()),
pass.length() + 1,
salt.data(),
work_factor);
@@ -124,7 +124,7 @@ std::string make_bcrypt(const std::string& pass,
std::string generate_bcrypt(const std::string& pass,
RandomNumberGenerator& rng,
- u16bit work_factor)
+ uint16_t work_factor)
{
return make_bcrypt(pass, unlock(rng.random_vec(16)), work_factor);
}
@@ -138,9 +138,9 @@ bool check_bcrypt(const std::string& pass, const std::string& hash)
return false;
}
- const u16bit workfactor = to_u32bit(hash.substr(4, 2));
+ const uint16_t workfactor = to_u32bit(hash.substr(4, 2));
- const std::vector<byte> salt = bcrypt_base64_decode(hash.substr(7, 22));
+ const std::vector<uint8_t> salt = bcrypt_base64_decode(hash.substr(7, 22));
if(salt.size() != 16)
return false;
diff --git a/src/lib/passhash/bcrypt/bcrypt.h b/src/lib/passhash/bcrypt/bcrypt.h
index a460356d4..ccf3c04bb 100644
--- a/src/lib/passhash/bcrypt/bcrypt.h
+++ b/src/lib/passhash/bcrypt/bcrypt.h
@@ -22,7 +22,7 @@ namespace Botan {
*/
std::string BOTAN_DLL generate_bcrypt(const std::string& password,
RandomNumberGenerator& rng,
- u16bit work_factor = 10);
+ uint16_t work_factor = 10);
/**
* Check a previously created password hash
diff --git a/src/lib/passhash/passhash9/passhash9.cpp b/src/lib/passhash/passhash9/passhash9.cpp
index c6a2f7d9e..fef23515b 100644
--- a/src/lib/passhash/passhash9/passhash9.cpp
+++ b/src/lib/passhash/passhash9/passhash9.cpp
@@ -23,7 +23,7 @@ const size_t PASSHASH9_PBKDF_OUTPUT_LEN = 24; // 192 bits output
const size_t WORK_FACTOR_SCALE = 10000;
-std::unique_ptr<MessageAuthenticationCode> get_pbkdf_prf(byte alg_id)
+std::unique_ptr<MessageAuthenticationCode> get_pbkdf_prf(uint8_t alg_id)
{
if(alg_id == 0)
return MessageAuthenticationCode::create("HMAC(SHA-1)");
@@ -42,8 +42,8 @@ std::unique_ptr<MessageAuthenticationCode> get_pbkdf_prf(byte alg_id)
std::string generate_passhash9(const std::string& pass,
RandomNumberGenerator& rng,
- u16bit work_factor,
- byte alg_id)
+ uint16_t work_factor,
+ uint8_t alg_id)
{
std::unique_ptr<MessageAuthenticationCode> prf = get_pbkdf_prf(alg_id);
@@ -54,12 +54,12 @@ std::string generate_passhash9(const std::string& pass,
PKCS5_PBKDF2 kdf(prf.release()); // takes ownership of pointer
- secure_vector<byte> salt(SALT_BYTES);
+ secure_vector<uint8_t> salt(SALT_BYTES);
rng.randomize(salt.data(), salt.size());
const size_t kdf_iterations = WORK_FACTOR_SCALE * work_factor;
- secure_vector<byte> blob;
+ secure_vector<uint8_t> blob;
blob.push_back(alg_id);
blob.push_back(get_byte(0, work_factor));
blob.push_back(get_byte(1, work_factor));
@@ -90,14 +90,14 @@ bool check_passhash9(const std::string& pass, const std::string& hash)
if(hash[i] != MAGIC_PREFIX[i])
return false;
- secure_vector<byte> bin = base64_decode(hash.c_str() + MAGIC_PREFIX.size());
+ secure_vector<uint8_t> bin = base64_decode(hash.c_str() + MAGIC_PREFIX.size());
if(bin.size() != BINARY_LENGTH)
return false;
- byte alg_id = bin[0];
+ uint8_t alg_id = bin[0];
- const size_t work_factor = load_be<u16bit>(&bin[ALGID_BYTES], 0);
+ const size_t work_factor = load_be<uint16_t>(&bin[ALGID_BYTES], 0);
// Bug in the format, bad states shouldn't be representable, but are...
if(work_factor == 0)
@@ -116,7 +116,7 @@ bool check_passhash9(const std::string& pass, const std::string& hash)
PKCS5_PBKDF2 kdf(pbkdf_prf.release()); // takes ownership of pointer
- secure_vector<byte> cmp = kdf.derive_key(
+ secure_vector<uint8_t> cmp = kdf.derive_key(
PASSHASH9_PBKDF_OUTPUT_LEN,
pass,
&bin[ALGID_BYTES + WORKFACTOR_BYTES], SALT_BYTES,
diff --git a/src/lib/passhash/passhash9/passhash9.h b/src/lib/passhash/passhash9/passhash9.h
index 8e8293600..d2282481d 100644
--- a/src/lib/passhash/passhash9/passhash9.h
+++ b/src/lib/passhash/passhash9/passhash9.h
@@ -27,8 +27,8 @@ namespace Botan {
*/
std::string BOTAN_DLL generate_passhash9(const std::string& password,
RandomNumberGenerator& rng,
- u16bit work_factor = 10,
- byte alg_id = 1);
+ uint16_t work_factor = 10,
+ uint8_t alg_id = 1);
/**
* Check a previously created password hash
diff --git a/src/lib/pbkdf/pbkdf.cpp b/src/lib/pbkdf/pbkdf.cpp
index a3485654b..d9479bd8d 100644
--- a/src/lib/pbkdf/pbkdf.cpp
+++ b/src/lib/pbkdf/pbkdf.cpp
@@ -60,18 +60,18 @@ std::vector<std::string> PBKDF::providers(const std::string& algo_spec)
return probe_providers_of<PBKDF>(algo_spec, { "base", "openssl" });
}
-void PBKDF::pbkdf_timed(byte out[], size_t out_len,
+void PBKDF::pbkdf_timed(uint8_t out[], size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
std::chrono::milliseconds msec,
size_t& iterations) const
{
iterations = pbkdf(out, out_len, passphrase, salt, salt_len, 0, msec);
}
-void PBKDF::pbkdf_iterations(byte out[], size_t out_len,
+void PBKDF::pbkdf_iterations(uint8_t out[], size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations) const
{
if(iterations == 0)
@@ -83,23 +83,23 @@ void PBKDF::pbkdf_iterations(byte out[], size_t out_len,
BOTAN_ASSERT_EQUAL(iterations, iterations_run, "Expected PBKDF iterations");
}
-secure_vector<byte> PBKDF::pbkdf_iterations(size_t out_len,
+secure_vector<uint8_t> PBKDF::pbkdf_iterations(size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations) const
{
- secure_vector<byte> out(out_len);
+ secure_vector<uint8_t> out(out_len);
pbkdf_iterations(out.data(), out_len, passphrase, salt, salt_len, iterations);
return out;
}
-secure_vector<byte> PBKDF::pbkdf_timed(size_t out_len,
+secure_vector<uint8_t> PBKDF::pbkdf_timed(size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
std::chrono::milliseconds msec,
size_t& iterations) const
{
- secure_vector<byte> out(out_len);
+ secure_vector<uint8_t> out(out_len);
pbkdf_timed(out.data(), out_len, passphrase, salt, salt_len, msec, iterations);
return out;
}
diff --git a/src/lib/pbkdf/pbkdf.h b/src/lib/pbkdf/pbkdf.h
index 3abac0896..95cf4da02 100644
--- a/src/lib/pbkdf/pbkdf.h
+++ b/src/lib/pbkdf/pbkdf.h
@@ -64,9 +64,9 @@ class BOTAN_DLL PBKDF
* run until msec milliseconds has passed.
* @return the number of iterations performed
*/
- virtual size_t pbkdf(byte out[], size_t out_len,
+ virtual size_t pbkdf(uint8_t out[], size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations,
std::chrono::milliseconds msec) const = 0;
@@ -80,9 +80,9 @@ class BOTAN_DLL PBKDF
* @param salt_len length of salt in bytes
* @param iterations the number of iterations to use (use 10K or more)
*/
- void pbkdf_iterations(byte out[], size_t out_len,
+ void pbkdf_iterations(uint8_t out[], size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations) const;
/**
@@ -97,9 +97,9 @@ class BOTAN_DLL PBKDF
* run until msec milliseconds has passed.
* @param iterations set to the number iterations executed
*/
- void pbkdf_timed(byte out[], size_t out_len,
+ void pbkdf_timed(uint8_t out[], size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
std::chrono::milliseconds msec,
size_t& iterations) const;
@@ -113,9 +113,9 @@ class BOTAN_DLL PBKDF
* @param iterations the number of iterations to use (use 10K or more)
* @return the derived key
*/
- secure_vector<byte> pbkdf_iterations(size_t out_len,
+ secure_vector<uint8_t> pbkdf_iterations(size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations) const;
/**
@@ -130,9 +130,9 @@ class BOTAN_DLL PBKDF
* @param iterations set to the number iterations executed
* @return the derived key
*/
- secure_vector<byte> pbkdf_timed(size_t out_len,
+ secure_vector<uint8_t> pbkdf_timed(size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
std::chrono::milliseconds msec,
size_t& iterations) const;
@@ -148,7 +148,7 @@ class BOTAN_DLL PBKDF
*/
OctetString derive_key(size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations) const
{
return pbkdf_iterations(out_len, passphrase, salt, salt_len, iterations);
@@ -164,7 +164,7 @@ class BOTAN_DLL PBKDF
template<typename Alloc>
OctetString derive_key(size_t out_len,
const std::string& passphrase,
- const std::vector<byte, Alloc>& salt,
+ const std::vector<uint8_t, Alloc>& salt,
size_t iterations) const
{
return pbkdf_iterations(out_len, passphrase, salt.data(), salt.size(), iterations);
@@ -181,7 +181,7 @@ class BOTAN_DLL PBKDF
*/
OctetString derive_key(size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
std::chrono::milliseconds msec,
size_t& iterations) const
{
@@ -199,7 +199,7 @@ class BOTAN_DLL PBKDF
template<typename Alloc>
OctetString derive_key(size_t out_len,
const std::string& passphrase,
- const std::vector<byte, Alloc>& salt,
+ const std::vector<uint8_t, Alloc>& salt,
std::chrono::milliseconds msec,
size_t& iterations) const
{
diff --git a/src/lib/pbkdf/pbkdf1/pbkdf1.cpp b/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
index 49e1cf268..ad922ce9c 100644
--- a/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
+++ b/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
@@ -10,9 +10,9 @@
namespace Botan {
-size_t PKCS5_PBKDF1::pbkdf(byte output_buf[], size_t output_len,
+size_t PKCS5_PBKDF1::pbkdf(uint8_t output_buf[], size_t output_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations,
std::chrono::milliseconds msec) const
{
@@ -21,7 +21,7 @@ size_t PKCS5_PBKDF1::pbkdf(byte output_buf[], size_t output_len,
m_hash->update(passphrase);
m_hash->update(salt, salt_len);
- secure_vector<byte> key = m_hash->final();
+ secure_vector<uint8_t> key = m_hash->final();
const auto start = std::chrono::high_resolution_clock::now();
size_t iterations_performed = 1;
diff --git a/src/lib/pbkdf/pbkdf1/pbkdf1.h b/src/lib/pbkdf/pbkdf1/pbkdf1.h
index cd10b3112..ca6542822 100644
--- a/src/lib/pbkdf/pbkdf1/pbkdf1.h
+++ b/src/lib/pbkdf/pbkdf1/pbkdf1.h
@@ -37,9 +37,9 @@ class BOTAN_DLL PKCS5_PBKDF1 final : public PBKDF
return new PKCS5_PBKDF1(m_hash->clone());
}
- size_t pbkdf(byte output_buf[], size_t output_len,
+ size_t pbkdf(uint8_t output_buf[], size_t output_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations,
std::chrono::milliseconds msec) const override;
private:
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
index 0041fd537..03e746717 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
@@ -13,10 +13,10 @@ namespace Botan {
size_t
pbkdf2(MessageAuthenticationCode& prf,
- byte out[],
+ uint8_t out[],
size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations,
std::chrono::milliseconds msec)
{
@@ -27,7 +27,7 @@ pbkdf2(MessageAuthenticationCode& prf,
try
{
- prf.set_key(reinterpret_cast<const byte*>(passphrase.data()), passphrase.size());
+ prf.set_key(reinterpret_cast<const uint8_t*>(passphrase.data()), passphrase.size());
}
catch(Invalid_Key_Length&)
{
@@ -37,14 +37,14 @@ pbkdf2(MessageAuthenticationCode& prf,
}
const size_t prf_sz = prf.output_length();
- secure_vector<byte> U(prf_sz);
+ secure_vector<uint8_t> U(prf_sz);
const size_t blocks_needed = round_up(out_len, prf_sz) / prf_sz;
std::chrono::microseconds usec_per_block =
std::chrono::duration_cast<std::chrono::microseconds>(msec) / blocks_needed;
- u32bit counter = 1;
+ uint32_t counter = 1;
while(out_len)
{
const size_t prf_output = std::min<size_t>(prf_sz, out_len);
@@ -105,9 +105,9 @@ pbkdf2(MessageAuthenticationCode& prf,
}
size_t
-PKCS5_PBKDF2::pbkdf(byte key[], size_t key_len,
+PKCS5_PBKDF2::pbkdf(uint8_t key[], size_t key_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations,
std::chrono::milliseconds msec) const
{
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.h b/src/lib/pbkdf/pbkdf2/pbkdf2.h
index 36a3c640a..248daae67 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.h
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.h
@@ -15,10 +15,10 @@
namespace Botan {
BOTAN_DLL size_t pbkdf2(MessageAuthenticationCode& prf,
- byte out[],
+ uint8_t out[],
size_t out_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations,
std::chrono::milliseconds msec);
@@ -38,9 +38,9 @@ class BOTAN_DLL PKCS5_PBKDF2 final : public PBKDF
return new PKCS5_PBKDF2(m_mac->clone());
}
- size_t pbkdf(byte output_buf[], size_t output_len,
+ size_t pbkdf(uint8_t output_buf[], size_t output_len,
const std::string& passphrase,
- const byte salt[], size_t salt_len,
+ const uint8_t salt[], size_t salt_len,
size_t iterations,
std::chrono::milliseconds msec) const override;
diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp
index eab9862af..85efe1615 100644
--- a/src/lib/pk_pad/eme.cpp
+++ b/src/lib/pk_pad/eme.cpp
@@ -56,7 +56,7 @@ EME* get_eme(const std::string& algo_spec)
/*
* Encode a message
*/
-secure_vector<byte> EME::encode(const byte msg[], size_t msg_len,
+secure_vector<uint8_t> EME::encode(const uint8_t msg[], size_t msg_len,
size_t key_bits,
RandomNumberGenerator& rng) const
{
@@ -66,7 +66,7 @@ secure_vector<byte> EME::encode(const byte msg[], size_t msg_len,
/*
* Encode a message
*/
-secure_vector<byte> EME::encode(const secure_vector<byte>& msg,
+secure_vector<uint8_t> EME::encode(const secure_vector<uint8_t>& msg,
size_t key_bits,
RandomNumberGenerator& rng) const
{
diff --git a/src/lib/pk_pad/eme.h b/src/lib/pk_pad/eme.h
index a5ad27b4e..e9b4386ab 100644
--- a/src/lib/pk_pad/eme.h
+++ b/src/lib/pk_pad/eme.h
@@ -36,7 +36,7 @@ class BOTAN_DLL EME
* @param rng a random number generator
* @return encoded plaintext
*/
- secure_vector<byte> encode(const byte in[],
+ secure_vector<uint8_t> encode(const uint8_t in[],
size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const;
@@ -48,7 +48,7 @@ class BOTAN_DLL EME
* @param rng a random number generator
* @return encoded plaintext
*/
- secure_vector<byte> encode(const secure_vector<byte>& in,
+ secure_vector<uint8_t> encode(const secure_vector<uint8_t>& in,
size_t key_length,
RandomNumberGenerator& rng) const;
@@ -60,8 +60,8 @@ class BOTAN_DLL EME
* @return bytes of out[] written to along with
* validity mask (0xFF if valid, else 0x00)
*/
- virtual secure_vector<byte> unpad(byte& valid_mask,
- const byte in[],
+ virtual secure_vector<uint8_t> unpad(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const = 0;
/**
@@ -72,7 +72,7 @@ class BOTAN_DLL EME
* @param rng a random number generator
* @return encoded plaintext
*/
- virtual secure_vector<byte> pad(const byte in[],
+ virtual secure_vector<uint8_t> pad(const uint8_t in[],
size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const = 0;
diff --git a/src/lib/pk_pad/eme_oaep/oaep.cpp b/src/lib/pk_pad/eme_oaep/oaep.cpp
index f58254fdd..ef2fb81bb 100644
--- a/src/lib/pk_pad/eme_oaep/oaep.cpp
+++ b/src/lib/pk_pad/eme_oaep/oaep.cpp
@@ -14,7 +14,7 @@ namespace Botan {
/*
* OAEP Pad Operation
*/
-secure_vector<byte> OAEP::pad(const byte in[], size_t in_length,
+secure_vector<uint8_t> OAEP::pad(const uint8_t in[], size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const
{
@@ -25,7 +25,7 @@ secure_vector<byte> OAEP::pad(const byte in[], size_t in_length,
throw Invalid_Argument("OAEP: Input is too large");
}
- secure_vector<byte> out(key_length);
+ secure_vector<uint8_t> out(key_length);
rng.randomize(out.data(), m_Phash.size());
@@ -47,8 +47,8 @@ secure_vector<byte> OAEP::pad(const byte in[], size_t in_length,
/*
* OAEP Unpad Operation
*/
-secure_vector<byte> OAEP::unpad(byte& valid_mask,
- const byte in[], size_t in_length) const
+secure_vector<uint8_t> OAEP::unpad(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_length) const
{
/*
Must be careful about error messages here; if an attacker can
@@ -70,9 +70,9 @@ secure_vector<byte> OAEP::unpad(byte& valid_mask,
Therefore, the first byte can always be skipped safely.
*/
- byte skip_first = CT::is_zero<byte>(in[0]) & 0x01;
+ uint8_t skip_first = CT::is_zero<uint8_t>(in[0]) & 0x01;
- secure_vector<byte> input(in + skip_first, in + in_length);
+ secure_vector<uint8_t> input(in + skip_first, in + in_length);
CT::poison(input.data(), input.size());
@@ -87,26 +87,26 @@ secure_vector<byte> OAEP::unpad(byte& valid_mask,
&input[hlen], input.size() - hlen);
size_t delim_idx = 2 * hlen;
- byte waiting_for_delim = 0xFF;
- byte bad_input = 0;
+ uint8_t waiting_for_delim = 0xFF;
+ uint8_t bad_input = 0;
for(size_t i = delim_idx; i < input.size(); ++i)
{
- const byte zero_m = CT::is_zero<byte>(input[i]);
- const byte one_m = CT::is_equal<byte>(input[i], 1);
+ const uint8_t zero_m = CT::is_zero<uint8_t>(input[i]);
+ const uint8_t one_m = CT::is_equal<uint8_t>(input[i], 1);
- const byte add_m = waiting_for_delim & zero_m;
+ const uint8_t add_m = waiting_for_delim & zero_m;
bad_input |= waiting_for_delim & ~(zero_m | one_m);
- delim_idx += CT::select<byte>(add_m, 1, 0);
+ delim_idx += CT::select<uint8_t>(add_m, 1, 0);
waiting_for_delim &= zero_m;
}
// If we never saw any non-zero byte, then it's not valid input
bad_input |= waiting_for_delim;
- bad_input |= CT::is_equal<byte>(same_mem(&input[hlen], m_Phash.data(), hlen), false);
+ bad_input |= CT::is_equal<uint8_t>(same_mem(&input[hlen], m_Phash.data(), hlen), false);
CT::unpoison(input.data(), input.size());
CT::unpoison(&bad_input, 1);
@@ -114,7 +114,7 @@ secure_vector<byte> OAEP::unpad(byte& valid_mask,
valid_mask = ~bad_input;
- secure_vector<byte> output(input.begin() + delim_idx + 1, input.end());
+ secure_vector<uint8_t> output(input.begin() + delim_idx + 1, input.end());
CT::cond_zero_mem(bad_input, output.data(), output.size());
return output;
diff --git a/src/lib/pk_pad/eme_oaep/oaep.h b/src/lib/pk_pad/eme_oaep/oaep.h
index 3e476f6a3..9cd213eab 100644
--- a/src/lib/pk_pad/eme_oaep/oaep.h
+++ b/src/lib/pk_pad/eme_oaep/oaep.h
@@ -27,16 +27,16 @@ class BOTAN_DLL OAEP final : public EME
*/
OAEP(HashFunction* hash, const std::string& P = "");
private:
- secure_vector<byte> pad(const byte in[],
+ secure_vector<uint8_t> pad(const uint8_t in[],
size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const override;
- secure_vector<byte> unpad(byte& valid_mask,
- const byte in[],
+ secure_vector<uint8_t> unpad(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const override;
- secure_vector<byte> m_Phash;
+ secure_vector<uint8_t> m_Phash;
std::unique_ptr<HashFunction> m_hash;
};
diff --git a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
index 2b5ee4ba0..5d4f950f5 100644
--- a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
+++ b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
@@ -13,7 +13,7 @@ namespace Botan {
/*
* PKCS1 Pad Operation
*/
-secure_vector<byte> EME_PKCS1v15::pad(const byte in[], size_t inlen,
+secure_vector<uint8_t> EME_PKCS1v15::pad(const uint8_t in[], size_t inlen,
size_t key_length,
RandomNumberGenerator& rng) const
{
@@ -24,7 +24,7 @@ secure_vector<byte> EME_PKCS1v15::pad(const byte in[], size_t inlen,
throw Invalid_Argument("PKCS1: Input is too large");
}
- secure_vector<byte> out(key_length);
+ secure_vector<uint8_t> out(key_length);
out[0] = 0x02;
rng.randomize(out.data() + 1, (key_length - inlen - 2));
@@ -45,31 +45,31 @@ secure_vector<byte> EME_PKCS1v15::pad(const byte in[], size_t inlen,
/*
* PKCS1 Unpad Operation
*/
-secure_vector<byte> EME_PKCS1v15::unpad(byte& valid_mask,
- const byte in[], size_t inlen) const
+secure_vector<uint8_t> EME_PKCS1v15::unpad(uint8_t& valid_mask,
+ const uint8_t in[], size_t inlen) const
{
if(inlen < 2)
{
valid_mask = false;
- return secure_vector<byte>();
+ return secure_vector<uint8_t>();
}
CT::poison(in, inlen);
- byte bad_input_m = 0;
- byte seen_zero_m = 0;
+ uint8_t bad_input_m = 0;
+ uint8_t seen_zero_m = 0;
size_t delim_idx = 0;
- bad_input_m |= ~CT::is_equal<byte>(in[0], 0);
- bad_input_m |= ~CT::is_equal<byte>(in[1], 2);
+ bad_input_m |= ~CT::is_equal<uint8_t>(in[0], 0);
+ bad_input_m |= ~CT::is_equal<uint8_t>(in[1], 2);
for(size_t i = 2; i < inlen; ++i)
{
- const byte is_zero_m = CT::is_zero<byte>(in[i]);
+ const uint8_t is_zero_m = CT::is_zero<uint8_t>(in[i]);
- delim_idx += CT::select<byte>(~seen_zero_m, 1, 0);
+ delim_idx += CT::select<uint8_t>(~seen_zero_m, 1, 0);
- bad_input_m |= is_zero_m & CT::expand_mask<byte>(i < 10);
+ bad_input_m |= is_zero_m & CT::expand_mask<uint8_t>(i < 10);
seen_zero_m |= is_zero_m;
}
@@ -80,7 +80,7 @@ secure_vector<byte> EME_PKCS1v15::unpad(byte& valid_mask,
CT::unpoison(bad_input_m);
CT::unpoison(delim_idx);
- secure_vector<byte> output(&in[delim_idx + 2], &in[inlen]);
+ secure_vector<uint8_t> output(&in[delim_idx + 2], &in[inlen]);
CT::cond_zero_mem(bad_input_m, output.data(), output.size());
valid_mask = ~bad_input_m;
return output;
diff --git a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.h b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.h
index 006b39997..9e06403ac 100644
--- a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.h
+++ b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.h
@@ -20,11 +20,11 @@ class BOTAN_DLL EME_PKCS1v15 final : public EME
public:
size_t maximum_input_size(size_t) const override;
private:
- secure_vector<byte> pad(const byte[], size_t, size_t,
+ secure_vector<uint8_t> pad(const uint8_t[], size_t, size_t,
RandomNumberGenerator&) const override;
- secure_vector<byte> unpad(byte& valid_mask,
- const byte in[],
+ secure_vector<uint8_t> unpad(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const override;
};
diff --git a/src/lib/pk_pad/eme_raw/eme_raw.cpp b/src/lib/pk_pad/eme_raw/eme_raw.cpp
index 84fd6f545..066e7afd8 100644
--- a/src/lib/pk_pad/eme_raw/eme_raw.cpp
+++ b/src/lib/pk_pad/eme_raw/eme_raw.cpp
@@ -10,15 +10,15 @@
namespace Botan {
-secure_vector<byte> EME_Raw::pad(const byte in[], size_t in_length,
+secure_vector<uint8_t> EME_Raw::pad(const uint8_t in[], size_t in_length,
size_t,
RandomNumberGenerator&) const
{
- return secure_vector<byte>(in, in + in_length);
+ return secure_vector<uint8_t>(in, in + in_length);
}
-secure_vector<byte> EME_Raw::unpad(byte& valid_mask,
- const byte in[], size_t in_length) const
+secure_vector<uint8_t> EME_Raw::unpad(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_length) const
{
valid_mask = 0xFF;
return CT::strip_leading_zeros(in, in_length);
diff --git a/src/lib/pk_pad/eme_raw/eme_raw.h b/src/lib/pk_pad/eme_raw/eme_raw.h
index fa30c684e..ec698f759 100644
--- a/src/lib/pk_pad/eme_raw/eme_raw.h
+++ b/src/lib/pk_pad/eme_raw/eme_raw.h
@@ -18,11 +18,11 @@ class BOTAN_DLL EME_Raw final : public EME
EME_Raw() {}
private:
- secure_vector<byte> pad(const byte[], size_t, size_t,
+ secure_vector<uint8_t> pad(const uint8_t[], size_t, size_t,
RandomNumberGenerator&) const override;
- secure_vector<byte> unpad(byte& valid_mask,
- const byte in[],
+ secure_vector<uint8_t> unpad(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const override;
};
diff --git a/src/lib/pk_pad/emsa.h b/src/lib/pk_pad/emsa.h
index bc930ae22..4b932fd78 100644
--- a/src/lib/pk_pad/emsa.h
+++ b/src/lib/pk_pad/emsa.h
@@ -26,12 +26,12 @@ class BOTAN_DLL EMSA
* @param input some data
* @param length length of input in bytes
*/
- virtual void update(const byte input[], size_t length) = 0;
+ virtual void update(const uint8_t input[], size_t length) = 0;
/**
* @return raw hash
*/
- virtual secure_vector<byte> raw_data() = 0;
+ virtual secure_vector<uint8_t> raw_data() = 0;
/**
* Return the encoding of a message
@@ -40,7 +40,7 @@ class BOTAN_DLL EMSA
* @param rng a random number generator
* @return encoded signature
*/
- virtual secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ virtual secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) = 0;
@@ -51,8 +51,8 @@ class BOTAN_DLL EMSA
* @param key_bits the size of the key in bits
* @return true if coded is a valid encoding of raw, otherwise false
*/
- virtual bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ virtual bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) = 0;
virtual ~EMSA();
diff --git a/src/lib/pk_pad/emsa1/emsa1.cpp b/src/lib/pk_pad/emsa1/emsa1.cpp
index 11130920f..82c3b86a7 100644
--- a/src/lib/pk_pad/emsa1/emsa1.cpp
+++ b/src/lib/pk_pad/emsa1/emsa1.cpp
@@ -11,7 +11,7 @@ namespace Botan {
namespace {
-secure_vector<byte> emsa1_encoding(const secure_vector<byte>& msg,
+secure_vector<uint8_t> emsa1_encoding(const secure_vector<uint8_t>& msg,
size_t output_bits)
{
if(8*msg.size() <= output_bits)
@@ -20,17 +20,17 @@ secure_vector<byte> emsa1_encoding(const secure_vector<byte>& msg,
size_t shift = 8*msg.size() - output_bits;
size_t byte_shift = shift / 8, bit_shift = shift % 8;
- secure_vector<byte> digest(msg.size() - byte_shift);
+ secure_vector<uint8_t> digest(msg.size() - byte_shift);
for(size_t j = 0; j != msg.size() - byte_shift; ++j)
digest[j] = msg[j];
if(bit_shift)
{
- byte carry = 0;
+ uint8_t carry = 0;
for(size_t j = 0; j != digest.size(); ++j)
{
- byte temp = digest[j];
+ uint8_t temp = digest[j];
digest[j] = (temp >> bit_shift) | carry;
carry = (temp << (8 - bit_shift));
}
@@ -45,17 +45,17 @@ EMSA* EMSA1::clone()
return new EMSA1(m_hash->clone());
}
-void EMSA1::update(const byte input[], size_t length)
+void EMSA1::update(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
-secure_vector<byte> EMSA1::raw_data()
+secure_vector<uint8_t> EMSA1::raw_data()
{
return m_hash->final();
}
-secure_vector<byte> EMSA1::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> EMSA1::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator&)
{
@@ -64,8 +64,8 @@ secure_vector<byte> EMSA1::encoding_of(const secure_vector<byte>& msg,
return emsa1_encoding(msg, output_bits);
}
-bool EMSA1::verify(const secure_vector<byte>& input,
- const secure_vector<byte>& raw,
+bool EMSA1::verify(const secure_vector<uint8_t>& input,
+ const secure_vector<uint8_t>& raw,
size_t key_bits)
{
try {
@@ -73,7 +73,7 @@ bool EMSA1::verify(const secure_vector<byte>& input,
throw Encoding_Error("EMSA1::encoding_of: Invalid size for input");
// Call emsa1_encoding to handle any required bit shifting
- const secure_vector<byte> our_coding = emsa1_encoding(raw, key_bits);
+ const secure_vector<uint8_t> our_coding = emsa1_encoding(raw, key_bits);
if(our_coding.size() < input.size())
return false;
diff --git a/src/lib/pk_pad/emsa1/emsa1.h b/src/lib/pk_pad/emsa1/emsa1.h
index 5a4b4b372..6d7b2bca8 100644
--- a/src/lib/pk_pad/emsa1/emsa1.h
+++ b/src/lib/pk_pad/emsa1/emsa1.h
@@ -33,15 +33,15 @@ class BOTAN_DLL EMSA1 : public EMSA
std::unique_ptr<HashFunction> m_hash;
private:
- void update(const byte[], size_t) override;
- secure_vector<byte> raw_data() override;
+ void update(const uint8_t[], size_t) override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) override;
};
diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
index b3f74930b..c4cdc6f35 100644
--- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
+++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
@@ -12,16 +12,16 @@ namespace Botan {
namespace {
-secure_vector<byte> emsa3_encoding(const secure_vector<byte>& msg,
+secure_vector<uint8_t> emsa3_encoding(const secure_vector<uint8_t>& msg,
size_t output_bits,
- const byte hash_id[],
+ const uint8_t hash_id[],
size_t hash_id_length)
{
size_t output_length = output_bits / 8;
if(output_length < hash_id_length + msg.size() + 10)
throw Encoding_Error("emsa3_encoding: Output length is too small");
- secure_vector<byte> T(output_length);
+ secure_vector<uint8_t> T(output_length);
const size_t P_LENGTH = output_length - msg.size() - hash_id_length - 2;
T[0] = 0x01;
@@ -34,18 +34,18 @@ secure_vector<byte> emsa3_encoding(const secure_vector<byte>& msg,
}
-void EMSA_PKCS1v15::update(const byte input[], size_t length)
+void EMSA_PKCS1v15::update(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
-secure_vector<byte> EMSA_PKCS1v15::raw_data()
+secure_vector<uint8_t> EMSA_PKCS1v15::raw_data()
{
return m_hash->final();
}
-secure_vector<byte>
-EMSA_PKCS1v15::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t>
+EMSA_PKCS1v15::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator&)
{
@@ -56,8 +56,8 @@ EMSA_PKCS1v15::encoding_of(const secure_vector<byte>& msg,
m_hash_id.data(), m_hash_id.size());
}
-bool EMSA_PKCS1v15::verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+bool EMSA_PKCS1v15::verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits)
{
if(raw.size() != m_hash->output_length())
@@ -79,28 +79,28 @@ EMSA_PKCS1v15::EMSA_PKCS1v15(HashFunction* hash) : m_hash(hash)
m_hash_id = pkcs_hash_id(m_hash->name());
}
-void EMSA_PKCS1v15_Raw::update(const byte input[], size_t length)
+void EMSA_PKCS1v15_Raw::update(const uint8_t input[], size_t length)
{
m_message += std::make_pair(input, length);
}
-secure_vector<byte> EMSA_PKCS1v15_Raw::raw_data()
+secure_vector<uint8_t> EMSA_PKCS1v15_Raw::raw_data()
{
- secure_vector<byte> ret;
+ secure_vector<uint8_t> ret;
std::swap(ret, m_message);
return ret;
}
-secure_vector<byte>
-EMSA_PKCS1v15_Raw::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t>
+EMSA_PKCS1v15_Raw::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator&)
{
return emsa3_encoding(msg, output_bits, nullptr, 0);
}
-bool EMSA_PKCS1v15_Raw::verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+bool EMSA_PKCS1v15_Raw::verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits)
{
try
diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
index 65daaf7ce..95ccafa4d 100644
--- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
+++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
@@ -28,18 +28,18 @@ class BOTAN_DLL EMSA_PKCS1v15 final : public EMSA
EMSA* clone() override { return new EMSA_PKCS1v15(m_hash->clone()); }
- void update(const byte[], size_t) override;
+ void update(const uint8_t[], size_t) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
+ bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
size_t) override;
private:
std::unique_ptr<HashFunction> m_hash;
- std::vector<byte> m_hash_id;
+ std::vector<uint8_t> m_hash_id;
};
/**
@@ -52,18 +52,18 @@ class BOTAN_DLL EMSA_PKCS1v15_Raw final : public EMSA
public:
EMSA* clone() override { return new EMSA_PKCS1v15_Raw(); }
- void update(const byte[], size_t) override;
+ void update(const uint8_t[], size_t) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
+ bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
size_t) override;
private:
- secure_vector<byte> m_message;
+ secure_vector<uint8_t> m_message;
};
}
diff --git a/src/lib/pk_pad/emsa_pssr/pssr.cpp b/src/lib/pk_pad/emsa_pssr/pssr.cpp
index a41e79e78..5f76b5a6f 100644
--- a/src/lib/pk_pad/emsa_pssr/pssr.cpp
+++ b/src/lib/pk_pad/emsa_pssr/pssr.cpp
@@ -14,7 +14,7 @@ namespace Botan {
/*
* PSSR Update Operation
*/
-void PSSR::update(const byte input[], size_t length)
+void PSSR::update(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
@@ -22,7 +22,7 @@ void PSSR::update(const byte input[], size_t length)
/*
* Return the raw (unencoded) data
*/
-secure_vector<byte> PSSR::raw_data()
+secure_vector<uint8_t> PSSR::raw_data()
{
return m_hash->final();
}
@@ -30,7 +30,7 @@ secure_vector<byte> PSSR::raw_data()
/*
* PSSR Encode Operation
*/
-secure_vector<byte> PSSR::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> PSSR::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng)
{
@@ -43,15 +43,15 @@ secure_vector<byte> PSSR::encoding_of(const secure_vector<byte>& msg,
const size_t output_length = (output_bits + 7) / 8;
- secure_vector<byte> salt = rng.random_vec(m_SALT_SIZE);
+ secure_vector<uint8_t> salt = rng.random_vec(m_SALT_SIZE);
for(size_t j = 0; j != 8; ++j)
m_hash->update(0);
m_hash->update(msg);
m_hash->update(salt);
- secure_vector<byte> H = m_hash->final();
+ secure_vector<uint8_t> H = m_hash->final();
- secure_vector<byte> EM(output_length);
+ secure_vector<uint8_t> EM(output_length);
EM[output_length - HASH_SIZE - m_SALT_SIZE - 2] = 0x01;
buffer_insert(EM, output_length - 1 - HASH_SIZE - m_SALT_SIZE, salt);
@@ -66,8 +66,8 @@ secure_vector<byte> PSSR::encoding_of(const secure_vector<byte>& msg,
/*
* PSSR Decode/Verify Operation
*/
-bool PSSR::verify(const secure_vector<byte>& const_coded,
- const secure_vector<byte>& raw, size_t key_bits)
+bool PSSR::verify(const secure_vector<uint8_t>& const_coded,
+ const secure_vector<uint8_t>& raw, size_t key_bits)
{
const size_t HASH_SIZE = m_hash->output_length();
const size_t KEY_BYTES = (key_bits + 7) / 8;
@@ -84,10 +84,10 @@ bool PSSR::verify(const secure_vector<byte>& const_coded,
if(const_coded[const_coded.size()-1] != 0xBC)
return false;
- secure_vector<byte> coded = const_coded;
+ secure_vector<uint8_t> coded = const_coded;
if(coded.size() < KEY_BYTES)
{
- secure_vector<byte> temp(KEY_BYTES);
+ secure_vector<uint8_t> temp(KEY_BYTES);
buffer_insert(temp, KEY_BYTES - coded.size(), coded);
coded = temp;
}
@@ -96,10 +96,10 @@ bool PSSR::verify(const secure_vector<byte>& const_coded,
if(TOP_BITS > 8 - high_bit(coded[0]))
return false;
- byte* DB = coded.data();
+ uint8_t* DB = coded.data();
const size_t DB_size = coded.size() - HASH_SIZE - 1;
- const byte* H = &coded[DB_size];
+ const uint8_t* H = &coded[DB_size];
const size_t H_size = HASH_SIZE;
mgf1_mask(*m_hash, H, H_size, DB, DB_size);
@@ -120,7 +120,7 @@ bool PSSR::verify(const secure_vector<byte>& const_coded,
m_hash->update(0);
m_hash->update(raw);
m_hash->update(&DB[salt_offset], DB_size - salt_offset);
- secure_vector<byte> H2 = m_hash->final();
+ secure_vector<uint8_t> H2 = m_hash->final();
return same_mem(H, H2.data(), HASH_SIZE);
}
diff --git a/src/lib/pk_pad/emsa_pssr/pssr.h b/src/lib/pk_pad/emsa_pssr/pssr.h
index bf465eadf..0ed47c466 100644
--- a/src/lib/pk_pad/emsa_pssr/pssr.h
+++ b/src/lib/pk_pad/emsa_pssr/pssr.h
@@ -33,16 +33,16 @@ class BOTAN_DLL PSSR final : public EMSA
EMSA* clone() override { return new PSSR(m_hash->clone(), m_SALT_SIZE); }
private:
- void update(const byte input[], size_t length) override;
+ void update(const uint8_t input[], size_t length) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) override;
size_t m_SALT_SIZE;
diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
index 8d3bbdbc3..d15012a0d 100644
--- a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
+++ b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
@@ -12,7 +12,7 @@ namespace Botan {
/*
* EMSA-Raw Encode Operation
*/
-void EMSA_Raw::update(const byte input[], size_t length)
+void EMSA_Raw::update(const uint8_t input[], size_t length)
{
m_message += std::make_pair(input, length);
}
@@ -20,9 +20,9 @@ void EMSA_Raw::update(const byte input[], size_t length)
/*
* Return the raw (unencoded) data
*/
-secure_vector<byte> EMSA_Raw::raw_data()
+secure_vector<uint8_t> EMSA_Raw::raw_data()
{
- secure_vector<byte> output;
+ secure_vector<uint8_t> output;
std::swap(m_message, output);
return output;
}
@@ -30,7 +30,7 @@ secure_vector<byte> EMSA_Raw::raw_data()
/*
* EMSA-Raw Encode Operation
*/
-secure_vector<byte> EMSA_Raw::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> EMSA_Raw::encoding_of(const secure_vector<uint8_t>& msg,
size_t,
RandomNumberGenerator&)
{
@@ -40,8 +40,8 @@ secure_vector<byte> EMSA_Raw::encoding_of(const secure_vector<byte>& msg,
/*
* EMSA-Raw Verify Operation
*/
-bool EMSA_Raw::verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+bool EMSA_Raw::verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t)
{
if(coded.size() == raw.size())
diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.h b/src/lib/pk_pad/emsa_raw/emsa_raw.h
index cc2d5d63a..288969257 100644
--- a/src/lib/pk_pad/emsa_raw/emsa_raw.h
+++ b/src/lib/pk_pad/emsa_raw/emsa_raw.h
@@ -22,15 +22,15 @@ class BOTAN_DLL EMSA_Raw final : public EMSA
EMSA* clone() override { return new EMSA_Raw(); }
private:
- void update(const byte[], size_t) override;
- secure_vector<byte> raw_data() override;
+ void update(const uint8_t[], size_t) override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
RandomNumberGenerator&) override;
- bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
+ bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
size_t) override;
- secure_vector<byte> m_message;
+ secure_vector<uint8_t> m_message;
};
}
diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
index 2feedee1c..8d90bd245 100644
--- a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
+++ b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
@@ -12,10 +12,10 @@ namespace Botan {
namespace {
-secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg,
+secure_vector<uint8_t> emsa2_encoding(const secure_vector<uint8_t>& msg,
size_t output_bits,
- const secure_vector<byte>& empty_hash,
- byte hash_id)
+ const secure_vector<uint8_t>& empty_hash,
+ uint8_t hash_id)
{
const size_t HASH_SIZE = empty_hash.size();
@@ -28,7 +28,7 @@ secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg,
const bool empty_input = (msg == empty_hash);
- secure_vector<byte> output(output_length);
+ secure_vector<uint8_t> output(output_length);
output[0] = (empty_input ? 0x4B : 0x6B);
output[output_length - 3 - HASH_SIZE] = 0xBA;
@@ -42,12 +42,12 @@ secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg,
}
-void EMSA_X931::update(const byte input[], size_t length)
+void EMSA_X931::update(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
-secure_vector<byte> EMSA_X931::raw_data()
+secure_vector<uint8_t> EMSA_X931::raw_data()
{
return m_hash->final();
}
@@ -55,7 +55,7 @@ secure_vector<byte> EMSA_X931::raw_data()
/*
* EMSA_X931 Encode Operation
*/
-secure_vector<byte> EMSA_X931::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> EMSA_X931::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator&)
{
@@ -65,8 +65,8 @@ secure_vector<byte> EMSA_X931::encoding_of(const secure_vector<byte>& msg,
/*
* EMSA_X931 Verify Operation
*/
-bool EMSA_X931::verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+bool EMSA_X931::verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits)
{
try
diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.h b/src/lib/pk_pad/emsa_x931/emsa_x931.h
index fe5866002..ec48d01de 100644
--- a/src/lib/pk_pad/emsa_x931/emsa_x931.h
+++ b/src/lib/pk_pad/emsa_x931/emsa_x931.h
@@ -28,18 +28,18 @@ class BOTAN_DLL EMSA_X931 final : public EMSA
EMSA* clone() override { return new EMSA_X931(m_hash->clone()); }
private:
- void update(const byte[], size_t) override;
- secure_vector<byte> raw_data() override;
+ void update(const uint8_t[], size_t) override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
+ bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
size_t) override;
- secure_vector<byte> m_empty_hash;
+ secure_vector<uint8_t> m_empty_hash;
std::unique_ptr<HashFunction> m_hash;
- byte m_hash_id;
+ uint8_t m_hash_id;
};
}
diff --git a/src/lib/pk_pad/hash_id/hash_id.cpp b/src/lib/pk_pad/hash_id/hash_id.cpp
index 2af0f6878..70b7470c4 100644
--- a/src/lib/pk_pad/hash_id/hash_id.cpp
+++ b/src/lib/pk_pad/hash_id/hash_id.cpp
@@ -12,39 +12,39 @@ namespace Botan {
namespace {
-const byte MD5_PKCS_ID[] = {
+const uint8_t MD5_PKCS_ID[] = {
0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86,
0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 };
-const byte RIPEMD_160_PKCS_ID[] = {
+const uint8_t RIPEMD_160_PKCS_ID[] = {
0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 0x03, 0x02,
0x01, 0x05, 0x00, 0x04, 0x14 };
-const byte SHA_160_PKCS_ID[] = {
+const uint8_t SHA_160_PKCS_ID[] = {
0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02,
0x1A, 0x05, 0x00, 0x04, 0x14 };
-const byte SHA_224_PKCS_ID[] = {
+const uint8_t SHA_224_PKCS_ID[] = {
0x30, 0x2D, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C };
-const byte SHA_256_PKCS_ID[] = {
+const uint8_t SHA_256_PKCS_ID[] = {
0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 };
-const byte SHA_384_PKCS_ID[] = {
+const uint8_t SHA_384_PKCS_ID[] = {
0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30 };
-const byte SHA_512_PKCS_ID[] = {
+const uint8_t SHA_512_PKCS_ID[] = {
0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 };
-const byte SHA_512_256_PKCS_ID[] = {
+const uint8_t SHA_512_256_PKCS_ID[] = {
0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x06, 0x05, 0x00, 0x04, 0x20 };
-const byte TIGER_PKCS_ID[] = {
+const uint8_t TIGER_PKCS_ID[] = {
0x30, 0x29, 0x30, 0x0D, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04,
0x01, 0xDA, 0x47, 0x0C, 0x02, 0x05, 0x00, 0x04, 0x18 };
@@ -53,46 +53,46 @@ const byte TIGER_PKCS_ID[] = {
/*
* HashID as specified by PKCS
*/
-std::vector<byte> pkcs_hash_id(const std::string& name)
+std::vector<uint8_t> pkcs_hash_id(const std::string& name)
{
// Special case for SSL/TLS RSA signatures
if(name == "Parallel(MD5,SHA-160)")
- return std::vector<byte>();
+ return std::vector<uint8_t>();
if(name == "MD5")
- return std::vector<byte>(MD5_PKCS_ID,
+ return std::vector<uint8_t>(MD5_PKCS_ID,
MD5_PKCS_ID + sizeof(MD5_PKCS_ID));
if(name == "RIPEMD-160")
- return std::vector<byte>(RIPEMD_160_PKCS_ID,
+ return std::vector<uint8_t>(RIPEMD_160_PKCS_ID,
RIPEMD_160_PKCS_ID + sizeof(RIPEMD_160_PKCS_ID));
if(name == "SHA-160")
- return std::vector<byte>(SHA_160_PKCS_ID,
+ return std::vector<uint8_t>(SHA_160_PKCS_ID,
SHA_160_PKCS_ID + sizeof(SHA_160_PKCS_ID));
if(name == "SHA-224")
- return std::vector<byte>(SHA_224_PKCS_ID,
+ return std::vector<uint8_t>(SHA_224_PKCS_ID,
SHA_224_PKCS_ID + sizeof(SHA_224_PKCS_ID));
if(name == "SHA-256")
- return std::vector<byte>(SHA_256_PKCS_ID,
+ return std::vector<uint8_t>(SHA_256_PKCS_ID,
SHA_256_PKCS_ID + sizeof(SHA_256_PKCS_ID));
if(name == "SHA-384")
- return std::vector<byte>(SHA_384_PKCS_ID,
+ return std::vector<uint8_t>(SHA_384_PKCS_ID,
SHA_384_PKCS_ID + sizeof(SHA_384_PKCS_ID));
if(name == "SHA-512")
- return std::vector<byte>(SHA_512_PKCS_ID,
+ return std::vector<uint8_t>(SHA_512_PKCS_ID,
SHA_512_PKCS_ID + sizeof(SHA_512_PKCS_ID));
if(name == "SHA-512-256")
- return std::vector<byte>(SHA_512_256_PKCS_ID,
+ return std::vector<uint8_t>(SHA_512_256_PKCS_ID,
SHA_512_256_PKCS_ID + sizeof(SHA_512_256_PKCS_ID));
if(name == "Tiger(24,3)")
- return std::vector<byte>(TIGER_PKCS_ID,
+ return std::vector<uint8_t>(TIGER_PKCS_ID,
TIGER_PKCS_ID + sizeof(TIGER_PKCS_ID));
throw Invalid_Argument("No PKCS #1 identifier for " + name);
@@ -101,7 +101,7 @@ std::vector<byte> pkcs_hash_id(const std::string& name)
/*
* HashID as specified by IEEE 1363/X9.31
*/
-byte ieee1363_hash_id(const std::string& name)
+uint8_t ieee1363_hash_id(const std::string& name)
{
if(name == "SHA-160") return 0x33;
diff --git a/src/lib/pk_pad/hash_id/hash_id.h b/src/lib/pk_pad/hash_id/hash_id.h
index 5eab8bc2b..4e5492bd0 100644
--- a/src/lib/pk_pad/hash_id/hash_id.h
+++ b/src/lib/pk_pad/hash_id/hash_id.h
@@ -17,17 +17,17 @@ namespace Botan {
* Return the PKCS #1 hash identifier
* @see RFC 3447 section 9.2
* @param hash_name the name of the hash function
-* @return byte sequence identifying the hash
+* @return uint8_t sequence identifying the hash
* @throw Invalid_Argument if the hash has no known PKCS #1 hash id
*/
-BOTAN_DLL std::vector<byte> pkcs_hash_id(const std::string& hash_name);
+BOTAN_DLL std::vector<uint8_t> pkcs_hash_id(const std::string& hash_name);
/**
* Return the IEEE 1363 hash identifier
* @param hash_name the name of the hash function
-* @return byte code identifying the hash, or 0 if not known
+* @return uint8_t code identifying the hash, or 0 if not known
*/
-BOTAN_DLL byte ieee1363_hash_id(const std::string& hash_name);
+BOTAN_DLL uint8_t ieee1363_hash_id(const std::string& hash_name);
}
diff --git a/src/lib/pk_pad/iso9796/iso9796.cpp b/src/lib/pk_pad/iso9796/iso9796.cpp
index db79661e3..f123a7e15 100644
--- a/src/lib/pk_pad/iso9796/iso9796.cpp
+++ b/src/lib/pk_pad/iso9796/iso9796.cpp
@@ -14,7 +14,7 @@ namespace Botan {
namespace {
-secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
+secure_vector<uint8_t> iso9796_encoding(const secure_vector<uint8_t>& msg,
size_t output_bits, std::unique_ptr<HashFunction>& hash, size_t SALT_SIZE, bool implicit, RandomNumberGenerator& rng)
{
const size_t output_length = (output_bits + 7) / 8;
@@ -37,12 +37,12 @@ secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
- HASH_SIZE - SALT_SIZE - tLength - 1;
//msg1 is the recoverable and msg2 the unrecoverable message part.
- secure_vector<byte> msg1;
- secure_vector<byte> msg2;
+ secure_vector<uint8_t> msg1;
+ secure_vector<uint8_t> msg2;
if(msg.size() > capacity)
{
- msg1 = secure_vector<byte> (msg.begin(), msg.begin() + capacity);
- msg2 = secure_vector<byte> (msg.begin() + capacity, msg.end());
+ msg1 = secure_vector<uint8_t> (msg.begin(), msg.begin() + capacity);
+ msg2 = secure_vector<uint8_t> (msg.begin() + capacity, msg.end());
hash->update(msg2);
}
else
@@ -53,14 +53,14 @@ secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
//compute H(C||msg1 ||H(msg2)||S)
uint64_t msgLength = msg1.size();
- secure_vector<byte> salt = rng.random_vec(SALT_SIZE);
+ secure_vector<uint8_t> salt = rng.random_vec(SALT_SIZE);
hash->update_be(msgLength * 8);
hash->update(msg1);
hash->update(msg2);
hash->update(salt);
- secure_vector<byte> H = hash->final();
+ secure_vector<uint8_t> H = hash->final();
- secure_vector<byte> EM(output_length);
+ secure_vector<uint8_t> EM(output_length);
//compute message offset.
size_t offset = output_length - HASH_SIZE - SALT_SIZE - tLength
@@ -78,7 +78,7 @@ secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
//set implicit/ISO trailer
if(!implicit)
{
- byte hash_id = ieee1363_hash_id(hash->name());
+ uint8_t hash_id = ieee1363_hash_id(hash->name());
if(!hash_id)
{
throw Encoding_Error("ISO9796-2::encoding_of: no hash identifier for " + hash->name());
@@ -97,8 +97,8 @@ secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
return EM;
}
-bool iso9796_verification(const secure_vector<byte>& const_coded,
- const secure_vector<byte>& raw, size_t key_bits, std::unique_ptr<HashFunction>& hash, size_t SALT_SIZE)
+bool iso9796_verification(const secure_vector<uint8_t>& const_coded,
+ const secure_vector<uint8_t>& raw, size_t key_bits, std::unique_ptr<HashFunction>& hash, size_t SALT_SIZE)
{
const size_t HASH_SIZE = hash->output_length();
const size_t KEY_BYTES = (key_bits + 7) / 8;
@@ -115,7 +115,7 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
}
else
{
- byte hash_id = ieee1363_hash_id(hash->name());
+ uint8_t hash_id = ieee1363_hash_id(hash->name());
if((!const_coded[const_coded.size() - 2]) || (const_coded[const_coded.size() - 2] != hash_id) ||
(const_coded[const_coded.size() - 1] != 0xCC))
{
@@ -124,13 +124,13 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
tLength = 2;
}
- secure_vector<byte> coded = const_coded;
+ secure_vector<uint8_t> coded = const_coded;
//remove mask
- byte* DB = coded.data();
+ uint8_t* DB = coded.data();
const size_t DB_size = coded.size() - HASH_SIZE - tLength;
- const byte* H = &coded[DB_size];
+ const uint8_t* H = &coded[DB_size];
mgf1_mask(*hash, H, HASH_SIZE, DB, DB_size);
//clear the leftmost bit (confer bouncy castle)
@@ -150,20 +150,20 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
{
return false;
}
- secure_vector<byte> msg1(coded.begin() + msg1_offset,
+ secure_vector<uint8_t> msg1(coded.begin() + msg1_offset,
coded.end() - tLength - HASH_SIZE - SALT_SIZE);
- secure_vector<byte> salt(coded.begin() + msg1_offset + msg1.size(),
+ secure_vector<uint8_t> salt(coded.begin() + msg1_offset + msg1.size(),
coded.end() - tLength - HASH_SIZE);
//compute H2(C||msg1||H(msg2)||S*). * indicates a recovered value
const size_t capacity = (key_bits - 2 + 7) / 8 - HASH_SIZE
- SALT_SIZE - tLength - 1;
- secure_vector<byte> msg1raw;
- secure_vector<byte> msg2;
+ secure_vector<uint8_t> msg1raw;
+ secure_vector<uint8_t> msg2;
if(raw.size() > capacity)
{
- msg1raw = secure_vector<byte> (raw.begin(), raw.begin() + capacity);
- msg2 = secure_vector<byte> (raw.begin() + capacity, raw.end());
+ msg1raw = secure_vector<uint8_t> (raw.begin(), raw.begin() + capacity);
+ msg2 = secure_vector<uint8_t> (raw.begin() + capacity, raw.end());
hash->update(msg2);
}
else
@@ -177,7 +177,7 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
hash->update(msg1raw);
hash->update(msg2);
hash->update(salt);
- secure_vector<byte> H3 = hash->final();
+ secure_vector<uint8_t> H3 = hash->final();
//compute H3(C*||msg1*||H(msg2)||S*) * indicates a recovered value
uint64_t msgLength = msg1.size();
@@ -185,7 +185,7 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
hash->update(msg1);
hash->update(msg2);
hash->update(salt);
- secure_vector<byte> H2 = hash->final();
+ secure_vector<uint8_t> H2 = hash->final();
//check if H3 == H2
return same_mem(H3.data(), H2.data(), HASH_SIZE);
@@ -196,7 +196,7 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
* ISO-9796-2 signature scheme 2
* DS 2 is probabilistic
*/
-void ISO_9796_DS2::update(const byte input[], size_t length)
+void ISO_9796_DS2::update(const uint8_t input[], size_t length)
{
//need to buffer message completely, before digest
m_msg_buffer.insert(m_msg_buffer.end(), input, input+length);
@@ -205,9 +205,9 @@ void ISO_9796_DS2::update(const byte input[], size_t length)
/*
* Return the raw (unencoded) data
*/
-secure_vector<byte> ISO_9796_DS2::raw_data()
+secure_vector<uint8_t> ISO_9796_DS2::raw_data()
{
- secure_vector<byte> retbuffer = m_msg_buffer;
+ secure_vector<uint8_t> retbuffer = m_msg_buffer;
m_msg_buffer.clear();
return retbuffer;
}
@@ -215,7 +215,7 @@ secure_vector<byte> ISO_9796_DS2::raw_data()
/*
* ISO-9796-2 scheme 2 encode operation
*/
-secure_vector<byte> ISO_9796_DS2::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> ISO_9796_DS2::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits, RandomNumberGenerator& rng)
{
return iso9796_encoding(msg, output_bits, m_hash, m_SALT_SIZE, m_implicit, rng);
@@ -224,8 +224,8 @@ secure_vector<byte> ISO_9796_DS2::encoding_of(const secure_vector<byte>& msg,
/*
* ISO-9796-2 scheme 2 verify operation
*/
-bool ISO_9796_DS2::verify(const secure_vector<byte>& const_coded,
- const secure_vector<byte>& raw, size_t key_bits)
+bool ISO_9796_DS2::verify(const secure_vector<uint8_t>& const_coded,
+ const secure_vector<uint8_t>& raw, size_t key_bits)
{
return iso9796_verification(const_coded,raw,key_bits,m_hash,m_SALT_SIZE);
}
@@ -234,7 +234,7 @@ bool ISO_9796_DS2::verify(const secure_vector<byte>& const_coded,
* ISO-9796-2 signature scheme 3
* DS 3 is deterministic and equals DS2 without salt
*/
-void ISO_9796_DS3::update(const byte input[], size_t length)
+void ISO_9796_DS3::update(const uint8_t input[], size_t length)
{
//need to buffer message completely, before digest
m_msg_buffer.insert(m_msg_buffer.end(), input, input+length);
@@ -243,9 +243,9 @@ void ISO_9796_DS3::update(const byte input[], size_t length)
/*
* Return the raw (unencoded) data
*/
-secure_vector<byte> ISO_9796_DS3::raw_data()
+secure_vector<uint8_t> ISO_9796_DS3::raw_data()
{
- secure_vector<byte> retbuffer = m_msg_buffer;
+ secure_vector<uint8_t> retbuffer = m_msg_buffer;
m_msg_buffer.clear();
return retbuffer;
}
@@ -253,7 +253,7 @@ secure_vector<byte> ISO_9796_DS3::raw_data()
/*
* ISO-9796-2 scheme 3 encode operation
*/
-secure_vector<byte> ISO_9796_DS3::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> ISO_9796_DS3::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits, RandomNumberGenerator& rng)
{
return iso9796_encoding(msg, output_bits, m_hash, 0, m_implicit, rng);
@@ -262,8 +262,8 @@ secure_vector<byte> ISO_9796_DS3::encoding_of(const secure_vector<byte>& msg,
/*
* ISO-9796-2 scheme 3 verify operation
*/
-bool ISO_9796_DS3::verify(const secure_vector<byte>& const_coded,
- const secure_vector<byte>& raw, size_t key_bits)
+bool ISO_9796_DS3::verify(const secure_vector<uint8_t>& const_coded,
+ const secure_vector<uint8_t>& raw, size_t key_bits)
{
return iso9796_verification(const_coded, raw, key_bits, m_hash, 0);
}
diff --git a/src/lib/pk_pad/iso9796/iso9796.h b/src/lib/pk_pad/iso9796/iso9796.h
index da3fff055..81e008e47 100644
--- a/src/lib/pk_pad/iso9796/iso9796.h
+++ b/src/lib/pk_pad/iso9796/iso9796.h
@@ -37,22 +37,22 @@ class BOTAN_DLL ISO_9796_DS2 final : public EMSA
EMSA* clone() override
{return new ISO_9796_DS2(m_hash->clone(), m_implicit, m_SALT_SIZE);}
private:
- void update(const byte input[], size_t length) override;
+ void update(const uint8_t input[], size_t length) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) override;
std::unique_ptr<HashFunction> m_hash;
bool m_implicit;
size_t m_SALT_SIZE;
- secure_vector<byte> m_msg_buffer;
+ secure_vector<uint8_t> m_msg_buffer;
};
/**
@@ -71,21 +71,21 @@ class BOTAN_DLL ISO_9796_DS3 final : public EMSA
EMSA* clone() override
{return new ISO_9796_DS3(m_hash->clone(), m_implicit);}
private:
- void update(const byte input[], size_t length) override;
+ void update(const uint8_t input[], size_t length) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) override;
std::unique_ptr<HashFunction> m_hash;
bool m_implicit;
- secure_vector<byte> m_msg_buffer;
+ secure_vector<uint8_t> m_msg_buffer;
};
}
diff --git a/src/lib/pk_pad/mgf1/mgf1.cpp b/src/lib/pk_pad/mgf1/mgf1.cpp
index 34bc4a9a9..8903ac6f0 100644
--- a/src/lib/pk_pad/mgf1/mgf1.cpp
+++ b/src/lib/pk_pad/mgf1/mgf1.cpp
@@ -12,16 +12,16 @@
namespace Botan {
void mgf1_mask(HashFunction& hash,
- const byte in[], size_t in_len,
- byte out[], size_t out_len)
+ const uint8_t in[], size_t in_len,
+ uint8_t out[], size_t out_len)
{
- u32bit counter = 0;
+ uint32_t counter = 0;
while(out_len)
{
hash.update(in, in_len);
hash.update_be(counter);
- secure_vector<byte> buffer = hash.final();
+ secure_vector<uint8_t> buffer = hash.final();
size_t xored = std::min<size_t>(buffer.size(), out_len);
xor_buf(out, buffer.data(), xored);
diff --git a/src/lib/pk_pad/mgf1/mgf1.h b/src/lib/pk_pad/mgf1/mgf1.h
index 034b0328e..27160bd9a 100644
--- a/src/lib/pk_pad/mgf1/mgf1.h
+++ b/src/lib/pk_pad/mgf1/mgf1.h
@@ -21,8 +21,8 @@ namespace Botan {
* @param out_len size of the output buffer in bytes
*/
void BOTAN_DLL mgf1_mask(HashFunction& hash,
- const byte in[], size_t in_len,
- byte out[], size_t out_len);
+ const uint8_t in[], size_t in_len,
+ uint8_t out[], size_t out_len);
}
diff --git a/src/lib/prov/openssl/openssl_block.cpp b/src/lib/prov/openssl/openssl_block.cpp
index cb98be70d..842730af7 100644
--- a/src/lib/prov/openssl/openssl_block.cpp
+++ b/src/lib/prov/openssl/openssl_block.cpp
@@ -34,19 +34,19 @@ class OpenSSL_BlockCipher : public BlockCipher
Key_Length_Specification key_spec() const override { return m_cipher_key_spec; }
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
{
int out_len = 0;
EVP_EncryptUpdate(&m_encrypt, out, &out_len, in, blocks * m_block_sz);
}
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
{
int out_len = 0;
EVP_DecryptUpdate(&m_decrypt, out, &out_len, in, blocks * m_block_sz);
}
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
size_t m_block_sz;
Key_Length_Specification m_cipher_key_spec;
@@ -104,9 +104,9 @@ OpenSSL_BlockCipher::~OpenSSL_BlockCipher()
/*
* Set the key
*/
-void OpenSSL_BlockCipher::key_schedule(const byte key[], size_t length)
+void OpenSSL_BlockCipher::key_schedule(const uint8_t key[], size_t length)
{
- secure_vector<byte> full_key(key, key + length);
+ secure_vector<uint8_t> full_key(key, key + length);
if(m_cipher_name == "TripleDES" && length == 16)
{
diff --git a/src/lib/prov/openssl/openssl_ec.cpp b/src/lib/prov/openssl/openssl_ec.cpp
index 5fe7865a1..84f3a1ca0 100644
--- a/src/lib/prov/openssl/openssl_ec.cpp
+++ b/src/lib/prov/openssl/openssl_ec.cpp
@@ -43,7 +43,7 @@ namespace Botan {
namespace {
-secure_vector<byte> PKCS8_for_openssl(const EC_PrivateKey& ec)
+secure_vector<uint8_t> PKCS8_for_openssl(const EC_PrivateKey& ec)
{
const PointGFp& pub_key = ec.public_point();
const BigInt& priv_key = ec.private_value();
@@ -123,8 +123,8 @@ class OpenSSL_ECDSA_Verification_Operation : public PK_Ops::Verification_with_EM
::EC_KEY_set_group(m_ossl_ec.get(), grp.get());
- const secure_vector<byte> enc = EC2OSP(ecdsa.public_point(), PointGFp::UNCOMPRESSED);
- const byte* enc_ptr = enc.data();
+ const secure_vector<uint8_t> enc = EC2OSP(ecdsa.public_point(), PointGFp::UNCOMPRESSED);
+ const uint8_t* enc_ptr = enc.data();
EC_KEY* key_ptr = m_ossl_ec.get();
if(!::o2i_ECPublicKey(&key_ptr, &enc_ptr, enc.size()))
throw OpenSSL_Error("o2i_ECPublicKey");
@@ -137,8 +137,8 @@ class OpenSSL_ECDSA_Verification_Operation : public PK_Ops::Verification_with_EM
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig_bytes[], size_t sig_len) override
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig_bytes[], size_t sig_len) override
{
const size_t order_bytes = (m_order_bits + 7) / 8;
if(sig_len != 2 * order_bytes)
@@ -168,8 +168,8 @@ class OpenSSL_ECDSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
PK_Ops::Signature_with_EMSA(emsa),
m_ossl_ec(nullptr, ::EC_KEY_free)
{
- const secure_vector<byte> der = PKCS8_for_openssl(ecdsa);
- const byte* der_ptr = der.data();
+ const secure_vector<uint8_t> der = PKCS8_for_openssl(ecdsa);
+ const uint8_t* der_ptr = der.data();
m_ossl_ec.reset(d2i_ECPrivateKey(nullptr, &der_ptr, der.size()));
if(!m_ossl_ec)
throw OpenSSL_Error("d2i_ECPrivateKey");
@@ -178,7 +178,7 @@ class OpenSSL_ECDSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
m_order_bits = ::EC_GROUP_get_degree(group);
}
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator&) override
{
std::unique_ptr<ECDSA_SIG, std::function<void (ECDSA_SIG*)>> sig(nullptr, ECDSA_SIG_free);
@@ -190,7 +190,7 @@ class OpenSSL_ECDSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
const size_t order_bytes = (m_order_bits + 7) / 8;
const size_t r_bytes = BN_num_bytes(sig->r);
const size_t s_bytes = BN_num_bytes(sig->s);
- secure_vector<byte> sigval(2*order_bytes);
+ secure_vector<uint8_t> sigval(2*order_bytes);
BN_bn2bin(sig->r, &sigval[order_bytes - r_bytes]);
BN_bn2bin(sig->s, &sigval[2*order_bytes - s_bytes]);
return sigval;
@@ -240,18 +240,18 @@ class OpenSSL_ECDH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
OpenSSL_ECDH_KA_Operation(const ECDH_PrivateKey& ecdh, const std::string& kdf) :
PK_Ops::Key_Agreement_with_KDF(kdf), m_ossl_ec(::EC_KEY_new(), ::EC_KEY_free)
{
- const secure_vector<byte> der = PKCS8_for_openssl(ecdh);
- const byte* der_ptr = der.data();
+ const secure_vector<uint8_t> der = PKCS8_for_openssl(ecdh);
+ const uint8_t* der_ptr = der.data();
m_ossl_ec.reset(d2i_ECPrivateKey(nullptr, &der_ptr, der.size()));
if(!m_ossl_ec)
throw OpenSSL_Error("d2i_ECPrivateKey");
}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override
{
const EC_GROUP* group = ::EC_KEY_get0_group(m_ossl_ec.get());
const size_t out_len = (::EC_GROUP_get_degree(group) + 7) / 8;
- secure_vector<byte> out(out_len);
+ secure_vector<uint8_t> out(out_len);
EC_POINT* pub_key = ::EC_POINT_new(group);
if(!pub_key)
diff --git a/src/lib/prov/openssl/openssl_hash.cpp b/src/lib/prov/openssl/openssl_hash.cpp
index 8e36866a1..19a12d938 100644
--- a/src/lib/prov/openssl/openssl_hash.cpp
+++ b/src/lib/prov/openssl/openssl_hash.cpp
@@ -54,12 +54,12 @@ class OpenSSL_HashFunction : public HashFunction
}
private:
- void add_data(const byte input[], size_t length) override
+ void add_data(const uint8_t input[], size_t length) override
{
EVP_DigestUpdate(&m_md, input, length);
}
- void final_result(byte output[]) override
+ void final_result(uint8_t output[]) override
{
EVP_DigestFinal_ex(&m_md, output, nullptr);
const EVP_MD* algo = EVP_MD_CTX_md(&m_md);
diff --git a/src/lib/prov/openssl/openssl_rc4.cpp b/src/lib/prov/openssl/openssl_rc4.cpp
index c8ba32235..9cca7fdd1 100644
--- a/src/lib/prov/openssl/openssl_rc4.cpp
+++ b/src/lib/prov/openssl/openssl_rc4.cpp
@@ -48,26 +48,26 @@ class OpenSSL_RC4 : public StreamCipher
explicit OpenSSL_RC4(size_t skip = 0) : m_skip(skip) { clear(); }
~OpenSSL_RC4() { clear(); }
- void set_iv(const byte*, size_t len) override
+ void set_iv(const uint8_t*, size_t len) override
{
if(len > 0)
throw Exception("RC4 does not support an IV");
}
- void seek(u64bit) override
+ void seek(uint64_t) override
{
throw Exception("RC4 does not support seeking");
}
private:
- void cipher(const byte in[], byte out[], size_t length) override
+ void cipher(const uint8_t in[], uint8_t out[], size_t length) override
{
::RC4(&m_rc4, length, in, out);
}
- void key_schedule(const byte key[], size_t length) override
+ void key_schedule(const uint8_t key[], size_t length) override
{
::RC4_set_key(&m_rc4, length, key);
- byte d = 0;
+ uint8_t d = 0;
for(size_t i = 0; i != m_skip; ++i)
::RC4(&m_rc4, 1, &d, &d);
}
diff --git a/src/lib/prov/openssl/openssl_rsa.cpp b/src/lib/prov/openssl/openssl_rsa.cpp
index aef9c95d8..e7a562cf5 100644
--- a/src/lib/prov/openssl/openssl_rsa.cpp
+++ b/src/lib/prov/openssl/openssl_rsa.cpp
@@ -44,8 +44,8 @@ class OpenSSL_RSA_Encryption_Operation : public PK_Ops::Encryption
OpenSSL_RSA_Encryption_Operation(const RSA_PublicKey& rsa, int pad, size_t pad_overhead) :
m_openssl_rsa(nullptr, ::RSA_free), m_padding(pad)
{
- const std::vector<byte> der = rsa.public_key_bits();
- const byte* der_ptr = der.data();
+ const std::vector<uint8_t> der = rsa.public_key_bits();
+ const uint8_t* der_ptr = der.data();
m_openssl_rsa.reset(::d2i_RSAPublicKey(nullptr, &der_ptr, der.size()));
if(!m_openssl_rsa)
throw OpenSSL_Error("d2i_RSAPublicKey");
@@ -55,7 +55,7 @@ class OpenSSL_RSA_Encryption_Operation : public PK_Ops::Encryption
size_t max_input_bits() const override { return m_bits; };
- secure_vector<byte> encrypt(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator&) override
{
const size_t mod_sz = n_size();
@@ -63,9 +63,9 @@ class OpenSSL_RSA_Encryption_Operation : public PK_Ops::Encryption
if(msg_len > mod_sz)
throw Invalid_Argument("Input too large for RSA key");
- secure_vector<byte> outbuf(mod_sz);
+ secure_vector<uint8_t> outbuf(mod_sz);
- secure_vector<byte> inbuf;
+ secure_vector<uint8_t> inbuf;
if(m_padding == RSA_NO_PADDING)
{
@@ -99,17 +99,17 @@ class OpenSSL_RSA_Decryption_Operation : public PK_Ops::Decryption
OpenSSL_RSA_Decryption_Operation(const RSA_PrivateKey& rsa, int pad) :
m_openssl_rsa(nullptr, ::RSA_free), m_padding(pad)
{
- const secure_vector<byte> der = rsa.private_key_bits();
- const byte* der_ptr = der.data();
+ const secure_vector<uint8_t> der = rsa.private_key_bits();
+ const uint8_t* der_ptr = der.data();
m_openssl_rsa.reset(d2i_RSAPrivateKey(nullptr, &der_ptr, der.size()));
if(!m_openssl_rsa)
throw OpenSSL_Error("d2i_RSAPrivateKey");
}
- secure_vector<byte> decrypt(byte& valid_mask,
- const byte msg[], size_t msg_len) override
+ secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
+ const uint8_t msg[], size_t msg_len) override
{
- secure_vector<byte> buf(::RSA_size(m_openssl_rsa.get()));
+ secure_vector<uint8_t> buf(::RSA_size(m_openssl_rsa.get()));
int rc = ::RSA_private_decrypt(msg_len, msg, buf.data(), m_openssl_rsa.get(), m_padding);
if(rc < 0 || static_cast<size_t>(rc) > buf.size())
{
@@ -143,8 +143,8 @@ class OpenSSL_RSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
PK_Ops::Verification_with_EMSA(emsa),
m_openssl_rsa(nullptr, ::RSA_free)
{
- const std::vector<byte> der = rsa.public_key_bits();
- const byte* der_ptr = der.data();
+ const std::vector<uint8_t> der = rsa.public_key_bits();
+ const uint8_t* der_ptr = der.data();
m_openssl_rsa.reset(::d2i_RSAPublicKey(nullptr, &der_ptr, der.size()));
}
@@ -152,17 +152,17 @@ class OpenSSL_RSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return true; }
- secure_vector<byte> verify_mr(const byte msg[], size_t msg_len) override
+ secure_vector<uint8_t> verify_mr(const uint8_t msg[], size_t msg_len) override
{
const size_t mod_sz = ::RSA_size(m_openssl_rsa.get());
if(msg_len > mod_sz)
throw Invalid_Argument("OpenSSL RSA verify input too large");
- secure_vector<byte> inbuf(mod_sz);
+ secure_vector<uint8_t> inbuf(mod_sz);
copy_mem(&inbuf[mod_sz - msg_len], msg, msg_len);
- secure_vector<byte> outbuf(mod_sz);
+ secure_vector<uint8_t> outbuf(mod_sz);
int rc = ::RSA_public_decrypt(inbuf.size(), inbuf.data(), outbuf.data(),
m_openssl_rsa.get(), RSA_NO_PADDING);
@@ -183,14 +183,14 @@ class OpenSSL_RSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
PK_Ops::Signature_with_EMSA(emsa),
m_openssl_rsa(nullptr, ::RSA_free)
{
- const secure_vector<byte> der = rsa.private_key_bits();
- const byte* der_ptr = der.data();
+ const secure_vector<uint8_t> der = rsa.private_key_bits();
+ const uint8_t* der_ptr = der.data();
m_openssl_rsa.reset(d2i_RSAPrivateKey(nullptr, &der_ptr, der.size()));
if(!m_openssl_rsa)
throw OpenSSL_Error("d2i_RSAPrivateKey");
}
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator&) override
{
const size_t mod_sz = ::RSA_size(m_openssl_rsa.get());
@@ -198,10 +198,10 @@ class OpenSSL_RSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
if(msg_len > mod_sz)
throw Invalid_Argument("OpenSSL RSA sign input too large");
- secure_vector<byte> inbuf(mod_sz);
+ secure_vector<uint8_t> inbuf(mod_sz);
copy_mem(&inbuf[mod_sz - msg_len], msg, msg_len);
- secure_vector<byte> outbuf(mod_sz);
+ secure_vector<uint8_t> outbuf(mod_sz);
int rc = ::RSA_private_encrypt(inbuf.size(), inbuf.data(), outbuf.data(),
m_openssl_rsa.get(), RSA_NO_PADDING);
diff --git a/src/lib/prov/pkcs11/p11.h b/src/lib/prov/pkcs11/p11.h
index 72abcd611..efc887e11 100644
--- a/src/lib/prov/pkcs11/p11.h
+++ b/src/lib/prov/pkcs11/p11.h
@@ -58,7 +58,7 @@ static_assert(CRYPTOKI_VERSION_MAJOR == 2 && CRYPTOKI_VERSION_MINOR == 40,
namespace Botan {
namespace PKCS11 {
-using secure_string = secure_vector<byte>;
+using secure_string = secure_vector<uint8_t>;
enum class AttributeType : CK_ATTRIBUTE_TYPE
{
@@ -1149,7 +1149,7 @@ class BOTAN_DLL LowLevel
*/
template<typename TAlloc>
bool C_InitToken(SlotId slot_id,
- const std::vector<byte, TAlloc>& so_pin,
+ const std::vector<uint8_t, TAlloc>& so_pin,
const std::string& label,
ReturnValue* return_value = ThrowException) const
{
@@ -1159,7 +1159,7 @@ class BOTAN_DLL LowLevel
padded_label.insert(padded_label.end(), 32 - label.size(), ' ');
}
- return C_InitToken(slot_id, reinterpret_cast< Utf8Char* >(const_cast< byte* >(so_pin.data())),
+ return C_InitToken(slot_id, reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(so_pin.data())),
so_pin.size(), reinterpret_cast< Utf8Char* >(const_cast< char* >(padded_label.c_str())), return_value);
}
@@ -1201,10 +1201,10 @@ class BOTAN_DLL LowLevel
*/
template<typename TAlloc>
bool C_InitPIN(SessionHandle session,
- const std::vector<byte, TAlloc>& pin,
+ const std::vector<uint8_t, TAlloc>& pin,
ReturnValue* return_value = ThrowException) const
{
- return C_InitPIN(session, reinterpret_cast< Utf8Char* >(const_cast< byte* >(pin.data())), pin.size(), return_value);
+ return C_InitPIN(session, reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(pin.data())), pin.size(), return_value);
}
/**
@@ -1250,13 +1250,13 @@ class BOTAN_DLL LowLevel
*/
template<typename TAlloc>
bool C_SetPIN(SessionHandle session,
- const std::vector<byte, TAlloc>& old_pin,
- const std::vector<byte, TAlloc>& new_pin,
+ const std::vector<uint8_t, TAlloc>& old_pin,
+ const std::vector<uint8_t, TAlloc>& new_pin,
ReturnValue* return_value = ThrowException) const
{
return C_SetPIN(session,
- reinterpret_cast< Utf8Char* >(const_cast< byte* >(old_pin.data())), old_pin.size(),
- reinterpret_cast< Utf8Char* >(const_cast< byte* >(new_pin.data())), new_pin.size(),
+ reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(old_pin.data())), old_pin.size(),
+ reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(new_pin.data())), new_pin.size(),
return_value);
}
@@ -1423,10 +1423,10 @@ class BOTAN_DLL LowLevel
template<typename TAlloc>
bool C_Login(SessionHandle session,
UserType user_type,
- const std::vector<byte, TAlloc>& pin,
+ const std::vector<uint8_t, TAlloc>& pin,
ReturnValue* return_value = ThrowException) const
{
- return C_Login(session, user_type, reinterpret_cast< Utf8Char* >(const_cast< byte* >(pin.data())), pin.size(),
+ return C_Login(session, user_type, reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(pin.data())), pin.size(),
return_value);
}
@@ -1576,7 +1576,7 @@ class BOTAN_DLL LowLevel
template<typename TAlloc>
bool C_GetAttributeValue(SessionHandle session,
ObjectHandle object,
- std::map<AttributeType, std::vector<byte, TAlloc>>& attribute_values,
+ std::map<AttributeType, std::vector<uint8_t, TAlloc>>& attribute_values,
ReturnValue* return_value = ThrowException) const
{
std::vector<Attribute> getter_template;
@@ -1599,7 +1599,7 @@ class BOTAN_DLL LowLevel
{
entry.second.clear();
entry.second.resize(getter_template.at(i).ulValueLen);
- getter_template.at(i).pValue = const_cast< byte* >(entry.second.data());
+ getter_template.at(i).pValue = const_cast< uint8_t* >(entry.second.data());
i++;
}
@@ -1651,7 +1651,7 @@ class BOTAN_DLL LowLevel
template<typename TAlloc>
bool C_SetAttributeValue(SessionHandle session,
ObjectHandle object,
- std::map<AttributeType, std::vector<byte, TAlloc>>& attribute_values,
+ std::map<AttributeType, std::vector<uint8_t, TAlloc>>& attribute_values,
ReturnValue* return_value = ThrowException) const
{
std::vector<Attribute> setter_template;
@@ -1788,8 +1788,8 @@ class BOTAN_DLL LowLevel
*/
template<typename TAllocA, typename TAllocB>
bool C_Encrypt(SessionHandle session,
- const std::vector<byte, TAllocA>& plaintext_data,
- std::vector<byte, TAllocB>& encrypted_data,
+ const std::vector<uint8_t, TAllocA>& plaintext_data,
+ std::vector<uint8_t, TAllocB>& encrypted_data,
ReturnValue* return_value = ThrowException) const
{
Ulong encrypted_size = 0;
@@ -1915,8 +1915,8 @@ class BOTAN_DLL LowLevel
*/
template<typename TAllocA, typename TAllocB>
bool C_Decrypt(SessionHandle session,
- const std::vector<byte, TAllocA>& encrypted_data,
- std::vector<byte, TAllocB>& decrypted_data,
+ const std::vector<uint8_t, TAllocA>& encrypted_data,
+ std::vector<uint8_t, TAllocB>& decrypted_data,
ReturnValue* return_value = ThrowException) const
{
Ulong decrypted_size = 0;
@@ -2064,7 +2064,7 @@ class BOTAN_DLL LowLevel
* C_DigestFinal finishes a multiple-part message-digesting operation.
* @param session the session's handle
* @param digest_ptr gets the message digest
- * @param digest_len_ptr gets byte count of digest
+ * @param digest_len_ptr gets uint8_t count of digest
* @param return_value default value (`ThrowException`): throw exception on error.
* if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown.
* At least the following PKCS#11 return values may be returned:
@@ -2147,8 +2147,8 @@ class BOTAN_DLL LowLevel
*/
template<typename TAllocA, typename TAllocB>
bool C_Sign(SessionHandle session,
- const std::vector<byte, TAllocA>& data,
- std::vector<byte, TAllocB>& signature,
+ const std::vector<uint8_t, TAllocA>& data,
+ std::vector<uint8_t, TAllocB>& signature,
ReturnValue* return_value = ThrowException) const
{
Ulong signature_size = 0;
@@ -2197,7 +2197,7 @@ class BOTAN_DLL LowLevel
*/
template<typename TAlloc>
bool C_SignUpdate(SessionHandle session,
- const std::vector<byte, TAlloc>& part,
+ const std::vector<uint8_t, TAlloc>& part,
ReturnValue* return_value = ThrowException) const
{
return C_SignUpdate(session, const_cast<Byte*>(part.data()), part.size(), return_value);
@@ -2241,7 +2241,7 @@ class BOTAN_DLL LowLevel
*/
template<typename TAlloc>
bool C_SignFinal(SessionHandle session,
- std::vector<byte, TAlloc>& signature,
+ std::vector<uint8_t, TAlloc>& signature,
ReturnValue* return_value = ThrowException) const
{
Ulong signature_size = 0;
@@ -2368,8 +2368,8 @@ class BOTAN_DLL LowLevel
*/
template<typename TAllocA, typename TAllocB>
bool C_Verify(SessionHandle session,
- const std::vector<byte, TAllocA>& data,
- std::vector<byte, TAllocB>& signature,
+ const std::vector<uint8_t, TAllocA>& data,
+ std::vector<uint8_t, TAllocB>& signature,
ReturnValue* return_value = ThrowException) const
{
return C_Verify(session, const_cast<Byte*>(data.data()), data.size(), signature.data(), signature.size(), return_value);
@@ -2411,7 +2411,7 @@ class BOTAN_DLL LowLevel
*/
template<typename TAlloc>
bool C_VerifyUpdate(SessionHandle session,
- std::vector<byte, TAlloc> part,
+ std::vector<uint8_t, TAlloc> part,
ReturnValue* return_value = ThrowException) const
{
return C_VerifyUpdate(session, part.data(), part.size(), return_value);
diff --git a/src/lib/prov/pkcs11/p11_ecc_key.cpp b/src/lib/prov/pkcs11/p11_ecc_key.cpp
index 527daceaf..9366594a6 100644
--- a/src/lib/prov/pkcs11/p11_ecc_key.cpp
+++ b/src/lib/prov/pkcs11/p11_ecc_key.cpp
@@ -17,22 +17,22 @@ namespace Botan {
namespace PKCS11 {
namespace {
/// Converts a DER-encoded ANSI X9.62 ECPoint to PointGFp
-PointGFp decode_public_point(const secure_vector<byte>& ec_point_data, const CurveGFp& curve)
+PointGFp decode_public_point(const secure_vector<uint8_t>& ec_point_data, const CurveGFp& curve)
{
- secure_vector<byte> ec_point;
+ secure_vector<uint8_t> ec_point;
BER_Decoder(ec_point_data).decode(ec_point, OCTET_STRING);
return OS2ECP(ec_point, curve);
}
}
-EC_PublicKeyGenerationProperties::EC_PublicKeyGenerationProperties(const std::vector<byte>& ec_params)
+EC_PublicKeyGenerationProperties::EC_PublicKeyGenerationProperties(const std::vector<uint8_t>& ec_params)
: PublicKeyProperties(KeyType::Ec), m_ec_params(ec_params)
{
add_binary(AttributeType::EcParams, m_ec_params);
}
-EC_PublicKeyImportProperties::EC_PublicKeyImportProperties(const std::vector<byte>& ec_params,
- const std::vector<byte>& ec_point)
+EC_PublicKeyImportProperties::EC_PublicKeyImportProperties(const std::vector<uint8_t>& ec_params,
+ const std::vector<uint8_t>& ec_point)
: PublicKeyProperties(KeyType::Ec), m_ec_params(ec_params), m_ec_point(ec_point)
{
add_binary(AttributeType::EcParams, m_ec_params);
@@ -42,7 +42,7 @@ EC_PublicKeyImportProperties::EC_PublicKeyImportProperties(const std::vector<byt
PKCS11_EC_PublicKey::PKCS11_EC_PublicKey(Session& session, ObjectHandle handle)
: Object(session, handle)
{
- secure_vector<byte> ec_parameters = get_attribute_value(AttributeType::EcParams);
+ secure_vector<uint8_t> ec_parameters = get_attribute_value(AttributeType::EcParams);
m_domain_params = EC_Group(unlock(ec_parameters));
m_public_key = decode_public_point(get_attribute_value(AttributeType::EcPoint), m_domain_params.get_curve());
m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT;
@@ -53,13 +53,13 @@ PKCS11_EC_PublicKey::PKCS11_EC_PublicKey(Session& session, const EC_PublicKeyImp
{
m_domain_params = EC_Group(props.ec_params());
- secure_vector<byte> ec_point;
+ secure_vector<uint8_t> ec_point;
BER_Decoder(props.ec_point()).decode(ec_point, OCTET_STRING);
m_public_key = OS2ECP(ec_point, m_domain_params.get_curve());
m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT;
}
-EC_PrivateKeyImportProperties::EC_PrivateKeyImportProperties(const std::vector<byte>& ec_params, const BigInt& value)
+EC_PrivateKeyImportProperties::EC_PrivateKeyImportProperties(const std::vector<uint8_t>& ec_params, const BigInt& value)
: PrivateKeyProperties(KeyType::Ec), m_ec_params(ec_params), m_value(value)
{
add_binary(AttributeType::EcParams, m_ec_params);
@@ -69,7 +69,7 @@ EC_PrivateKeyImportProperties::EC_PrivateKeyImportProperties(const std::vector<b
PKCS11_EC_PrivateKey::PKCS11_EC_PrivateKey(Session& session, ObjectHandle handle)
: Object(session, handle), m_domain_params(), m_public_key()
{
- secure_vector<byte> ec_parameters = get_attribute_value(AttributeType::EcParams);
+ secure_vector<uint8_t> ec_parameters = get_attribute_value(AttributeType::EcParams);
m_domain_params = EC_Group(unlock(ec_parameters));
}
@@ -79,7 +79,7 @@ PKCS11_EC_PrivateKey::PKCS11_EC_PrivateKey(Session& session, const EC_PrivateKey
m_domain_params = EC_Group(props.ec_params());
}
-PKCS11_EC_PrivateKey::PKCS11_EC_PrivateKey(Session& session, const std::vector<byte>& ec_params,
+PKCS11_EC_PrivateKey::PKCS11_EC_PrivateKey(Session& session, const std::vector<uint8_t>& ec_params,
const EC_PrivateKeyGenerationProperties& props)
: Object(session)
{
@@ -106,7 +106,7 @@ size_t PKCS11_EC_PrivateKey::key_length() const
return m_domain_params.get_order().bits();
}
-std::vector<byte> PKCS11_EC_PrivateKey::public_key_bits() const
+std::vector<uint8_t> PKCS11_EC_PrivateKey::public_key_bits() const
{
return unlock(EC2OSP(public_point(), PointGFp::COMPRESSED));
}
diff --git a/src/lib/prov/pkcs11/p11_ecc_key.h b/src/lib/prov/pkcs11/p11_ecc_key.h
index 69e612c33..6762d448e 100644
--- a/src/lib/prov/pkcs11/p11_ecc_key.h
+++ b/src/lib/prov/pkcs11/p11_ecc_key.h
@@ -30,16 +30,16 @@ class BOTAN_DLL EC_PublicKeyGenerationProperties final : public PublicKeyPropert
{
public:
/// @param ec_params DER-encoding of an ANSI X9.62 Parameters value
- EC_PublicKeyGenerationProperties(const std::vector<byte>& ec_params);
+ EC_PublicKeyGenerationProperties(const std::vector<uint8_t>& ec_params);
/// @return the DER-encoding of the ec parameters according to ANSI X9.62
- inline const std::vector<byte>& ec_params() const
+ inline const std::vector<uint8_t>& ec_params() const
{
return m_ec_params;
}
private:
- const std::vector<byte> m_ec_params;
+ const std::vector<uint8_t> m_ec_params;
};
/// Properties for importing a PKCS#11 EC public key
@@ -50,23 +50,23 @@ class BOTAN_DLL EC_PublicKeyImportProperties final : public PublicKeyProperties
* @param ec_params DER-encoding of an ANSI X9.62 Parameters value
* @param ec_point DER-encoding of ANSI X9.62 ECPoint value Q
*/
- EC_PublicKeyImportProperties(const std::vector<byte>& ec_params, const std::vector<byte>& ec_point);
+ EC_PublicKeyImportProperties(const std::vector<uint8_t>& ec_params, const std::vector<uint8_t>& ec_point);
/// @return the DER-encoding of the ec parameters according to ANSI X9.62
- inline const std::vector<byte>& ec_params() const
+ inline const std::vector<uint8_t>& ec_params() const
{
return m_ec_params;
}
/// @return the DER-encoding of the ec public point according to ANSI X9.62
- inline const std::vector<byte>& ec_point() const
+ inline const std::vector<uint8_t>& ec_point() const
{
return m_ec_point;
}
private:
- const std::vector<byte> m_ec_params;
- const std::vector<byte> m_ec_point;
+ const std::vector<uint8_t> m_ec_params;
+ const std::vector<uint8_t> m_ec_point;
};
/// Represents a PKCS#11 EC public key
@@ -108,10 +108,10 @@ class BOTAN_DLL EC_PrivateKeyImportProperties final : public PrivateKeyPropertie
* @param ec_params DER-encoding of an ANSI X9.62 Parameters value
* @param value ANSI X9.62 private value d
*/
- EC_PrivateKeyImportProperties(const std::vector<byte>& ec_params, const BigInt& value);
+ EC_PrivateKeyImportProperties(const std::vector<uint8_t>& ec_params, const BigInt& value);
/// @return the DER-encoding of the ec parameters according to ANSI X9.62
- inline const std::vector<byte>& ec_params() const
+ inline const std::vector<uint8_t>& ec_params() const
{
return m_ec_params;
}
@@ -123,7 +123,7 @@ class BOTAN_DLL EC_PrivateKeyImportProperties final : public PrivateKeyPropertie
}
private:
- const std::vector<byte> m_ec_params;
+ const std::vector<uint8_t> m_ec_params;
const BigInt m_value;
};
@@ -157,7 +157,7 @@ class BOTAN_DLL PKCS11_EC_PrivateKey : public virtual Private_Key,
* @param props the attributes of the private key
* @note no persistent public key object will be created
*/
- PKCS11_EC_PrivateKey(Session& session, const std::vector<byte>& ec_params,
+ PKCS11_EC_PrivateKey(Session& session, const std::vector<uint8_t>& ec_params,
const EC_PrivateKeyGenerationProperties& props);
/// @returns the domain of the EC private key
@@ -201,7 +201,7 @@ class BOTAN_DLL PKCS11_EC_PrivateKey : public virtual Private_Key,
// Private_Key methods
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
std::size_t key_length() const override;
diff --git a/src/lib/prov/pkcs11/p11_ecdh.cpp b/src/lib/prov/pkcs11/p11_ecdh.cpp
index 50aa964d5..088b93894 100644
--- a/src/lib/prov/pkcs11/p11_ecdh.cpp
+++ b/src/lib/prov/pkcs11/p11_ecdh.cpp
@@ -33,7 +33,7 @@ ECDH_PrivateKey PKCS11_ECDH_PrivateKey::export_key() const
return ECDH_PrivateKey(rng, domain(), BigInt::decode(priv_key));
}
-secure_vector<byte> PKCS11_ECDH_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> PKCS11_ECDH_PrivateKey::private_key_bits() const
{
return export_key().private_key_bits();
}
@@ -49,10 +49,10 @@ class PKCS11_ECDH_KA_Operation : public PK_Ops::Key_Agreement
/// The encoding in V2.20 was not specified and resulted in different implementations choosing different encodings.
/// Applications relying only on a V2.20 encoding (e.g. the DER variant) other than the one specified now (raw) may not work with all V2.30 compliant tokens.
- secure_vector<byte> agree(size_t key_len, const byte other_key[], size_t other_key_len, const byte salt[],
+ secure_vector<uint8_t> agree(size_t key_len, const uint8_t other_key[], size_t other_key_len, const uint8_t salt[],
size_t salt_len) override
{
- std::vector<byte> der_encoded_other_key;
+ std::vector<uint8_t> der_encoded_other_key;
if(m_key.point_encoding() == PublicPointEncoding::Der)
{
der_encoded_other_key = DER_Encoder().encode(other_key, other_key_len, OCTET_STRING).get_contents_unlocked();
@@ -79,7 +79,7 @@ class PKCS11_ECDH_KA_Operation : public PK_Ops::Key_Agreement
attributes.count(), &secret_handle);
Object secret_object(m_key.session(), secret_handle);
- secure_vector<byte> secret = secret_object.get_attribute_value(AttributeType::Value);
+ secure_vector<uint8_t> secret = secret_object.get_attribute_value(AttributeType::Value);
if(secret.size() < key_len)
{
throw PKCS11_Error("ECDH key derivation secret length is too short");
diff --git a/src/lib/prov/pkcs11/p11_ecdh.h b/src/lib/prov/pkcs11/p11_ecdh.h
index 7fc21ad46..c8e4017ba 100644
--- a/src/lib/prov/pkcs11/p11_ecdh.h
+++ b/src/lib/prov/pkcs11/p11_ecdh.h
@@ -83,7 +83,7 @@ class BOTAN_DLL PKCS11_ECDH_PrivateKey final : public virtual PKCS11_EC_PrivateK
* @param props the attributes of the private key
* @note no persistent public key object will be created
*/
- PKCS11_ECDH_PrivateKey(Session& session, const std::vector<byte>& ec_params,
+ PKCS11_ECDH_PrivateKey(Session& session, const std::vector<uint8_t>& ec_params,
const EC_PrivateKeyGenerationProperties& props)
: PKCS11_EC_PrivateKey(session, ec_params, props)
{}
@@ -93,7 +93,7 @@ class BOTAN_DLL PKCS11_ECDH_PrivateKey final : public virtual PKCS11_EC_PrivateK
return "ECDH";
}
- inline std::vector<byte> public_value() const override
+ inline std::vector<uint8_t> public_value() const override
{
return unlock(EC2OSP(public_point(), PointGFp::UNCOMPRESSED));
}
@@ -101,7 +101,7 @@ class BOTAN_DLL PKCS11_ECDH_PrivateKey final : public virtual PKCS11_EC_PrivateK
/// @return the exported ECDH private key
ECDH_PrivateKey export_key() const;
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
std::unique_ptr<PK_Ops::Key_Agreement>
create_key_agreement_op(RandomNumberGenerator& rng,
diff --git a/src/lib/prov/pkcs11/p11_ecdsa.cpp b/src/lib/prov/pkcs11/p11_ecdsa.cpp
index cbdd4d007..5be66caaf 100644
--- a/src/lib/prov/pkcs11/p11_ecdsa.cpp
+++ b/src/lib/prov/pkcs11/p11_ecdsa.cpp
@@ -47,7 +47,7 @@ ECDSA_PrivateKey PKCS11_ECDSA_PrivateKey::export_key() const
return ECDSA_PrivateKey(rng, domain(), BigInt::decode(priv_key));
}
-secure_vector<byte> PKCS11_ECDSA_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> PKCS11_ECDSA_PrivateKey::private_key_bits() const
{
return export_key().private_key_bits();
}
@@ -61,14 +61,14 @@ class PKCS11_ECDSA_Signature_Operation : public PK_Ops::Signature
: PK_Ops::Signature(), m_key(key), m_order(key.domain().get_order()), m_mechanism(MechanismWrapper::create_ecdsa_mechanism(emsa))
{}
- void update(const byte msg[], size_t msg_len) override
+ void update(const uint8_t msg[], size_t msg_len) override
{
if(!m_initialized)
{
// first call to update: initialize and cache message because we can not determine yet whether a single- or multiple-part operation will be performed
m_key.module()->C_SignInit(m_key.session().handle(), m_mechanism.data(), m_key.handle());
m_initialized = true;
- m_first_message = secure_vector<byte>(msg, msg + msg_len);
+ m_first_message = secure_vector<uint8_t>(msg, msg + msg_len);
return;
}
@@ -82,9 +82,9 @@ class PKCS11_ECDSA_Signature_Operation : public PK_Ops::Signature
m_key.module()->C_SignUpdate(m_key.session().handle(), const_cast<Byte*>(msg), msg_len);
}
- secure_vector<byte> sign(RandomNumberGenerator&) override
+ secure_vector<uint8_t> sign(RandomNumberGenerator&) override
{
- secure_vector<byte> signature;
+ secure_vector<uint8_t> signature;
if(!m_first_message.empty())
{
// single call to update: perform single-part operation
@@ -104,7 +104,7 @@ class PKCS11_ECDSA_Signature_Operation : public PK_Ops::Signature
const PKCS11_EC_PrivateKey& m_key;
const BigInt& m_order;
MechanismWrapper m_mechanism;
- secure_vector<byte> m_first_message;
+ secure_vector<uint8_t> m_first_message;
bool m_initialized = false;
};
@@ -116,14 +116,14 @@ class PKCS11_ECDSA_Verification_Operation : public PK_Ops::Verification
: PK_Ops::Verification(), m_key(key), m_order(key.domain().get_order()), m_mechanism(MechanismWrapper::create_ecdsa_mechanism(emsa))
{}
- void update(const byte msg[], size_t msg_len) override
+ void update(const uint8_t msg[], size_t msg_len) override
{
if(!m_initialized)
{
// first call to update: initialize and cache message because we can not determine yet whether a single- or multiple-part operation will be performed
m_key.module()->C_VerifyInit(m_key.session().handle(), m_mechanism.data(), m_key.handle());
m_initialized = true;
- m_first_message = secure_vector<byte>(msg, msg + msg_len);
+ m_first_message = secure_vector<uint8_t>(msg, msg + msg_len);
return;
}
@@ -137,7 +137,7 @@ class PKCS11_ECDSA_Verification_Operation : public PK_Ops::Verification
m_key.module()->C_VerifyUpdate(m_key.session().handle(), const_cast<Byte*>(msg), msg_len);
}
- bool is_valid_signature(const byte sig[], size_t sig_len) override
+ bool is_valid_signature(const uint8_t sig[], size_t sig_len) override
{
ReturnValue return_value = ReturnValue::SignatureInvalid;
if(!m_first_message.empty())
@@ -164,7 +164,7 @@ class PKCS11_ECDSA_Verification_Operation : public PK_Ops::Verification
const PKCS11_EC_PublicKey& m_key;
const BigInt& m_order;
MechanismWrapper m_mechanism;
- secure_vector<byte> m_first_message;
+ secure_vector<uint8_t> m_first_message;
bool m_initialized = false;
};
diff --git a/src/lib/prov/pkcs11/p11_ecdsa.h b/src/lib/prov/pkcs11/p11_ecdsa.h
index 73ee900db..c1ac0d557 100644
--- a/src/lib/prov/pkcs11/p11_ecdsa.h
+++ b/src/lib/prov/pkcs11/p11_ecdsa.h
@@ -85,7 +85,7 @@ class BOTAN_DLL PKCS11_ECDSA_PrivateKey final : public PKCS11_EC_PrivateKey
* @param props the attributes of the private key
* @note no persistent public key object will be created
*/
- PKCS11_ECDSA_PrivateKey(Session& session, const std::vector<byte>& ec_params,
+ PKCS11_ECDSA_PrivateKey(Session& session, const std::vector<uint8_t>& ec_params,
const EC_PrivateKeyGenerationProperties& props)
: PKCS11_EC_PrivateKey(session, ec_params, props)
{}
@@ -98,7 +98,7 @@ class BOTAN_DLL PKCS11_ECDSA_PrivateKey final : public PKCS11_EC_PrivateKey
/// @return the exported ECDSA private key
ECDSA_PrivateKey export_key() const;
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
bool check_key(RandomNumberGenerator&, bool) const override;
diff --git a/src/lib/prov/pkcs11/p11_mechanism.h b/src/lib/prov/pkcs11/p11_mechanism.h
index dde5e5b07..be48c9a14 100644
--- a/src/lib/prov/pkcs11/p11_mechanism.h
+++ b/src/lib/prov/pkcs11/p11_mechanism.h
@@ -63,9 +63,9 @@ class MechanismWrapper final
* @param salt the salt
* @param salt_len size of the salt in bytes
*/
- inline void set_ecdh_salt(const byte salt[], size_t salt_len)
+ inline void set_ecdh_salt(const uint8_t salt[], size_t salt_len)
{
- m_parameters->ecdh_params.pSharedData = const_cast<byte*>(salt);
+ m_parameters->ecdh_params.pSharedData = const_cast<uint8_t*>(salt);
m_parameters->ecdh_params.ulSharedDataLen = salt_len;
}
@@ -74,9 +74,9 @@ class MechanismWrapper final
* @param other_key key of the other party
* @param other_key_len size of the key of the other party in bytes
*/
- inline void set_ecdh_other_key(const byte other_key[], size_t other_key_len)
+ inline void set_ecdh_other_key(const uint8_t other_key[], size_t other_key_len)
{
- m_parameters->ecdh_params.pPublicData = const_cast<byte*>(other_key);
+ m_parameters->ecdh_params.pPublicData = const_cast<uint8_t*>(other_key);
m_parameters->ecdh_params.ulPublicDataLen = other_key_len;
}
diff --git a/src/lib/prov/pkcs11/p11_object.cpp b/src/lib/prov/pkcs11/p11_object.cpp
index ef7477284..872fdf8b7 100644
--- a/src/lib/prov/pkcs11/p11_object.cpp
+++ b/src/lib/prov/pkcs11/p11_object.cpp
@@ -22,28 +22,28 @@ AttributeContainer::AttributeContainer(ObjectClass object_class)
void AttributeContainer::add_class(ObjectClass object_class)
{
m_numerics.push_back(static_cast< uint64_t >(object_class));
- add_attribute(AttributeType::Class, reinterpret_cast< byte* >(&m_numerics.back()), sizeof(ObjectClass));
+ add_attribute(AttributeType::Class, reinterpret_cast< uint8_t* >(&m_numerics.back()), sizeof(ObjectClass));
}
void AttributeContainer::add_string(AttributeType attribute, const std::string& value)
{
m_strings.push_back(value);
- add_attribute(attribute, reinterpret_cast< const byte* >(m_strings.back().data()), value.size());
+ add_attribute(attribute, reinterpret_cast< const uint8_t* >(m_strings.back().data()), value.size());
}
-void AttributeContainer::add_binary(AttributeType attribute, const byte* value, size_t length)
+void AttributeContainer::add_binary(AttributeType attribute, const uint8_t* value, size_t length)
{
- m_vectors.push_back(secure_vector<byte>(value, value + length));
- add_attribute(attribute, reinterpret_cast< const byte* >(m_vectors.back().data()), length);
+ m_vectors.push_back(secure_vector<uint8_t>(value, value + length));
+ add_attribute(attribute, reinterpret_cast< const uint8_t* >(m_vectors.back().data()), length);
}
void AttributeContainer::add_bool(AttributeType attribute, bool value)
{
m_numerics.push_back(value ? True : False);
- add_attribute(attribute, reinterpret_cast< byte* >(&m_numerics.back()), sizeof(Bbool));
+ add_attribute(attribute, reinterpret_cast< uint8_t* >(&m_numerics.back()), sizeof(Bbool));
}
-void AttributeContainer::add_attribute(AttributeType attribute, const byte* value, uint32_t size)
+void AttributeContainer::add_attribute(AttributeType attribute, const uint8_t* value, uint32_t size)
{
bool exists = false;
// check if the attribute has been added already
@@ -63,12 +63,12 @@ void AttributeContainer::add_attribute(AttributeType attribute, const byte* valu
}), m_numerics.end());
m_vectors.erase(std::remove_if(m_vectors.begin(),
- m_vectors.end(), [ &existing_attribute ](const secure_vector<byte>& data)
+ m_vectors.end(), [ &existing_attribute ](const secure_vector<uint8_t>& data)
{
return data.data() == existing_attribute.pValue;
}), m_vectors.end());
- existing_attribute.pValue = const_cast< byte* >(value);
+ existing_attribute.pValue = const_cast< uint8_t* >(value);
existing_attribute.ulValueLen = size;
exists = true;
break;
@@ -77,7 +77,7 @@ void AttributeContainer::add_attribute(AttributeType attribute, const byte* valu
if(!exists)
{
- m_attributes.push_back(Attribute{ static_cast< CK_ATTRIBUTE_TYPE >(attribute), const_cast< byte* >(value), size });
+ m_attributes.push_back(Attribute{ static_cast< CK_ATTRIBUTE_TYPE >(attribute), const_cast< uint8_t* >(value), size });
}
}
@@ -188,16 +188,16 @@ Object::Object(Session& session, const ObjectProperties& obj_props)
m_session.get().module()->C_CreateObject(m_session.get().handle(), obj_props.data(), obj_props.count(), &m_handle);
}
-secure_vector<byte> Object::get_attribute_value(AttributeType attribute) const
+secure_vector<uint8_t> Object::get_attribute_value(AttributeType attribute) const
{
- std::map<AttributeType, secure_vector<byte>> attribute_map = { { attribute, secure_vector<byte>() } };
+ std::map<AttributeType, secure_vector<uint8_t>> attribute_map = { { attribute, secure_vector<uint8_t>() } };
module()->C_GetAttributeValue(m_session.get().handle(), m_handle, attribute_map);
return attribute_map.at(attribute);
}
-void Object::set_attribute_value(AttributeType attribute, const secure_vector<byte>& value) const
+void Object::set_attribute_value(AttributeType attribute, const secure_vector<uint8_t>& value) const
{
- std::map<AttributeType, secure_vector<byte>> attribute_map = { { attribute, value } };
+ std::map<AttributeType, secure_vector<uint8_t>> attribute_map = { { attribute, value } };
module()->C_SetAttributeValue(m_session.get().handle(), m_handle, attribute_map);
}
diff --git a/src/lib/prov/pkcs11/p11_object.h b/src/lib/prov/pkcs11/p11_object.h
index cae1969a2..e7ab05f0d 100644
--- a/src/lib/prov/pkcs11/p11_object.h
+++ b/src/lib/prov/pkcs11/p11_object.h
@@ -83,7 +83,7 @@ class BOTAN_DLL AttributeContainer
* @param value binary attribute value to add
* @param length size of the binary attribute value in bytes
*/
- void add_binary(AttributeType attribute, const byte* value, size_t length);
+ void add_binary(AttributeType attribute, const uint8_t* value, size_t length);
/**
* Add a binary attribute (e.g. CKA_ID / AttributeType::Id).
@@ -91,7 +91,7 @@ class BOTAN_DLL AttributeContainer
* @param binary binary attribute value to add
*/
template<typename TAlloc>
- void add_binary(AttributeType attribute, const std::vector<byte, TAlloc>& binary)
+ void add_binary(AttributeType attribute, const std::vector<uint8_t, TAlloc>& binary)
{
add_binary(attribute, binary.data(), binary.size());
}
@@ -113,18 +113,18 @@ class BOTAN_DLL AttributeContainer
{
static_assert(std::is_integral<T>::value, "Numeric value required.");
m_numerics.push_back(static_cast< uint64_t >(value));
- add_attribute(attribute, reinterpret_cast< byte* >(&m_numerics.back()), sizeof(T));
+ add_attribute(attribute, reinterpret_cast< uint8_t* >(&m_numerics.back()), sizeof(T));
}
protected:
/// Add an attribute with the given value and size to the attribute collection `m_attributes`
- void add_attribute(AttributeType attribute, const byte* value, uint32_t size);
+ void add_attribute(AttributeType attribute, const uint8_t* value, uint32_t size);
private:
std::vector<Attribute> m_attributes;
std::list<uint64_t> m_numerics;
std::list<std::string> m_strings;
- std::list<secure_vector<byte>> m_vectors;
+ std::list<secure_vector<uint8_t>> m_vectors;
};
/// Manages calls to C_FindObjects* functions (C_FindObjectsInit -> C_FindObjects -> C_FindObjectsFinal)
@@ -249,13 +249,13 @@ class BOTAN_DLL DataObjectProperties : public StorageObjectProperties
}
/// @param object_id DER-encoding of the object identifier indicating the data object type
- inline void set_object_id(const std::vector<byte>& object_id)
+ inline void set_object_id(const std::vector<uint8_t>& object_id)
{
add_binary(AttributeType::ObjectId, object_id);
}
/// @param value value of the object
- inline void set_value(const secure_vector<byte>& value)
+ inline void set_value(const secure_vector<uint8_t>& value)
{
add_binary(AttributeType::Value, value);
}
@@ -284,7 +284,7 @@ class BOTAN_DLL CertificateProperties : public StorageObjectProperties
* @param checksum the value of this attribute is derived from the certificate by taking the
* first three bytes of the SHA - 1 hash of the certificate object's `CKA_VALUE` attribute
*/
- inline void set_check_value(const std::vector<byte>& checksum)
+ inline void set_check_value(const std::vector<uint8_t>& checksum)
{
add_binary(AttributeType::CheckValue, checksum);
}
@@ -292,17 +292,17 @@ class BOTAN_DLL CertificateProperties : public StorageObjectProperties
/// @param date start date for the certificate
inline void set_start_date(Date date)
{
- add_binary(AttributeType::StartDate, reinterpret_cast<byte*>(&date), sizeof(Date));
+ add_binary(AttributeType::StartDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
}
/// @param date end date for the certificate
inline void set_end_date(Date date)
{
- add_binary(AttributeType::EndDate, reinterpret_cast<byte*>(&date), sizeof(Date));
+ add_binary(AttributeType::EndDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
}
/// @param pubkey_info DER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate
- inline void set_public_key_info(const std::vector<byte>& pubkey_info)
+ inline void set_public_key_info(const std::vector<uint8_t>& pubkey_info)
{
add_binary(AttributeType::PublicKeyInfo, pubkey_info);
}
@@ -328,7 +328,7 @@ class BOTAN_DLL KeyProperties : public StorageObjectProperties
KeyProperties(ObjectClass object_class, KeyType key_type);
/// @param id key identifier for key
- inline void set_id(const std::vector<byte>& id)
+ inline void set_id(const std::vector<uint8_t>& id)
{
add_binary(AttributeType::Id, id);
}
@@ -336,13 +336,13 @@ class BOTAN_DLL KeyProperties : public StorageObjectProperties
/// @param date start date for the key
inline void set_start_date(Date date)
{
- add_binary(AttributeType::StartDate, reinterpret_cast<byte*>(&date), sizeof(Date));
+ add_binary(AttributeType::StartDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
}
/// @param date end date for the key
inline void set_end_date(Date date)
{
- add_binary(AttributeType::EndDate, reinterpret_cast<byte*>(&date), sizeof(Date));
+ add_binary(AttributeType::EndDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
}
/// @param value true if key supports key derivation (i.e., if other keys can be derived from this one)
@@ -378,7 +378,7 @@ class BOTAN_DLL PublicKeyProperties : public KeyProperties
PublicKeyProperties(KeyType key_type);
/// @param subject DER-encoding of the key subject name
- inline void set_subject(const std::vector<byte>& subject)
+ inline void set_subject(const std::vector<uint8_t>& subject)
{
add_binary(AttributeType::Subject, subject);
}
@@ -428,7 +428,7 @@ class BOTAN_DLL PublicKeyProperties : public KeyProperties
}
/// @param pubkey_info DER-encoding of the SubjectPublicKeyInfo for this public key
- inline void set_public_key_info(const std::vector<byte>& pubkey_info)
+ inline void set_public_key_info(const std::vector<uint8_t>& pubkey_info)
{
add_binary(AttributeType::PublicKeyInfo, pubkey_info);
}
@@ -442,7 +442,7 @@ class BOTAN_DLL PrivateKeyProperties : public KeyProperties
PrivateKeyProperties(KeyType key_type);
/// @param subject DER-encoding of the key subject name
- inline void set_subject(const std::vector<byte>& subject)
+ inline void set_subject(const std::vector<uint8_t>& subject)
{
add_binary(AttributeType::Subject, subject);
}
@@ -507,7 +507,7 @@ class BOTAN_DLL PrivateKeyProperties : public KeyProperties
}
/// @param pubkey_info DER-encoding of the SubjectPublicKeyInfo for this public key
- inline void set_public_key_info(const std::vector<byte>& pubkey_info)
+ inline void set_public_key_info(const std::vector<uint8_t>& pubkey_info)
{
add_binary(AttributeType::PublicKeyInfo, pubkey_info);
}
@@ -590,7 +590,7 @@ class BOTAN_DLL SecretKeyProperties : public KeyProperties
}
/// @param checksum the key check value of this key
- inline void set_check_value(const std::vector<byte>& checksum)
+ inline void set_check_value(const std::vector<uint8_t>& checksum)
{
add_binary(AttributeType::CheckValue, checksum);
}
@@ -668,21 +668,21 @@ class BOTAN_DLL Object
/// Searches for all objects of the given type using the id (`CKA_ID`)
template<typename T>
- static std::vector<T> search(Session& session, const std::vector<byte>& id);
+ static std::vector<T> search(Session& session, const std::vector<uint8_t>& id);
/// Searches for all objects of the given type using the label (`CKA_LABEL`) and id (`CKA_ID`)
template<typename T>
- static std::vector<T> search(Session& session, const std::string& label, const std::vector<byte>& id);
+ static std::vector<T> search(Session& session, const std::string& label, const std::vector<uint8_t>& id);
/// Searches for all objects of the given type
template<typename T>
static std::vector<T> search(Session& session);
/// @returns the value of the given attribute (using `C_GetAttributeValue`)
- secure_vector<byte> get_attribute_value(AttributeType attribute) const;
+ secure_vector<uint8_t> get_attribute_value(AttributeType attribute) const;
/// Sets the given value for the attribute (using `C_SetAttributeValue`)
- void set_attribute_value(AttributeType attribute, const secure_vector<byte>& value) const;
+ void set_attribute_value(AttributeType attribute, const secure_vector<uint8_t>& value) const;
/// Destroys the object
void destroy() const;
@@ -742,7 +742,7 @@ std::vector<T> Object::search(Session& session, const std::string& label)
}
template<typename T>
-std::vector<T> Object::search(Session& session, const std::vector<byte>& id)
+std::vector<T> Object::search(Session& session, const std::vector<uint8_t>& id)
{
AttributeContainer search_template(T::Class);
search_template.add_binary(AttributeType::Id, id);
@@ -750,7 +750,7 @@ std::vector<T> Object::search(Session& session, const std::vector<byte>& id)
}
template<typename T>
-std::vector<T> Object::search(Session& session, const std::string& label, const std::vector<byte>& id)
+std::vector<T> Object::search(Session& session, const std::string& label, const std::vector<uint8_t>& id)
{
AttributeContainer search_template(T::Class);
search_template.add_string(AttributeType::Label, label);
diff --git a/src/lib/prov/pkcs11/p11_randomgenerator.cpp b/src/lib/prov/pkcs11/p11_randomgenerator.cpp
index eaf9933c6..957a33cae 100644
--- a/src/lib/prov/pkcs11/p11_randomgenerator.cpp
+++ b/src/lib/prov/pkcs11/p11_randomgenerator.cpp
@@ -16,14 +16,14 @@ PKCS11_RNG::PKCS11_RNG(Session& session)
: m_session(session)
{}
-void PKCS11_RNG::randomize(Botan::byte output[], std::size_t length)
+void PKCS11_RNG::randomize(uint8_t output[], std::size_t length)
{
module()->C_GenerateRandom(m_session.get().handle(), output, length);
}
-void PKCS11_RNG::add_entropy(const Botan::byte in[], std::size_t length)
+void PKCS11_RNG::add_entropy(const uint8_t in[], std::size_t length)
{
- module()->C_SeedRandom(m_session.get().handle(), const_cast<Botan::byte*>(in), length);
+ module()->C_SeedRandom(m_session.get().handle(), const_cast<uint8_t*>(in), length);
}
}
diff --git a/src/lib/prov/pkcs11/p11_randomgenerator.h b/src/lib/prov/pkcs11/p11_randomgenerator.h
index a291c89f3..6a29f8040 100644
--- a/src/lib/prov/pkcs11/p11_randomgenerator.h
+++ b/src/lib/prov/pkcs11/p11_randomgenerator.h
@@ -55,10 +55,10 @@ class BOTAN_DLL PKCS11_RNG final : public Hardware_RNG
}
/// Calls `C_GenerateRandom` to generate random data
- void randomize(Botan::byte output[], std::size_t length) override;
+ void randomize(uint8_t output[], std::size_t length) override;
/// Calls `C_SeedRandom` to add entropy to the random generation function of the token/middleware
- void add_entropy(const Botan::byte in[], std::size_t length) override;
+ void add_entropy(const uint8_t in[], std::size_t length) override;
private:
const std::reference_wrapper<Session> m_session;
diff --git a/src/lib/prov/pkcs11/p11_rsa.cpp b/src/lib/prov/pkcs11/p11_rsa.cpp
index 1edbde83b..3bb7b7534 100644
--- a/src/lib/prov/pkcs11/p11_rsa.cpp
+++ b/src/lib/prov/pkcs11/p11_rsa.cpp
@@ -101,7 +101,7 @@ RSA_PrivateKey PKCS11_RSA_PrivateKey::export_key() const
, BigInt::decode(n));
}
-secure_vector<byte> PKCS11_RSA_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> PKCS11_RSA_PrivateKey::private_key_bits() const
{
return export_key().private_key_bits();
}
@@ -127,12 +127,12 @@ class PKCS11_RSA_Decryption_Operation final : public PK_Ops::Decryption
m_bits = m_key.get_n().bits() - 1;
}
- secure_vector<byte> decrypt(byte& valid_mask, const byte ciphertext[], size_t ciphertext_len) override
+ secure_vector<uint8_t> decrypt(uint8_t& valid_mask, const uint8_t ciphertext[], size_t ciphertext_len) override
{
valid_mask = 0;
m_key.module()->C_DecryptInit(m_key.session().handle(), m_mechanism.data(), m_key.handle());
- std::vector<byte> encrypted_data(ciphertext, ciphertext + ciphertext_len);
+ std::vector<uint8_t> encrypted_data(ciphertext, ciphertext + ciphertext_len);
// blind for RSA/RAW decryption
if(! m_mechanism.padding_size())
@@ -140,7 +140,7 @@ class PKCS11_RSA_Decryption_Operation final : public PK_Ops::Decryption
encrypted_data = BigInt::encode(m_blinder.blind(BigInt::decode(encrypted_data)));
}
- secure_vector<byte> decrypted_data;
+ secure_vector<uint8_t> decrypted_data;
m_key.module()->C_Decrypt(m_key.session().handle(), encrypted_data, decrypted_data);
// Unblind for RSA/RAW decryption
@@ -178,12 +178,12 @@ class PKCS11_RSA_Encryption_Operation : public PK_Ops::Encryption
return m_bits;
}
- secure_vector<byte> encrypt(const byte msg[], size_t msg_len, RandomNumberGenerator&) override
+ secure_vector<uint8_t> encrypt(const uint8_t msg[], size_t msg_len, RandomNumberGenerator&) override
{
m_key.module()->C_EncryptInit(m_key.session().handle(), m_mechanism.data(), m_key.handle());
- secure_vector<byte> encrytped_data;
- m_key.module()->C_Encrypt(m_key.session().handle(), secure_vector<byte>(msg, msg + msg_len), encrytped_data);
+ secure_vector<uint8_t> encrytped_data;
+ m_key.module()->C_Encrypt(m_key.session().handle(), secure_vector<uint8_t>(msg, msg + msg_len), encrytped_data);
return encrytped_data;
}
@@ -202,14 +202,14 @@ class PKCS11_RSA_Signature_Operation : public PK_Ops::Signature
: m_key(key), m_mechanism(MechanismWrapper::create_rsa_sign_mechanism(padding))
{}
- void update(const byte msg[], size_t msg_len) override
+ void update(const uint8_t msg[], size_t msg_len) override
{
if(!m_initialized)
{
// first call to update: initialize and cache message because we can not determine yet whether a single- or multiple-part operation will be performed
m_key.module()->C_SignInit(m_key.session().handle(), m_mechanism.data(), m_key.handle());
m_initialized = true;
- m_first_message = secure_vector<byte>(msg, msg + msg_len);
+ m_first_message = secure_vector<uint8_t>(msg, msg + msg_len);
return;
}
@@ -223,9 +223,9 @@ class PKCS11_RSA_Signature_Operation : public PK_Ops::Signature
m_key.module()->C_SignUpdate(m_key.session().handle(), const_cast< Byte* >(msg), msg_len);
}
- secure_vector<byte> sign(RandomNumberGenerator&) override
+ secure_vector<uint8_t> sign(RandomNumberGenerator&) override
{
- secure_vector<byte> signature;
+ secure_vector<uint8_t> signature;
if(!m_first_message.empty())
{
// single call to update: perform single-part operation
@@ -244,7 +244,7 @@ class PKCS11_RSA_Signature_Operation : public PK_Ops::Signature
private:
const PKCS11_RSA_PrivateKey& m_key;
bool m_initialized = false;
- secure_vector<byte> m_first_message;
+ secure_vector<uint8_t> m_first_message;
MechanismWrapper m_mechanism;
};
@@ -257,14 +257,14 @@ class PKCS11_RSA_Verification_Operation : public PK_Ops::Verification
: m_key(key), m_mechanism(MechanismWrapper::create_rsa_sign_mechanism(padding))
{}
- void update(const byte msg[], size_t msg_len) override
+ void update(const uint8_t msg[], size_t msg_len) override
{
if(!m_initialized)
{
// first call to update: initialize and cache message because we can not determine yet whether a single- or multiple-part operation will be performed
m_key.module()->C_VerifyInit(m_key.session().handle(), m_mechanism.data(), m_key.handle());
m_initialized = true;
- m_first_message = secure_vector<byte>(msg, msg + msg_len);
+ m_first_message = secure_vector<uint8_t>(msg, msg + msg_len);
return;
}
@@ -278,7 +278,7 @@ class PKCS11_RSA_Verification_Operation : public PK_Ops::Verification
m_key.module()->C_VerifyUpdate(m_key.session().handle(), const_cast< Byte* >(msg), msg_len);
}
- bool is_valid_signature(const byte sig[], size_t sig_len) override
+ bool is_valid_signature(const uint8_t sig[], size_t sig_len) override
{
ReturnValue return_value = ReturnValue::SignatureInvalid;
if(!m_first_message.empty())
@@ -304,7 +304,7 @@ class PKCS11_RSA_Verification_Operation : public PK_Ops::Verification
private:
const PKCS11_RSA_PublicKey& m_key;
bool m_initialized = false;
- secure_vector<byte> m_first_message;
+ secure_vector<uint8_t> m_first_message;
MechanismWrapper m_mechanism;
};
diff --git a/src/lib/prov/pkcs11/p11_rsa.h b/src/lib/prov/pkcs11/p11_rsa.h
index 13b9d9dc1..1a6fd4890 100644
--- a/src/lib/prov/pkcs11/p11_rsa.h
+++ b/src/lib/prov/pkcs11/p11_rsa.h
@@ -200,7 +200,7 @@ class BOTAN_DLL PKCS11_RSA_PrivateKey final : public Private_Key,
/// @return the exported RSA private key
RSA_PrivateKey export_key() const;
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
std::unique_ptr<PK_Ops::Decryption>
create_decryption_op(RandomNumberGenerator& rng,
diff --git a/src/lib/prov/pkcs11/p11_x509.cpp b/src/lib/prov/pkcs11/p11_x509.cpp
index 76b120368..5c6accdf0 100644
--- a/src/lib/prov/pkcs11/p11_x509.cpp
+++ b/src/lib/prov/pkcs11/p11_x509.cpp
@@ -13,7 +13,7 @@
namespace Botan {
namespace PKCS11 {
-X509_CertificateProperties::X509_CertificateProperties(const std::vector<byte>& subject, const std::vector<byte>& value)
+X509_CertificateProperties::X509_CertificateProperties(const std::vector<uint8_t>& subject, const std::vector<uint8_t>& value)
: CertificateProperties(CertificateType::X509), m_subject(subject), m_value(value)
{
add_binary(AttributeType::Subject, m_subject);
diff --git a/src/lib/prov/pkcs11/p11_x509.h b/src/lib/prov/pkcs11/p11_x509.h
index f0e025ff4..db83286cc 100644
--- a/src/lib/prov/pkcs11/p11_x509.h
+++ b/src/lib/prov/pkcs11/p11_x509.h
@@ -31,34 +31,34 @@ class BOTAN_DLL X509_CertificateProperties final : public CertificateProperties
* @param subject DER-encoding of the certificate subject name
* @param value BER-encoding of the certificate
*/
- X509_CertificateProperties(const std::vector<byte>& subject, const std::vector<byte>& value);
+ X509_CertificateProperties(const std::vector<uint8_t>& subject, const std::vector<uint8_t>& value);
/// @param id key identifier for public/private key pair
- inline void set_id(const std::vector<byte>& id)
+ inline void set_id(const std::vector<uint8_t>& id)
{
add_binary(AttributeType::Id, id);
}
/// @param issuer DER-encoding of the certificate issuer name
- inline void set_issuer(const std::vector<byte>& issuer)
+ inline void set_issuer(const std::vector<uint8_t>& issuer)
{
add_binary(AttributeType::Issuer, issuer);
}
/// @param serial DER-encoding of the certificate serial number
- inline void set_serial(const std::vector<byte>& serial)
+ inline void set_serial(const std::vector<uint8_t>& serial)
{
add_binary(AttributeType::SerialNumber, serial);
}
/// @param hash hash value of the subject public key
- inline void set_subject_pubkey_hash(const std::vector<byte>& hash)
+ inline void set_subject_pubkey_hash(const std::vector<uint8_t>& hash)
{
add_binary(AttributeType::HashOfSubjectPublicKey, hash);
}
/// @param hash hash value of the issuer public key
- inline void set_issuer_pubkey_hash(const std::vector<byte>& hash)
+ inline void set_issuer_pubkey_hash(const std::vector<uint8_t>& hash)
{
add_binary(AttributeType::HashOfIssuerPublicKey, hash);
}
@@ -70,20 +70,20 @@ class BOTAN_DLL X509_CertificateProperties final : public CertificateProperties
}
/// @return the subject
- inline const std::vector<byte>& subject() const
+ inline const std::vector<uint8_t>& subject() const
{
return m_subject;
}
/// @return the BER-encoding of the certificate
- inline const std::vector<byte>& value() const
+ inline const std::vector<uint8_t>& value() const
{
return m_value;
}
private:
- const std::vector<byte> m_subject;
- const std::vector<byte> m_value;
+ const std::vector<uint8_t> m_subject;
+ const std::vector<uint8_t> m_value;
};
/// Represents a PKCS#11 X509 certificate
diff --git a/src/lib/prov/tpm/tpm.cpp b/src/lib/prov/tpm/tpm.cpp
index e1f214952..8e3fce968 100644
--- a/src/lib/prov/tpm/tpm.cpp
+++ b/src/lib/prov/tpm/tpm.cpp
@@ -59,7 +59,7 @@ TSS_FLAG bit_flag(size_t bits)
#if 0
bool is_srk_uuid(const UUID& uuid)
{
- static const byte srk[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
+ static const uint8_t srk[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
const std::vector<uint8_t>& b = uuid.binary_value();
return (b.size() == 16 && same_mem(b.data(), srk, 16));
}
@@ -349,7 +349,7 @@ AlgorithmIdentifier TPM_PrivateKey::algorithm_identifier() const
AlgorithmIdentifier::USE_NULL_PARAM);
}
-std::vector<byte> TPM_PrivateKey::public_key_bits() const
+std::vector<uint8_t> TPM_PrivateKey::public_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -359,7 +359,7 @@ std::vector<byte> TPM_PrivateKey::public_key_bits() const
.get_contents_unlocked();
}
-secure_vector<byte> TPM_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> TPM_PrivateKey::private_key_bits() const
{
throw TPM_Error("Private key export not supported for TPM keys");
}
@@ -394,12 +394,12 @@ class TPM_Signing_Operation : public PK_Ops::Signature
{
}
- void update(const byte msg[], size_t msg_len) override
+ void update(const uint8_t msg[], size_t msg_len) override
{
m_hash->update(msg, msg_len);
}
- secure_vector<byte> sign(RandomNumberGenerator&) override
+ secure_vector<uint8_t> sign(RandomNumberGenerator&) override
{
/*
* v1.2 TPMs will only sign with PKCS #1 v1.5 padding. SHA-1 is built
@@ -408,7 +408,7 @@ class TPM_Signing_Operation : public PK_Ops::Signature
* 01FFFF... prefix. Even when using SHA-1 we compute the hash locally
* since it is going to be much faster than pushing data over the LPC bus.
*/
- secure_vector<byte> msg_hash = m_hash->final();
+ secure_vector<uint8_t> msg_hash = m_hash->final();
std::vector<uint8_t> id_and_msg;
id_and_msg.reserve(m_hash_id.size() + msg_hash.size());
diff --git a/src/lib/prov/tpm/tpm.h b/src/lib/prov/tpm/tpm.h
index de0fa364f..178206b8f 100644
--- a/src/lib/prov/tpm/tpm.h
+++ b/src/lib/prov/tpm/tpm.h
@@ -77,12 +77,12 @@ class BOTAN_DLL TPM_RNG : public Hardware_RNG
public:
TPM_RNG(TPM_Context& ctx) : m_ctx(ctx) {}
- void add_entropy(const byte in[], size_t in_len) override
+ void add_entropy(const uint8_t in[], size_t in_len) override
{
m_ctx.stir_random(in, in_len);
}
- void randomize(byte out[], size_t out_len) override
+ void randomize(uint8_t out[], size_t out_len) override
{
m_ctx.gen_random(out, out_len);
}
@@ -154,9 +154,9 @@ class BOTAN_DLL TPM_PrivateKey : public Private_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
bool check_key(RandomNumberGenerator& rng, bool) const override;
diff --git a/src/lib/pubkey/cecpq1/cecpq1.cpp b/src/lib/pubkey/cecpq1/cecpq1.cpp
index d5b6ae702..83c0a383c 100644
--- a/src/lib/pubkey/cecpq1/cecpq1.cpp
+++ b/src/lib/pubkey/cecpq1/cecpq1.cpp
@@ -27,7 +27,7 @@ void CECPQ1_accept(uint8_t shared_key[CECPQ1_SHARED_KEY_BYTES],
const uint8_t received[CECPQ1_OFFER_BYTES],
RandomNumberGenerator& rng)
{
- secure_vector<byte> x25519_key = rng.random_vec(32);
+ secure_vector<uint8_t> x25519_key = rng.random_vec(32);
curve25519_basepoint(send, x25519_key.data());
diff --git a/src/lib/pubkey/curve25519/curve25519.cpp b/src/lib/pubkey/curve25519/curve25519.cpp
index 7c3dea0f3..4908bf46f 100644
--- a/src/lib/pubkey/curve25519/curve25519.cpp
+++ b/src/lib/pubkey/curve25519/curve25519.cpp
@@ -14,7 +14,7 @@ namespace Botan {
void curve25519_basepoint(uint8_t mypublic[32], const uint8_t secret[32])
{
- const byte basepoint[32] = { 9 };
+ const uint8_t basepoint[32] = { 9 };
curve25519_donna(mypublic, secret, basepoint);
}
@@ -26,10 +26,10 @@ void size_check(size_t size, const char* thing)
throw Decoding_Error("Invalid size " + std::to_string(size) + " for Curve25519 " + thing);
}
-secure_vector<byte> curve25519(const secure_vector<byte>& secret,
- const byte pubval[32])
+secure_vector<uint8_t> curve25519(const secure_vector<uint8_t>& secret,
+ const uint8_t pubval[32])
{
- secure_vector<byte> out(32);
+ secure_vector<uint8_t> out(32);
curve25519_donna(out.data(), secret.data(), pubval);
return out;
}
@@ -47,7 +47,7 @@ bool Curve25519_PublicKey::check_key(RandomNumberGenerator&, bool) const
}
Curve25519_PublicKey::Curve25519_PublicKey(const AlgorithmIdentifier&,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
@@ -58,7 +58,7 @@ Curve25519_PublicKey::Curve25519_PublicKey(const AlgorithmIdentifier&,
size_check(m_public.size(), "public key");
}
-std::vector<byte> Curve25519_PublicKey::public_key_bits() const
+std::vector<uint8_t> Curve25519_PublicKey::public_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -75,7 +75,7 @@ Curve25519_PrivateKey::Curve25519_PrivateKey(RandomNumberGenerator& rng)
}
Curve25519_PrivateKey::Curve25519_PrivateKey(const AlgorithmIdentifier&,
- const secure_vector<byte>& key_bits)
+ const secure_vector<uint8_t>& key_bits)
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
@@ -88,7 +88,7 @@ Curve25519_PrivateKey::Curve25519_PrivateKey(const AlgorithmIdentifier&,
size_check(m_private.size(), "private key");
}
-secure_vector<byte> Curve25519_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> Curve25519_PrivateKey::private_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -105,7 +105,7 @@ bool Curve25519_PrivateKey::check_key(RandomNumberGenerator&, bool) const
return public_point == m_public;
}
-secure_vector<byte> Curve25519_PrivateKey::agree(const byte w[], size_t w_len) const
+secure_vector<uint8_t> Curve25519_PrivateKey::agree(const uint8_t w[], size_t w_len) const
{
size_check(w_len, "public value");
return curve25519(m_private, w);
@@ -124,7 +124,7 @@ class Curve25519_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
PK_Ops::Key_Agreement_with_KDF(kdf),
m_key(key) {}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override
{
return m_key.agree(w, w_len);
}
diff --git a/src/lib/pubkey/curve25519/curve25519.h b/src/lib/pubkey/curve25519/curve25519.h
index 68f3cb387..43e998df6 100644
--- a/src/lib/pubkey/curve25519/curve25519.h
+++ b/src/lib/pubkey/curve25519/curve25519.h
@@ -25,9 +25,9 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
- std::vector<byte> public_value() const { return m_public; }
+ std::vector<uint8_t> public_value() const { return m_public; }
/**
* Create a Curve25519 Public Key.
@@ -35,24 +35,24 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key
* @param key_bits DER encoded public key bits
*/
Curve25519_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Create a Curve25519 Public Key.
* @param pub 32-byte raw public key
*/
- explicit Curve25519_PublicKey(const std::vector<byte>& pub) : m_public(pub) {}
+ explicit Curve25519_PublicKey(const std::vector<uint8_t>& pub) : m_public(pub) {}
/**
* Create a Curve25519 Public Key.
* @param pub 32-byte raw public key
*/
- explicit Curve25519_PublicKey(const secure_vector<byte>& pub) :
+ explicit Curve25519_PublicKey(const secure_vector<uint8_t>& pub) :
m_public(pub.begin(), pub.end()) {}
protected:
Curve25519_PublicKey() {}
- std::vector<byte> m_public;
+ std::vector<uint8_t> m_public;
};
class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
@@ -66,7 +66,7 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
* @param key_bits PKCS #8 structure
*/
Curve25519_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Generate a private key.
@@ -78,15 +78,15 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
* Construct a private key from the specified parameters.
* @param secret_key DER encoded private key bits
*/
- explicit Curve25519_PrivateKey(const secure_vector<byte>& secret_key);
+ explicit Curve25519_PrivateKey(const secure_vector<uint8_t>& secret_key);
- std::vector<byte> public_value() const override { return Curve25519_PublicKey::public_value(); }
+ std::vector<uint8_t> public_value() const override { return Curve25519_PublicKey::public_value(); }
- secure_vector<byte> agree(const byte w[], size_t w_len) const;
+ secure_vector<uint8_t> agree(const uint8_t w[], size_t w_len) const;
- const secure_vector<byte>& get_x() const { return m_private; }
+ const secure_vector<uint8_t>& get_x() const { return m_private; }
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
bool check_key(RandomNumberGenerator& rng, bool strong) const override;
@@ -96,7 +96,7 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
const std::string& provider) const override;
private:
- secure_vector<byte> m_private;
+ secure_vector<uint8_t> m_private;
};
/*
diff --git a/src/lib/pubkey/curve25519/donna.cpp b/src/lib/pubkey/curve25519/donna.cpp
index 22400015f..89f3fbc4a 100644
--- a/src/lib/pubkey/curve25519/donna.cpp
+++ b/src/lib/pubkey/curve25519/donna.cpp
@@ -35,8 +35,8 @@
namespace Botan {
-typedef byte u8;
-typedef u64bit limb;
+typedef uint8_t u8;
+typedef uint64_t limb;
typedef limb felem[5];
typedef struct
@@ -214,7 +214,7 @@ static inline void fsquare_times(felem output, const felem in, limb count) {
/* Load a little-endian 64-bit number */
static limb
load_limb(const u8 *in) {
- return load_le<u64bit>(in, 0);
+ return load_le<uint64_t>(in, 0);
}
static void
diff --git a/src/lib/pubkey/dh/dh.cpp b/src/lib/pubkey/dh/dh.cpp
index 8c7fdd289..25c5f5cf4 100644
--- a/src/lib/pubkey/dh/dh.cpp
+++ b/src/lib/pubkey/dh/dh.cpp
@@ -25,7 +25,7 @@ DH_PublicKey::DH_PublicKey(const DL_Group& grp, const BigInt& y1)
/*
* Return the public value for key agreement
*/
-std::vector<byte> DH_PublicKey::public_value() const
+std::vector<uint8_t> DH_PublicKey::public_value() const
{
return unlock(BigInt::encode_1363(m_y, group_p().bytes()));
}
@@ -59,7 +59,7 @@ DH_PrivateKey::DH_PrivateKey(RandomNumberGenerator& rng,
* Load a DH private key
*/
DH_PrivateKey::DH_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
{
if(m_y == 0)
@@ -69,7 +69,7 @@ DH_PrivateKey::DH_PrivateKey(const AlgorithmIdentifier& alg_id,
/*
* Return the public value for key agreement
*/
-std::vector<byte> DH_PrivateKey::public_value() const
+std::vector<uint8_t> DH_PrivateKey::public_value() const
{
return DH_PublicKey::public_value();
}
@@ -93,7 +93,7 @@ class DH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
[this](const BigInt& k) { return m_powermod_x_p(inverse_mod(k, m_p)); })
{}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override;
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override;
private:
const BigInt& m_p;
@@ -101,7 +101,7 @@ class DH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
Blinder m_blinder;
};
-secure_vector<byte> DH_KA_Operation::raw_agree(const byte w[], size_t w_len)
+secure_vector<uint8_t> DH_KA_Operation::raw_agree(const uint8_t w[], size_t w_len)
{
BigInt input = BigInt::decode(w, w_len);
diff --git a/src/lib/pubkey/dh/dh.h b/src/lib/pubkey/dh/dh.h
index 3b70d7149..d5e86d154 100644
--- a/src/lib/pubkey/dh/dh.h
+++ b/src/lib/pubkey/dh/dh.h
@@ -20,7 +20,7 @@ class BOTAN_DLL DH_PublicKey : public virtual DL_Scheme_PublicKey
public:
std::string algo_name() const override { return "DH"; }
- std::vector<byte> public_value() const;
+ std::vector<uint8_t> public_value() const;
DL_Group::Format group_format() const override { return DL_Group::ANSI_X9_42; }
@@ -30,7 +30,7 @@ class BOTAN_DLL DH_PublicKey : public virtual DL_Scheme_PublicKey
* @param key_bits DER encoded public key bits
*/
DH_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_42) {}
/**
@@ -51,7 +51,7 @@ class BOTAN_DLL DH_PrivateKey : public DH_PublicKey,
public virtual DL_Scheme_PrivateKey
{
public:
- std::vector<byte> public_value() const override;
+ std::vector<uint8_t> public_value() const override;
/**
* Load a private key.
@@ -59,7 +59,7 @@ class BOTAN_DLL DH_PrivateKey : public DH_PublicKey,
* @param key_bits PKCS #8 structure
*/
DH_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Create a private key.
diff --git a/src/lib/pubkey/dl_algo/dl_algo.cpp b/src/lib/pubkey/dl_algo/dl_algo.cpp
index 8e885d318..ac6637e29 100644
--- a/src/lib/pubkey/dl_algo/dl_algo.cpp
+++ b/src/lib/pubkey/dl_algo/dl_algo.cpp
@@ -29,13 +29,13 @@ AlgorithmIdentifier DL_Scheme_PublicKey::algorithm_identifier() const
m_group.DER_encode(group_format()));
}
-std::vector<byte> DL_Scheme_PublicKey::public_key_bits() const
+std::vector<uint8_t> DL_Scheme_PublicKey::public_key_bits() const
{
return DER_Encoder().encode(m_y).get_contents_unlocked();
}
DL_Scheme_PublicKey::DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits,
+ const std::vector<uint8_t>& key_bits,
DL_Group::Format format)
{
m_group.BER_decode(alg_id.parameters, format);
@@ -43,13 +43,13 @@ DL_Scheme_PublicKey::DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
BER_Decoder(key_bits).decode(m_y);
}
-secure_vector<byte> DL_Scheme_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> DL_Scheme_PrivateKey::private_key_bits() const
{
return DER_Encoder().encode(m_x).get_contents();
}
DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits,
+ const secure_vector<uint8_t>& key_bits,
DL_Group::Format format)
{
m_group.BER_decode(alg_id.parameters, format);
diff --git a/src/lib/pubkey/dl_algo/dl_algo.h b/src/lib/pubkey/dl_algo/dl_algo.h
index 40c4a1fab..044aae2e6 100644
--- a/src/lib/pubkey/dl_algo/dl_algo.h
+++ b/src/lib/pubkey/dl_algo/dl_algo.h
@@ -23,7 +23,7 @@ class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
/**
* Get the DL domain parameters of this key.
@@ -70,7 +70,7 @@ class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key
* @param group_format the underlying groups encoding format
*/
DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits,
+ const std::vector<uint8_t>& key_bits,
DL_Group::Format group_format);
protected:
@@ -102,7 +102,7 @@ class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
*/
const BigInt& get_x() const { return m_x; }
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
/**
* Create a private key.
@@ -111,7 +111,7 @@ class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
* @param group_format the underlying groups encoding format
*/
DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits,
+ const secure_vector<uint8_t>& key_bits,
DL_Group::Format group_format);
protected:
diff --git a/src/lib/pubkey/dl_group/dl_group.cpp b/src/lib/pubkey/dl_group/dl_group.cpp
index 40660e62a..0f4985eb9 100644
--- a/src/lib/pubkey/dl_group/dl_group.cpp
+++ b/src/lib/pubkey/dl_group/dl_group.cpp
@@ -83,7 +83,7 @@ DL_Group::DL_Group(RandomNumberGenerator& rng,
* DL_Group Constructor
*/
DL_Group::DL_Group(RandomNumberGenerator& rng,
- const std::vector<byte>& seed,
+ const std::vector<uint8_t>& seed,
size_t pbits, size_t qbits)
{
if(!generate_dsa_primes(rng, m_p, m_q, pbits, qbits, seed))
@@ -193,7 +193,7 @@ const BigInt& DL_Group::get_q() const
/*
* DER encode the parameters
*/
-std::vector<byte> DL_Group::DER_encode(Format format) const
+std::vector<uint8_t> DL_Group::DER_encode(Format format) const
{
init_check();
@@ -238,7 +238,7 @@ std::vector<byte> DL_Group::DER_encode(Format format) const
*/
std::string DL_Group::PEM_encode(Format format) const
{
- const std::vector<byte> encoding = DER_encode(format);
+ const std::vector<uint8_t> encoding = DER_encode(format);
if(format == PKCS_3)
return PEM_Code::encode(encoding, "DH PARAMETERS");
@@ -253,7 +253,7 @@ std::string DL_Group::PEM_encode(Format format) const
/*
* Decode BER encoded parameters
*/
-void DL_Group::BER_decode(const std::vector<byte>& data,
+void DL_Group::BER_decode(const std::vector<uint8_t>& data,
Format format)
{
BigInt new_p, new_q, new_g;
diff --git a/src/lib/pubkey/dl_group/dl_group.h b/src/lib/pubkey/dl_group/dl_group.h
index 8bdd205da..39ad9b954 100644
--- a/src/lib/pubkey/dl_group/dl_group.h
+++ b/src/lib/pubkey/dl_group/dl_group.h
@@ -78,14 +78,14 @@ class BOTAN_DLL DL_Group
* @param format the encoding format
* @return string holding the DER encoded group
*/
- std::vector<byte> DER_encode(Format format) const;
+ std::vector<uint8_t> DER_encode(Format format) const;
/**
* Decode a DER/BER encoded group into this instance.
* @param ber a vector containing the DER/BER encoded group
* @param format the format of the encoded group
*/
- void BER_decode(const std::vector<byte>& ber,
+ void BER_decode(const std::vector<uint8_t>& ber,
Format format);
/**
@@ -134,7 +134,7 @@ class BOTAN_DLL DL_Group
* @param qbits the desired bit size of the prime q.
*/
DL_Group(RandomNumberGenerator& rng,
- const std::vector<byte>& seed,
+ const std::vector<uint8_t>& seed,
size_t pbits = 1024, size_t qbits = 0);
/**
diff --git a/src/lib/pubkey/dlies/dlies.cpp b/src/lib/pubkey/dlies/dlies.cpp
index 09f24adb7..ca91a0fd4 100644
--- a/src/lib/pubkey/dlies/dlies.cpp
+++ b/src/lib/pubkey/dlies/dlies.cpp
@@ -41,7 +41,7 @@ DLIES_Encryptor::DLIES_Encryptor(const DH_PrivateKey& own_priv_key,
BOTAN_ASSERT_NONNULL(mac);
}
-std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length,
+std::vector<uint8_t> DLIES_Encryptor::enc(const uint8_t in[], size_t length,
RandomNumberGenerator&) const
{
if(m_other_pub_key.empty())
@@ -54,14 +54,14 @@ std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length,
// derive secret key from secret value
const size_t required_key_length = m_cipher ? m_cipher_key_len + m_mac_keylen : length + m_mac_keylen;
- const secure_vector<byte> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of());
+ const secure_vector<uint8_t> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of());
if(secret_keys.size() != required_key_length)
{
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
}
- secure_vector<byte> ciphertext(in, in + length);
+ secure_vector<uint8_t> ciphertext(in, in + length);
const size_t cipher_key_len = m_cipher ? m_cipher_key_len : length;
if(m_cipher)
@@ -83,10 +83,10 @@ std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length,
// calculate MAC
m_mac->set_key(secret_keys.data() + cipher_key_len, m_mac_keylen);
- secure_vector<byte> tag = m_mac->process(ciphertext);
+ secure_vector<uint8_t> tag = m_mac->process(ciphertext);
// out = (ephemeral) public key + ciphertext + tag
- secure_vector<byte> out(m_own_pub_key.size() + ciphertext.size() + tag.size());
+ secure_vector<uint8_t> out(m_own_pub_key.size() + ciphertext.size() + tag.size());
buffer_insert(out, 0, m_own_pub_key);
buffer_insert(out, 0 + m_own_pub_key.size(), ciphertext);
buffer_insert(out, 0 + m_own_pub_key.size() + ciphertext.size(), tag);
@@ -140,8 +140,8 @@ DLIES_Decryptor::DLIES_Decryptor(const DH_PrivateKey& own_priv_key,
DLIES_Decryptor(own_priv_key, rng, kdf, nullptr, 0, mac, mac_key_length)
{}
-secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask,
- const byte msg[], size_t length) const
+secure_vector<uint8_t> DLIES_Decryptor::do_decrypt(uint8_t& valid_mask,
+ const uint8_t msg[], size_t length) const
{
if(length < m_pub_key_size + m_mac->output_length())
{
@@ -149,7 +149,7 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask,
}
// calculate secret value
- std::vector<byte> other_pub_key(msg, msg + m_pub_key_size);
+ std::vector<uint8_t> other_pub_key(msg, msg + m_pub_key_size);
const SymmetricKey secret_value = m_ka.derive_key(0, other_pub_key);
const size_t ciphertext_len = length - m_pub_key_size - m_mac->output_length();
@@ -157,24 +157,24 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask,
// derive secret key from secret value
const size_t required_key_length = cipher_key_len + m_mac_keylen;
- secure_vector<byte> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of());
+ secure_vector<uint8_t> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of());
if(secret_keys.size() != required_key_length)
{
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
}
- secure_vector<byte> ciphertext(msg + m_pub_key_size, msg + m_pub_key_size + ciphertext_len);
+ secure_vector<uint8_t> ciphertext(msg + m_pub_key_size, msg + m_pub_key_size + ciphertext_len);
// calculate MAC
m_mac->set_key(secret_keys.data() + cipher_key_len, m_mac_keylen);
- secure_vector<byte> calculated_tag = m_mac->process(ciphertext);
+ secure_vector<uint8_t> calculated_tag = m_mac->process(ciphertext);
// calculated tag == received tag ?
- secure_vector<byte> tag(msg + m_pub_key_size + ciphertext_len,
+ secure_vector<uint8_t> tag(msg + m_pub_key_size + ciphertext_len,
msg + m_pub_key_size + ciphertext_len + m_mac->output_length());
- valid_mask = CT::expand_mask<byte>(same_mem(tag.data(), calculated_tag.data(), tag.size()));
+ valid_mask = CT::expand_mask<uint8_t>(same_mem(tag.data(), calculated_tag.data(), tag.size()));
// decrypt
if(m_cipher)
@@ -204,7 +204,7 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask,
}
else
{
- return secure_vector<byte>();
+ return secure_vector<uint8_t>();
}
}
else
diff --git a/src/lib/pubkey/dlies/dlies.h b/src/lib/pubkey/dlies/dlies.h
index 6e56c3da5..54b8f3f48 100644
--- a/src/lib/pubkey/dlies/dlies.h
+++ b/src/lib/pubkey/dlies/dlies.h
@@ -62,7 +62,7 @@ class BOTAN_DLL DLIES_Encryptor : public PK_Encryptor
size_t mac_key_len = 20);
// Set the other parties public key
- inline void set_other_key(const std::vector<byte>& other_pub_key)
+ inline void set_other_key(const std::vector<uint8_t>& other_pub_key)
{
m_other_pub_key = other_pub_key;
}
@@ -74,13 +74,13 @@ class BOTAN_DLL DLIES_Encryptor : public PK_Encryptor
}
private:
- std::vector<byte> enc(const byte[], size_t,
+ std::vector<uint8_t> enc(const uint8_t[], size_t,
RandomNumberGenerator&) const override;
size_t maximum_input_size() const override;
- std::vector<byte> m_other_pub_key;
- std::vector<byte> m_own_pub_key;
+ std::vector<uint8_t> m_other_pub_key;
+ std::vector<uint8_t> m_own_pub_key;
PK_Key_Agreement m_ka;
std::unique_ptr<KDF> m_kdf;
std::unique_ptr<Cipher_Mode> m_cipher;
@@ -141,8 +141,8 @@ class BOTAN_DLL DLIES_Decryptor : public PK_Decryptor
}
private:
- secure_vector<byte> do_decrypt(byte& valid_mask,
- const byte in[], size_t in_len) const override;
+ secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_len) const override;
const size_t m_pub_key_size;
PK_Key_Agreement m_ka;
diff --git a/src/lib/pubkey/dsa/dsa.cpp b/src/lib/pubkey/dsa/dsa.cpp
index f6c5989db..c419eec97 100644
--- a/src/lib/pubkey/dsa/dsa.cpp
+++ b/src/lib/pubkey/dsa/dsa.cpp
@@ -50,7 +50,7 @@ DSA_PrivateKey::DSA_PrivateKey(RandomNumberGenerator& rng,
}
DSA_PrivateKey::DSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
{
m_y = power_mod(group_g(), m_x, group_p());
@@ -90,7 +90,7 @@ class DSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
size_t max_input_bits() const override { return m_q.bits(); }
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
const BigInt& m_q;
@@ -100,8 +100,8 @@ class DSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
std::string m_emsa;
};
-secure_vector<byte>
-DSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+DSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
BigInt i(msg, msg_len);
@@ -154,8 +154,8 @@ class DSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const BigInt& m_q;
const BigInt& m_y;
@@ -164,8 +164,8 @@ class DSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
Modular_Reducer m_mod_p, m_mod_q;
};
-bool DSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool DSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != 2*m_q.bytes() || msg_len > m_q.bytes())
return false;
diff --git a/src/lib/pubkey/dsa/dsa.h b/src/lib/pubkey/dsa/dsa.h
index d26642ed4..117853907 100644
--- a/src/lib/pubkey/dsa/dsa.h
+++ b/src/lib/pubkey/dsa/dsa.h
@@ -30,7 +30,7 @@ class BOTAN_DLL DSA_PublicKey : public virtual DL_Scheme_PublicKey
* @param key_bits DER encoded public key bits
*/
DSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
{
}
@@ -62,7 +62,7 @@ class BOTAN_DLL DSA_PrivateKey : public DSA_PublicKey,
* @param key_bits PKCS#8 structure
*/
DSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Create a private key.
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index c264d7314..a5262fd5e 100644
--- a/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/lib/pubkey/ec_group/ec_group.cpp
@@ -33,7 +33,7 @@ EC_Group::EC_Group(const std::string& str)
try
{
- std::vector<byte> ber =
+ std::vector<uint8_t> ber =
unlock(PEM_Code::decode_check_label(str, "EC PARAMETERS"));
*this = EC_Group(ber);
@@ -44,7 +44,7 @@ EC_Group::EC_Group(const std::string& str)
}
}
-EC_Group::EC_Group(const std::vector<byte>& ber_data)
+EC_Group::EC_Group(const std::vector<uint8_t>& ber_data)
{
BER_Decoder ber(ber_data);
BER_Object obj = ber.get_next_object();
@@ -60,7 +60,7 @@ EC_Group::EC_Group(const std::vector<byte>& ber_data)
else if(obj.type_tag == SEQUENCE)
{
BigInt p, a, b;
- std::vector<byte> sv_base_point;
+ std::vector<uint8_t> sv_base_point;
BER_Decoder(ber_data)
.start_cons(SEQUENCE)
@@ -87,7 +87,7 @@ EC_Group::EC_Group(const std::vector<byte>& ber_data)
throw Decoding_Error("Unexpected tag while decoding ECC domain params");
}
-std::vector<byte>
+std::vector<uint8_t>
EC_Group::DER_encode(EC_Group_Encoding form) const
{
if(form == EC_DOMPAR_ENC_EXPLICIT)
@@ -126,7 +126,7 @@ EC_Group::DER_encode(EC_Group_Encoding form) const
std::string EC_Group::PEM_encode() const
{
- const std::vector<byte> der = DER_encode(EC_DOMPAR_ENC_EXPLICIT);
+ const std::vector<uint8_t> der = DER_encode(EC_DOMPAR_ENC_EXPLICIT);
return PEM_Code::encode(der, "EC PARAMETERS");
}
diff --git a/src/lib/pubkey/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h
index a03b97a68..b623a876d 100644
--- a/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/lib/pubkey/ec_group/ec_group.h
@@ -54,7 +54,7 @@ class BOTAN_DLL EC_Group
* Decode a BER encoded ECC domain parameter set
* @param ber_encoding the bytes of the BER encoding
*/
- explicit EC_Group(const std::vector<byte>& ber_encoding);
+ explicit EC_Group(const std::vector<uint8_t>& ber_encoding);
/**
* Create an EC domain by OID (or throw if unknown)
@@ -74,7 +74,7 @@ class BOTAN_DLL EC_Group
* @param form of encoding to use
* @returns bytes encododed as DER
*/
- std::vector<byte> DER_encode(EC_Group_Encoding form) const;
+ std::vector<uint8_t> DER_encode(EC_Group_Encoding form) const;
/**
* Return the PEM encoding (always in explicit form)
diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp
index 00ddddda1..cb0af42eb 100644
--- a/src/lib/pubkey/ecc_key/ecc_key.cpp
+++ b/src/lib/pubkey/ecc_key/ecc_key.cpp
@@ -38,7 +38,7 @@ EC_PublicKey::EC_PublicKey(const EC_Group& dom_par,
}
EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
m_domain_params{EC_Group(alg_id.parameters)},
m_public_key{OS2ECP(key_bits, domain().get_curve())},
m_domain_encoding{EC_DOMPAR_ENC_EXPLICIT}
@@ -55,7 +55,7 @@ AlgorithmIdentifier EC_PublicKey::algorithm_identifier() const
return AlgorithmIdentifier(get_oid(), DER_domain());
}
-std::vector<byte> EC_PublicKey::public_key_bits() const
+std::vector<uint8_t> EC_PublicKey::public_key_bits() const
{
return unlock(EC2OSP(public_point(), PointGFp::COMPRESSED));
}
@@ -110,7 +110,7 @@ EC_PrivateKey::EC_PrivateKey(RandomNumberGenerator& rng,
"Generated public key point was on the curve");
}
-secure_vector<byte> EC_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> EC_PrivateKey::private_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -122,14 +122,14 @@ secure_vector<byte> EC_PrivateKey::private_key_bits() const
}
EC_PrivateKey::EC_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits,
+ const secure_vector<uint8_t>& key_bits,
bool with_modular_inverse)
{
m_domain_params = EC_Group(alg_id.parameters);
m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT;
OID key_parameters;
- secure_vector<byte> public_key_bits;
+ secure_vector<uint8_t> public_key_bits;
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
diff --git a/src/lib/pubkey/ecc_key/ecc_key.h b/src/lib/pubkey/ecc_key/ecc_key.h
index 06f100c1c..d4ce6c0e7 100644
--- a/src/lib/pubkey/ecc_key/ecc_key.h
+++ b/src/lib/pubkey/ecc_key/ecc_key.h
@@ -43,7 +43,7 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
* @param key_bits DER encoded public key bits
*/
EC_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Get the public point of this key.
@@ -55,7 +55,7 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
bool check_key(RandomNumberGenerator& rng,
bool strong) const override;
@@ -78,7 +78,7 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
* Return the DER encoding of this keys domain in whatever format
* is preset for this particular key
*/
- std::vector<byte> DER_domain() const
+ std::vector<uint8_t> DER_domain() const
{ return domain().DER_encode(domain_format()); }
/**
@@ -129,10 +129,10 @@ class BOTAN_DLL EC_PrivateKey : public virtual EC_PublicKey,
* multiplying directly with x (as in ECDSA).
*/
EC_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits,
+ const secure_vector<uint8_t>& key_bits,
bool with_modular_inverse=false);
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
/**
* Get the private key value of this key object.
diff --git a/src/lib/pubkey/ecdh/ecdh.cpp b/src/lib/pubkey/ecdh/ecdh.cpp
index 1bdf2c209..32914be2e 100644
--- a/src/lib/pubkey/ecdh/ecdh.cpp
+++ b/src/lib/pubkey/ecdh/ecdh.cpp
@@ -35,7 +35,7 @@ class ECDH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
m_l_times_priv = inverse_mod(m_cofactor, key.domain().get_order()) * key.private_value();
}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override
{
PointGFp point = OS2ECP(w, w_len, m_curve);
// TODO: add blinding
diff --git a/src/lib/pubkey/ecdh/ecdh.h b/src/lib/pubkey/ecdh/ecdh.h
index 09c3fc721..7524a80ff 100644
--- a/src/lib/pubkey/ecdh/ecdh.h
+++ b/src/lib/pubkey/ecdh/ecdh.h
@@ -26,7 +26,7 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
ECDH_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
EC_PublicKey(alg_id, key_bits) {}
/**
@@ -47,13 +47,13 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey
/**
* @return public point value
*/
- std::vector<byte> public_value() const
+ std::vector<uint8_t> public_value() const
{ return unlock(EC2OSP(public_point(), PointGFp::UNCOMPRESSED)); }
/**
* @return public point value
*/
- std::vector<byte> public_value(PointGFp::Compression_Type type) const
+ std::vector<uint8_t> public_value(PointGFp::Compression_Type type) const
{ return unlock(EC2OSP(public_point(), type)); }
protected:
@@ -75,7 +75,7 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey,
* @param key_bits X.509 subject public key info structure
*/
ECDH_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits) {}
/**
@@ -89,10 +89,10 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey,
const BigInt& x = 0) :
EC_PrivateKey(rng, domain, x) {}
- std::vector<byte> public_value() const override
+ std::vector<uint8_t> public_value() const override
{ return ECDH_PublicKey::public_value(PointGFp::UNCOMPRESSED); }
- std::vector<byte> public_value(PointGFp::Compression_Type type) const
+ std::vector<uint8_t> public_value(PointGFp::Compression_Type type) const
{ return ECDH_PublicKey::public_value(type); }
std::unique_ptr<PK_Ops::Key_Agreement>
diff --git a/src/lib/pubkey/ecdsa/ecdsa.cpp b/src/lib/pubkey/ecdsa/ecdsa.cpp
index 8a6dd840b..bb65fb138 100644
--- a/src/lib/pubkey/ecdsa/ecdsa.cpp
+++ b/src/lib/pubkey/ecdsa/ecdsa.cpp
@@ -58,7 +58,7 @@ class ECDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
size_t max_input_bits() const override { return m_order.bits(); }
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
@@ -69,8 +69,8 @@ class ECDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
std::string m_emsa;
};
-secure_vector<byte>
-ECDSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+ECDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const BigInt m(msg, msg_len);
@@ -113,8 +113,8 @@ class ECDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
@@ -123,8 +123,8 @@ class ECDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
Modular_Reducer m_mod_order;
};
-bool ECDSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool ECDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != m_order.bytes()*2)
return false;
diff --git a/src/lib/pubkey/ecdsa/ecdsa.h b/src/lib/pubkey/ecdsa/ecdsa.h
index d6e08c42f..21535a2f4 100644
--- a/src/lib/pubkey/ecdsa/ecdsa.h
+++ b/src/lib/pubkey/ecdsa/ecdsa.h
@@ -36,7 +36,7 @@ class BOTAN_DLL ECDSA_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
ECDSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
EC_PublicKey(alg_id, key_bits) {}
/**
@@ -71,7 +71,7 @@ class BOTAN_DLL ECDSA_PrivateKey : public ECDSA_PublicKey,
* @param key_bits PKCS #8 structure
*/
ECDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits) {}
/**
diff --git a/src/lib/pubkey/ecgdsa/ecgdsa.cpp b/src/lib/pubkey/ecgdsa/ecgdsa.cpp
index 3740c3583..eb979cc1c 100644
--- a/src/lib/pubkey/ecgdsa/ecgdsa.cpp
+++ b/src/lib/pubkey/ecgdsa/ecgdsa.cpp
@@ -43,7 +43,7 @@ class ECGDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
{
}
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
size_t max_input_bits() const override { return m_order.bits(); }
@@ -55,8 +55,8 @@ class ECGDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
Modular_Reducer m_mod_order;
};
-secure_vector<byte>
-ECGDSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+ECGDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const BigInt m(msg, msg_len);
@@ -95,8 +95,8 @@ class ECGDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
@@ -105,8 +105,8 @@ class ECGDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
Modular_Reducer m_mod_order;
};
-bool ECGDSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool ECGDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != m_order.bytes()*2)
return false;
diff --git a/src/lib/pubkey/ecgdsa/ecgdsa.h b/src/lib/pubkey/ecgdsa/ecgdsa.h
index 5e0040fca..1d079bf38 100644
--- a/src/lib/pubkey/ecgdsa/ecgdsa.h
+++ b/src/lib/pubkey/ecgdsa/ecgdsa.h
@@ -34,7 +34,7 @@ class BOTAN_DLL ECGDSA_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
ECGDSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
EC_PublicKey(alg_id, key_bits) {}
/**
@@ -69,7 +69,7 @@ class BOTAN_DLL ECGDSA_PrivateKey : public ECGDSA_PublicKey,
* @param key_bits PKCS #8 structure
*/
ECGDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits, true) {}
/**
diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp
index b40d21251..84c1a8f3f 100644
--- a/src/lib/pubkey/ecies/ecies.cpp
+++ b/src/lib/pubkey/ecies/ecies.cpp
@@ -30,7 +30,7 @@ class ECIES_PrivateKey : public EC_PrivateKey, public PK_Key_Agreement_Key
{
}
- std::vector<byte> public_value() const override
+ std::vector<uint8_t> public_value() const override
{
return m_key.public_value();
}
@@ -61,7 +61,7 @@ class ECIES_ECDH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
{
}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override
{
const CurveGFp& curve = m_key.domain().get_curve();
PointGFp point = OS2ECP(w, w_len, curve);
@@ -130,7 +130,7 @@ ECIES_KA_Operation::ECIES_KA_Operation(const PK_Key_Agreement_Key& private_key,
/**
* ECIES secret derivation according to ISO 18033-2
*/
-SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<byte>& eph_public_key_bin,
+SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<uint8_t>& eph_public_key_bin,
const PointGFp& other_public_key_point) const
{
if(other_public_key_point.is_zero())
@@ -148,7 +148,7 @@ SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<byte>& eph_publ
other_point *= m_params.domain().get_cofactor();
}
- secure_vector<byte> derivation_input;
+ secure_vector<uint8_t> derivation_input;
// ISO 18033: encryption step e / decryption step g
if(!m_params.single_hash_mode())
@@ -157,7 +157,7 @@ SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<byte>& eph_publ
}
// ISO 18033: encryption step f / decryption step h
- secure_vector<byte> other_public_key_bin = EC2OSP(other_point, static_cast<byte>(m_params.compression_type()));
+ secure_vector<uint8_t> other_public_key_bin = EC2OSP(other_point, static_cast<uint8_t>(m_params.compression_type()));
// Note: the argument `m_params.secret_length()` passed for `key_len` will only be used by providers because
// "Raw" is passed to the `PK_Key_Agreement` if the implementation of botan is used.
const SymmetricKey peh = m_ka.derive_key(m_params.domain().get_order().bytes(), other_public_key_bin.data(), other_public_key_bin.size());
@@ -237,7 +237,7 @@ ECIES_Encryptor::ECIES_Encryptor(const PK_Key_Agreement_Key& private_key,
// ISO 18033: step d
// convert only if necessary; m_eph_public_key_bin has been initialized with the uncompressed format
m_eph_public_key_bin = unlock(EC2OSP(OS2ECP(m_eph_public_key_bin, m_params.domain().get_curve()),
- static_cast<byte>(ecies_params.compression_type())));
+ static_cast<uint8_t>(ecies_params.compression_type())));
}
}
@@ -253,7 +253,7 @@ ECIES_Encryptor::ECIES_Encryptor(RandomNumberGenerator& rng, const ECIES_System_
/*
* ECIES Encryption according to ISO 18033-2
*/
-std::vector<byte> ECIES_Encryptor::enc(const byte data[], size_t length, RandomNumberGenerator&) const
+std::vector<uint8_t> ECIES_Encryptor::enc(const uint8_t data[], size_t length, RandomNumberGenerator&) const
{
if(m_other_point.is_zero())
{
@@ -271,14 +271,14 @@ std::vector<byte> ECIES_Encryptor::enc(const byte data[], size_t length, RandomN
{
cipher->start(m_iv.bits_of());
}
- secure_vector<byte> encrypted_data(data, data + length);
+ secure_vector<uint8_t> encrypted_data(data, data + length);
cipher->finish(encrypted_data);
// concat elements
std::unique_ptr<MessageAuthenticationCode> mac = m_params.create_mac();
BOTAN_ASSERT(mac != nullptr, "MAC is found");
- secure_vector<byte> out(m_eph_public_key_bin.size() + encrypted_data.size() + mac->output_length());
+ secure_vector<uint8_t> out(m_eph_public_key_bin.size() + encrypted_data.size() + mac->output_length());
buffer_insert(out, 0, m_eph_public_key_bin);
buffer_insert(out, m_eph_public_key_bin.size(), encrypted_data);
@@ -317,7 +317,7 @@ ECIES_Decryptor::ECIES_Decryptor(const PK_Key_Agreement_Key& key,
/**
* ECIES Decryption according to ISO 18033-2
*/
-secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[], size_t in_len) const
+secure_vector<uint8_t> ECIES_Decryptor::do_decrypt(uint8_t& valid_mask, const uint8_t in[], size_t in_len) const
{
size_t point_size = m_params.domain().get_curve().get_p().bytes();
if(m_params.compression_type() != PointGFp::COMPRESSED)
@@ -335,9 +335,9 @@ secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[
}
// extract data
- const std::vector<byte> other_public_key_bin(in, in + point_size); // the received (ephemeral) public key
- const std::vector<byte> encrypted_data(in + point_size, in + in_len - mac->output_length());
- const std::vector<byte> mac_data(in + in_len - mac->output_length(), in + in_len);
+ const std::vector<uint8_t> other_public_key_bin(in, in + point_size); // the received (ephemeral) public key
+ const std::vector<uint8_t> encrypted_data(in + point_size, in + in_len - mac->output_length());
+ const std::vector<uint8_t> mac_data(in + in_len - mac->output_length(), in + in_len);
// ISO 18033: step a
PointGFp other_public_key = OS2ECP(other_public_key_bin, m_params.domain().get_curve());
@@ -359,8 +359,8 @@ secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[
{
mac->update(m_label);
}
- const secure_vector<byte> calculated_mac = mac->final();
- valid_mask = CT::expand_mask<byte>(same_mem(mac_data.data(), calculated_mac.data(), mac_data.size()));
+ const secure_vector<uint8_t> calculated_mac = mac->final();
+ valid_mask = CT::expand_mask<uint8_t>(same_mem(mac_data.data(), calculated_mac.data(), mac_data.size()));
if(valid_mask)
{
@@ -378,7 +378,7 @@ secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[
{
// the decryption can fail:
// e.g. Integrity_Failure is thrown if GCM is used and the message does not have a valid tag
- secure_vector<byte> decrypted_data(encrypted_data.begin(), encrypted_data.end());
+ secure_vector<uint8_t> decrypted_data(encrypted_data.begin(), encrypted_data.end());
cipher->finish(decrypted_data);
return decrypted_data;
}
@@ -387,7 +387,7 @@ secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[
valid_mask = 0;
}
}
- return secure_vector<byte>();
+ return secure_vector<uint8_t>();
}
}
diff --git a/src/lib/pubkey/ecies/ecies.h b/src/lib/pubkey/ecies/ecies.h
index 3f7a2e48b..6daf5a641 100644
--- a/src/lib/pubkey/ecies/ecies.h
+++ b/src/lib/pubkey/ecies/ecies.h
@@ -198,7 +198,7 @@ class BOTAN_DLL ECIES_KA_Operation
* @param eph_public_key_bin the encoded (ephemeral) public key which belongs to the used (ephemeral) private key
* @param other_public_key_point public key point of the other party
*/
- SymmetricKey derive_secret(const std::vector<byte>& eph_public_key_bin,
+ SymmetricKey derive_secret(const std::vector<uint8_t>& eph_public_key_bin,
const PointGFp& other_public_key_point) const;
private:
@@ -244,11 +244,11 @@ class BOTAN_DLL ECIES_Encryptor : public PK_Encryptor
/// Set the label which is appended to the input for the message authentication code
inline void set_label(const std::string& label)
{
- m_label = std::vector<byte>(label.begin(), label.end());
+ m_label = std::vector<uint8_t>(label.begin(), label.end());
}
private:
- std::vector<byte> enc(const byte data[], size_t length, RandomNumberGenerator&) const override;
+ std::vector<uint8_t> enc(const uint8_t data[], size_t length, RandomNumberGenerator&) const override;
inline size_t maximum_input_size() const override
{
@@ -257,10 +257,10 @@ class BOTAN_DLL ECIES_Encryptor : public PK_Encryptor
const ECIES_KA_Operation m_ka;
const ECIES_System_Params m_params;
- std::vector<byte> m_eph_public_key_bin;
+ std::vector<uint8_t> m_eph_public_key_bin;
InitializationVector m_iv;
PointGFp m_other_point;
- std::vector<byte> m_label;
+ std::vector<uint8_t> m_label;
};
@@ -288,16 +288,16 @@ class BOTAN_DLL ECIES_Decryptor : public PK_Decryptor
/// Set the label which is appended to the input for the message authentication code
inline void set_label(const std::string& label)
{
- m_label = std::vector<byte>(label.begin(), label.end());
+ m_label = std::vector<uint8_t>(label.begin(), label.end());
}
private:
- secure_vector<byte> do_decrypt(byte& valid_mask, const byte in[], size_t in_len) const override;
+ secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask, const uint8_t in[], size_t in_len) const override;
const ECIES_KA_Operation m_ka;
const ECIES_System_Params m_params;
InitializationVector m_iv;
- std::vector<byte> m_label;
+ std::vector<uint8_t> m_label;
};
}
diff --git a/src/lib/pubkey/eckcdsa/eckcdsa.cpp b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
index 89b5925a2..778c0f833 100644
--- a/src/lib/pubkey/eckcdsa/eckcdsa.cpp
+++ b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
@@ -57,36 +57,36 @@ class ECKCDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
m_prefix.resize(HashFunction::create(hash_for_signature())->hash_block_size()); // use only the "hash input block size" leftmost bits
}
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
size_t max_input_bits() const override { return m_order.bits(); }
bool has_prefix() override { return true; }
- secure_vector<byte> message_prefix() const override { return m_prefix; }
+ secure_vector<uint8_t> message_prefix() const override { return m_prefix; }
private:
const BigInt& m_order;
Blinded_Point_Multiply m_base_point;
const BigInt& m_x;
Modular_Reducer m_mod_order;
- secure_vector<byte> m_prefix;
+ secure_vector<uint8_t> m_prefix;
};
-secure_vector<byte>
-ECKCDSA_Signature_Operation::raw_sign(const byte msg[], size_t,
+secure_vector<uint8_t>
+ECKCDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t,
RandomNumberGenerator& rng)
{
const BigInt k = BigInt::random_integer(rng, 1, m_order);
const PointGFp k_times_P = m_base_point.blinded_multiply(k, rng);
const BigInt k_times_P_x = k_times_P.get_affine_x();
- secure_vector<byte> to_be_hashed(k_times_P_x.bytes());
+ secure_vector<uint8_t> to_be_hashed(k_times_P_x.bytes());
k_times_P_x.binary_encode(to_be_hashed.data());
std::unique_ptr<EMSA> emsa(m_emsa->clone());
emsa->update(to_be_hashed.data(), to_be_hashed.size());
- secure_vector<byte> c = emsa->raw_data();
+ secure_vector<uint8_t> c = emsa->raw_data();
c = emsa->encoding_of(c, max_input_bits(), rng);
const BigInt r(c.data(), c.size());
@@ -98,7 +98,7 @@ ECKCDSA_Signature_Operation::raw_sign(const byte msg[], size_t,
const BigInt s = m_mod_order.multiply(m_x, k - w);
BOTAN_ASSERT(s != 0, "invalid s");
- secure_vector<byte> output = BigInt::encode_1363(r, c.size());
+ secure_vector<uint8_t> output = BigInt::encode_1363(r, c.size());
output += BigInt::encode_1363(s, m_order.bytes());
return output;
}
@@ -129,25 +129,25 @@ class ECKCDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
}
bool has_prefix() override { return true; }
- secure_vector<byte> message_prefix() const override { return m_prefix; }
+ secure_vector<uint8_t> message_prefix() const override { return m_prefix; }
size_t max_input_bits() const override { return m_order.bits(); }
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
const BigInt& m_order;
// FIXME: should be offered by curve
Modular_Reducer m_mod_order;
- secure_vector<byte> m_prefix;
+ secure_vector<uint8_t> m_prefix;
};
-bool ECKCDSA_Verification_Operation::verify(const byte msg[], size_t,
- const byte sig[], size_t sig_len)
+bool ECKCDSA_Verification_Operation::verify(const uint8_t msg[], size_t,
+ const uint8_t sig[], size_t sig_len)
{
const std::unique_ptr<HashFunction> hash = HashFunction::create(hash_for_signature());
//calculate size of r
@@ -157,7 +157,7 @@ bool ECKCDSA_Verification_Operation::verify(const byte msg[], size_t,
return false;
}
- secure_vector<byte> r(sig, sig + size_r);
+ secure_vector<uint8_t> r(sig, sig + size_r);
// check that 0 < s < q
const BigInt s(sig + size_r, m_order.bytes());
@@ -167,18 +167,18 @@ bool ECKCDSA_Verification_Operation::verify(const byte msg[], size_t,
return false;
}
- secure_vector<byte> r_xor_e(r);
+ secure_vector<uint8_t> r_xor_e(r);
xor_buf(r_xor_e, msg, r.size());
BigInt w(r_xor_e.data(), r_xor_e.size());
w = m_mod_order.reduce(w);
const PointGFp q = multi_exponentiate(m_base_point, w, m_public_point, s);
const BigInt q_x = q.get_affine_x();
- secure_vector<byte> c(q_x.bytes());
+ secure_vector<uint8_t> c(q_x.bytes());
q_x.binary_encode(c.data());
std::unique_ptr<EMSA> emsa(m_emsa->clone());
emsa->update(c.data(), c.size());
- secure_vector<byte> v = emsa->raw_data();
+ secure_vector<uint8_t> v = emsa->raw_data();
Null_RNG rng;
v = emsa->encoding_of(v, max_input_bits(), rng);
diff --git a/src/lib/pubkey/eckcdsa/eckcdsa.h b/src/lib/pubkey/eckcdsa/eckcdsa.h
index e29ff610c..21bfbdc3c 100644
--- a/src/lib/pubkey/eckcdsa/eckcdsa.h
+++ b/src/lib/pubkey/eckcdsa/eckcdsa.h
@@ -34,7 +34,7 @@ class BOTAN_DLL ECKCDSA_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
ECKCDSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
EC_PublicKey(alg_id, key_bits) {}
/**
@@ -69,7 +69,7 @@ class BOTAN_DLL ECKCDSA_PrivateKey : public ECKCDSA_PublicKey,
* @param key_bits PKCS #8 structure
*/
ECKCDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits, true) {}
/**
diff --git a/src/lib/pubkey/elgamal/elgamal.cpp b/src/lib/pubkey/elgamal/elgamal.cpp
index 90534a430..b7ce643f1 100644
--- a/src/lib/pubkey/elgamal/elgamal.cpp
+++ b/src/lib/pubkey/elgamal/elgamal.cpp
@@ -40,7 +40,7 @@ ElGamal_PrivateKey::ElGamal_PrivateKey(RandomNumberGenerator& rng,
}
ElGamal_PrivateKey::ElGamal_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
{
m_y = power_mod(group_g(), m_x, group_p());
@@ -74,7 +74,7 @@ class ElGamal_Encryption_Operation : public PK_Ops::Encryption_with_EME
ElGamal_Encryption_Operation(const ElGamal_PublicKey& key, const std::string& eme);
- secure_vector<byte> raw_encrypt(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
@@ -93,8 +93,8 @@ ElGamal_Encryption_Operation::ElGamal_Encryption_Operation(const ElGamal_PublicK
m_mod_p = Modular_Reducer(p);
}
-secure_vector<byte>
-ElGamal_Encryption_Operation::raw_encrypt(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+ElGamal_Encryption_Operation::raw_encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const BigInt& p = m_mod_p.get_modulus();
@@ -109,7 +109,7 @@ ElGamal_Encryption_Operation::raw_encrypt(const byte msg[], size_t msg_len,
BigInt a = m_powermod_g_p(k);
BigInt b = m_mod_p.multiply(m, m_powermod_y_p(k));
- secure_vector<byte> output(2*p.bytes());
+ secure_vector<uint8_t> output(2*p.bytes());
a.binary_encode(&output[p.bytes() - a.bytes()]);
b.binary_encode(&output[output.size() / 2 + (p.bytes() - b.bytes())]);
return output;
@@ -129,7 +129,7 @@ class ElGamal_Decryption_Operation : public PK_Ops::Decryption_with_EME
const std::string& eme,
RandomNumberGenerator& rng);
- secure_vector<byte> raw_decrypt(const byte msg[], size_t msg_len) override;
+ secure_vector<uint8_t> raw_decrypt(const uint8_t msg[], size_t msg_len) override;
private:
Fixed_Exponent_Power_Mod m_powermod_x_p;
Modular_Reducer m_mod_p;
@@ -149,8 +149,8 @@ ElGamal_Decryption_Operation::ElGamal_Decryption_Operation(const ElGamal_Private
{
}
-secure_vector<byte>
-ElGamal_Decryption_Operation::raw_decrypt(const byte msg[], size_t msg_len)
+secure_vector<uint8_t>
+ElGamal_Decryption_Operation::raw_decrypt(const uint8_t msg[], size_t msg_len)
{
const BigInt& p = m_mod_p.get_modulus();
diff --git a/src/lib/pubkey/elgamal/elgamal.h b/src/lib/pubkey/elgamal/elgamal.h
index 9ac4ea949..688232631 100644
--- a/src/lib/pubkey/elgamal/elgamal.h
+++ b/src/lib/pubkey/elgamal/elgamal.h
@@ -27,7 +27,7 @@ class BOTAN_DLL ElGamal_PublicKey : public virtual DL_Scheme_PublicKey
* @param key_bits DER encoded public key bits
*/
ElGamal_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
{}
@@ -62,7 +62,7 @@ class BOTAN_DLL ElGamal_PrivateKey : public ElGamal_PublicKey,
* @param key_bits PKCS #8 structure
*/
ElGamal_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Create a private key.
diff --git a/src/lib/pubkey/gost_3410/gost_3410.cpp b/src/lib/pubkey/gost_3410/gost_3410.cpp
index e8923c71a..ee263bb96 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.cpp
+++ b/src/lib/pubkey/gost_3410/gost_3410.cpp
@@ -15,14 +15,14 @@
namespace Botan {
-std::vector<byte> GOST_3410_PublicKey::public_key_bits() const
+std::vector<uint8_t> GOST_3410_PublicKey::public_key_bits() const
{
const BigInt x = public_point().get_affine_x();
const BigInt y = public_point().get_affine_y();
size_t part_size = std::max(x.bytes(), y.bytes());
- std::vector<byte> bits(2*part_size);
+ std::vector<uint8_t> bits(2*part_size);
x.binary_encode(&bits[part_size - x.bytes()]);
y.binary_encode(&bits[2*part_size - y.bytes()]);
@@ -39,7 +39,7 @@ std::vector<byte> GOST_3410_PublicKey::public_key_bits() const
AlgorithmIdentifier GOST_3410_PublicKey::algorithm_identifier() const
{
- std::vector<byte> params =
+ std::vector<uint8_t> params =
DER_Encoder().start_cons(SEQUENCE)
.encode(OID(domain().get_oid()))
.end_cons()
@@ -49,7 +49,7 @@ AlgorithmIdentifier GOST_3410_PublicKey::algorithm_identifier() const
}
GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
OID ecc_param_id;
@@ -58,7 +58,7 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
m_domain_params = EC_Group(ecc_param_id);
- secure_vector<byte> bits;
+ secure_vector<uint8_t> bits;
BER_Decoder(key_bits).decode(bits, OCTET_STRING);
const size_t part_size = bits.size() / 2;
@@ -81,9 +81,9 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
namespace {
-BigInt decode_le(const byte msg[], size_t msg_len)
+BigInt decode_le(const uint8_t msg[], size_t msg_len)
{
- secure_vector<byte> msg_le(msg, msg + msg_len);
+ secure_vector<uint8_t> msg_le(msg, msg + msg_len);
for(size_t i = 0; i != msg_le.size() / 2; ++i)
std::swap(msg_le[i], msg_le[msg_le.size()-1-i]);
@@ -107,7 +107,7 @@ class GOST_3410_Signature_Operation : public PK_Ops::Signature_with_EMSA
size_t max_input_bits() const override { return m_order.bits(); }
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
@@ -117,8 +117,8 @@ class GOST_3410_Signature_Operation : public PK_Ops::Signature_with_EMSA
const BigInt& m_x;
};
-secure_vector<byte>
-GOST_3410_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+GOST_3410_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
BigInt k;
@@ -141,7 +141,7 @@ GOST_3410_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
if(r == 0 || s == 0)
throw Invalid_State("GOST 34.10: r == 0 || s == 0");
- secure_vector<byte> output(2*m_order.bytes());
+ secure_vector<uint8_t> output(2*m_order.bytes());
s.binary_encode(&output[output.size() / 2 - s.bytes()]);
r.binary_encode(&output[output.size() - r.bytes()]);
return output;
@@ -165,16 +165,16 @@ class GOST_3410_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
const BigInt& m_order;
};
-bool GOST_3410_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool GOST_3410_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != m_order.bytes()*2)
return false;
diff --git a/src/lib/pubkey/gost_3410/gost_3410.h b/src/lib/pubkey/gost_3410/gost_3410.h
index 49f328d56..dbaf68ada 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.h
+++ b/src/lib/pubkey/gost_3410/gost_3410.h
@@ -36,7 +36,7 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Get this keys algorithm name.
@@ -46,7 +46,7 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
size_t message_parts() const override { return 2; }
@@ -74,7 +74,7 @@ class BOTAN_DLL GOST_3410_PrivateKey : public GOST_3410_PublicKey,
* @param key_bits PKCS #8 structure
*/
GOST_3410_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits) {}
/**
diff --git a/src/lib/pubkey/keypair/keypair.cpp b/src/lib/pubkey/keypair/keypair.cpp
index 5667bde4a..70bdf05fc 100644
--- a/src/lib/pubkey/keypair/keypair.cpp
+++ b/src/lib/pubkey/keypair/keypair.cpp
@@ -30,14 +30,14 @@ bool encryption_consistency_check(RandomNumberGenerator& rng,
if(encryptor.maximum_input_size() == 0)
return true;
- std::vector<byte> plaintext =
+ std::vector<uint8_t> plaintext =
unlock(rng.random_vec(encryptor.maximum_input_size() - 1));
- std::vector<byte> ciphertext = encryptor.encrypt(plaintext, rng);
+ std::vector<uint8_t> ciphertext = encryptor.encrypt(plaintext, rng);
if(ciphertext == plaintext)
return false;
- std::vector<byte> decrypted = unlock(decryptor.decrypt(ciphertext));
+ std::vector<uint8_t> decrypted = unlock(decryptor.decrypt(ciphertext));
return (plaintext == decrypted);
}
@@ -53,10 +53,10 @@ bool signature_consistency_check(RandomNumberGenerator& rng,
PK_Signer signer(private_key, rng, padding);
PK_Verifier verifier(public_key, padding);
- std::vector<byte> message(32);
+ std::vector<uint8_t> message(32);
rng.randomize(message.data(), message.size());
- std::vector<byte> signature;
+ std::vector<uint8_t> signature;
try
{
diff --git a/src/lib/pubkey/mce/code_based_key_gen.cpp b/src/lib/pubkey/mce/code_based_key_gen.cpp
index 839ebc977..4d68c875a 100644
--- a/src/lib/pubkey/mce/code_based_key_gen.cpp
+++ b/src/lib/pubkey/mce/code_based_key_gen.cpp
@@ -22,27 +22,27 @@ namespace {
struct binary_matrix
{
public:
- binary_matrix(u32bit m_rown, u32bit m_coln);
+ binary_matrix(uint32_t m_rown, uint32_t m_coln);
- void row_xor(u32bit a, u32bit b);
+ void row_xor(uint32_t a, uint32_t b);
secure_vector<int> row_reduced_echelon_form();
/**
* return the coefficient out of F_2
*/
- u32bit coef(u32bit i, u32bit j)
+ uint32_t coef(uint32_t i, uint32_t j)
{
return (m_elem[(i) * m_rwdcnt + (j) / 32] >> (j % 32)) & 1;
};
- void set_coef_to_one(u32bit i, u32bit j)
+ void set_coef_to_one(uint32_t i, uint32_t j)
{
- m_elem[(i) * m_rwdcnt + (j) / 32] |= (static_cast<u32bit>(1) << ((j) % 32)) ;
+ m_elem[(i) * m_rwdcnt + (j) / 32] |= (static_cast<uint32_t>(1) << ((j) % 32)) ;
};
- void toggle_coeff(u32bit i, u32bit j)
+ void toggle_coeff(uint32_t i, uint32_t j)
{
- m_elem[(i) * m_rwdcnt + (j) / 32] ^= (static_cast<u32bit>(1) << ((j) % 32)) ;
+ m_elem[(i) * m_rwdcnt + (j) / 32] ^= (static_cast<uint32_t>(1) << ((j) % 32)) ;
}
void set_to_zero()
@@ -51,23 +51,23 @@ struct binary_matrix
}
//private:
- u32bit m_rown; // number of rows.
- u32bit m_coln; // number of columns.
- u32bit m_rwdcnt; // number of words in a row
- std::vector<u32bit> m_elem;
+ uint32_t m_rown; // number of rows.
+ uint32_t m_coln; // number of columns.
+ uint32_t m_rwdcnt; // number of words in a row
+ std::vector<uint32_t> m_elem;
};
-binary_matrix::binary_matrix (u32bit rown, u32bit coln)
+binary_matrix::binary_matrix (uint32_t rown, uint32_t coln)
{
m_coln = coln;
m_rown = rown;
m_rwdcnt = 1 + ((m_coln - 1) / 32);
- m_elem = std::vector<u32bit>(m_rown * m_rwdcnt);
+ m_elem = std::vector<uint32_t>(m_rown * m_rwdcnt);
}
-void binary_matrix::row_xor(u32bit a, u32bit b)
+void binary_matrix::row_xor(uint32_t a, uint32_t b)
{
- u32bit i;
+ uint32_t i;
for(i=0;i<m_rwdcnt;i++)
{
m_elem[a*m_rwdcnt+i]^=m_elem[b*m_rwdcnt+i];
@@ -77,7 +77,7 @@ void binary_matrix::row_xor(u32bit a, u32bit b)
//the matrix is reduced from LSB...(from right)
secure_vector<int> binary_matrix::row_reduced_echelon_form()
{
- u32bit i, failcnt, findrow, max=m_coln - 1;
+ uint32_t i, failcnt, findrow, max=m_coln - 1;
secure_vector<int> perm(m_coln);
for(i=0;i<m_coln;i++)
@@ -89,7 +89,7 @@ secure_vector<int> binary_matrix::row_reduced_echelon_form()
for(i=0;i<m_rown;i++,max--)
{
findrow=0;
- for(u32bit j=i;j<m_rown;j++)
+ for(uint32_t j=i;j<m_rown;j++)
{
if(coef(j,max))
{
@@ -115,7 +115,7 @@ secure_vector<int> binary_matrix::row_reduced_echelon_form()
else
{
perm[i+m_coln - m_rown] = max;
- for(u32bit j=i+1;j<m_rown;j++)//fill the column downwards with 0's
+ for(uint32_t j=i+1;j<m_rown;j++)//fill the column downwards with 0's
{
if(coef(j,(max)))
{
@@ -137,7 +137,7 @@ secure_vector<int> binary_matrix::row_reduced_echelon_form()
void randomize_support(std::vector<gf2m>& L, RandomNumberGenerator& rng)
{
- for(u32bit i = 0; i != L.size(); ++i)
+ for(uint32_t i = 0; i != L.size(); ++i)
{
gf2m rnd = random_gf2m(rng);
@@ -146,7 +146,7 @@ void randomize_support(std::vector<gf2m>& L, RandomNumberGenerator& rng)
}
}
-std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, std::shared_ptr<GF2m_Field> sp_field, u32bit code_length, u32bit t )
+std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, std::shared_ptr<GF2m_Field> sp_field, uint32_t code_length, uint32_t t )
{
//L- Support
//t- Number of errors
@@ -154,7 +154,7 @@ std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, s
//m- The extension degree of the GF
//g- The generator polynomial.
gf2m x,y;
- u32bit i,j,k,r,n;
+ uint32_t i,j,k,r,n;
std::vector<int> Laux(code_length);
n=code_length;
r=t*sp_field->get_extension_degree();
@@ -210,12 +210,12 @@ std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, s
}
}
-McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit ext_deg, u32bit code_length, u32bit t)
+McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, uint32_t ext_deg, uint32_t code_length, uint32_t t)
{
- u32bit i, j, k, l;
+ uint32_t i, j, k, l;
std::unique_ptr<binary_matrix> R;
- u32bit codimension = t * ext_deg;
+ uint32_t codimension = t * ext_deg;
if(code_length <= codimension)
{
throw Invalid_Argument("invalid McEliece parameters");
@@ -256,15 +256,15 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit e
// speed up the syndrome computation)
//
//
- std::vector<u32bit> H(bit_size_to_32bit_size(codimension) * code_length );
- u32bit* sk = H.data();
+ std::vector<uint32_t> H(bit_size_to_32bit_size(codimension) * code_length );
+ uint32_t* sk = H.data();
for (i = 0; i < code_length; ++i)
{
for (l = 0; l < t; ++l)
{
k = (l * ext_deg) / 32;
j = (l * ext_deg) % 32;
- sk[k] ^= static_cast<u32bit>(F[i].get_coef(l)) << j;
+ sk[k] ^= static_cast<uint32_t>(F[i].get_coef(l)) << j;
if (j + ext_deg > 32)
{
sk[k + 1] ^= F[i].get_coef( l) >> (32 - j);
@@ -281,7 +281,7 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit e
{
Linv[L[i]] = i;
}
- std::vector<byte> pubmat (R->m_elem.size() * 4);
+ std::vector<uint8_t> pubmat (R->m_elem.size() * 4);
for(i = 0; i < R->m_elem.size(); i++)
{
store_le(R->m_elem[i], &pubmat[i*4]);
diff --git a/src/lib/pubkey/mce/code_based_util.h b/src/lib/pubkey/mce/code_based_util.h
index 9b5395f41..ccc94c91b 100644
--- a/src/lib/pubkey/mce/code_based_util.h
+++ b/src/lib/pubkey/mce/code_based_util.h
@@ -22,9 +22,9 @@ namespace Botan {
* @return the mask 0xFFFF if tst is non-zero and 0 otherwise
*/
template<typename T>
-u16bit expand_mask_16bit(T tst)
+uint16_t expand_mask_16bit(T tst)
{
- const u16bit result = (tst != 0);
+ const uint16_t result = (tst != 0);
return ~(result - 1);
}
@@ -42,12 +42,12 @@ inline gf2m lex_to_gray(gf2m lex)
return (lex >> 1) ^ lex;
}
-inline u32bit bit_size_to_byte_size(u32bit bit_size)
+inline uint32_t bit_size_to_byte_size(uint32_t bit_size)
{
return (bit_size - 1) / 8 + 1;
}
-inline u32bit bit_size_to_32bit_size(u32bit bit_size)
+inline uint32_t bit_size_to_32bit_size(uint32_t bit_size)
{
return (bit_size - 1) / 32 + 1;
}
diff --git a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
index 74cb1c64b..a35fc7458 100644
--- a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
+++ b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
@@ -15,11 +15,11 @@ namespace Botan {
namespace {
-u32bit patch_root_array(gf2m* res_root_arr,
- u32bit res_root_arr_len,
- u32bit root_pos)
+uint32_t patch_root_array(gf2m* res_root_arr,
+ uint32_t res_root_arr_len,
+ uint32_t root_pos)
{
- volatile u32bit i;
+ volatile uint32_t i;
volatile gf2m patch_elem = 0x01;
volatile gf2m cond_mask = (root_pos == res_root_arr_len);
cond_mask = expand_mask_16bit(cond_mask);
@@ -37,18 +37,18 @@ u32bit patch_root_array(gf2m* res_root_arr,
class gf2m_decomp_rootfind_state
{
public:
- gf2m_decomp_rootfind_state(const polyn_gf2m & p_polyn, u32bit code_length);
+ gf2m_decomp_rootfind_state(const polyn_gf2m & p_polyn, uint32_t code_length);
void calc_LiK(const polyn_gf2m & sigma);
gf2m calc_Fxj_j_neq_0( const polyn_gf2m & sigma, gf2m j_gray);
void calc_next_Aij();
void calc_Ai_zero(const polyn_gf2m & sigma);
secure_vector<gf2m> find_roots(const polyn_gf2m & sigma);
- u32bit get_code_length() const { return code_length; };
- u32bit code_length;
+ uint32_t get_code_length() const { return code_length; };
+ uint32_t code_length;
secure_vector<gf2m> m_Lik; // size is outer_summands * m
secure_vector<gf2m> m_Aij; // ...
- u32bit m_outer_summands;
+ uint32_t m_outer_summands;
gf2m m_j;
gf2m m_j_gray;
gf2m m_sigma_3_l;
@@ -73,9 +73,9 @@ gf2m brootf_decomp__gray_to_lex(gf2m gray)
/**
* calculates ceil((t-4)/5) = outer_summands - 1
*/
-u32bit brootf_decomp__calc_sum_limit(u32bit t)
+uint32_t brootf_decomp__calc_sum_limit(uint32_t t)
{
- u32bit result;
+ uint32_t result;
if(t < 4)
{
return 0;
@@ -86,7 +86,7 @@ u32bit brootf_decomp__calc_sum_limit(u32bit t)
return result;
}
-gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn, u32bit the_code_length) :
+gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn, uint32_t the_code_length) :
code_length(the_code_length), m_j(0), m_j_gray(0)
{
gf2m coeff_3;
@@ -119,7 +119,7 @@ gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn,
void gf2m_decomp_rootfind_state::calc_Ai_zero(const polyn_gf2m & sigma)
{
- u32bit i;
+ uint32_t i;
/*
* this function assumes this the first gray code element is zero
*/
@@ -138,9 +138,9 @@ void gf2m_decomp_rootfind_state::calc_next_Aij()
* first thing, we declare Aij Aij_minusone and increase j.
* Case j=0 upon function entry also included, then Aij contains A_{i,j=0}.
*/
- u32bit i;
+ uint32_t i;
gf2m diff, new_j_gray;
- u32bit Lik_pos_base;
+ uint32_t Lik_pos_base;
this->m_j++;
@@ -190,11 +190,11 @@ void gf2m_decomp_rootfind_state::calc_next_Aij()
void gf2m_decomp_rootfind_state::calc_LiK(const polyn_gf2m & sigma)
{
std::shared_ptr<GF2m_Field> sp_field = sigma.get_sp_field();
- u32bit i, k, d;
+ uint32_t i, k, d;
d = sigma.get_degree();
for(k = 0; k < sp_field->get_extension_degree(); k++)
{
- u32bit Lik_pos_base = k * this->m_outer_summands;
+ uint32_t Lik_pos_base = k * this->m_outer_summands;
gf2m alpha_l_k_tt2_ttj[4];
alpha_l_k_tt2_ttj[0] = sp_field->gf_l_from_n(static_cast<gf2m>(1) << k);
alpha_l_k_tt2_ttj[1] = sp_field->gf_mul_rrr(alpha_l_k_tt2_ttj[0], alpha_l_k_tt2_ttj[0]);
@@ -203,14 +203,14 @@ void gf2m_decomp_rootfind_state::calc_LiK(const polyn_gf2m & sigma)
alpha_l_k_tt2_ttj[3] = sp_field->gf_mul_rrr(alpha_l_k_tt2_ttj[2], alpha_l_k_tt2_ttj[2]);
for(i = 0; i < this->m_outer_summands; i++)
{
- u32bit j;
- u32bit five_i = 5*i;
- u32bit Lik_pos = Lik_pos_base + i;
+ uint32_t j;
+ uint32_t five_i = 5*i;
+ uint32_t Lik_pos = Lik_pos_base + i;
this->m_Lik[Lik_pos] = 0;
for(j = 0; j <= 3; j++)
{
gf2m f, x;
- u32bit f_ind = five_i + (static_cast<u32bit>(1) << j);
+ uint32_t f_ind = five_i + (static_cast<uint32_t>(1) << j);
if(f_ind > d)
{
break;
@@ -228,7 +228,7 @@ gf2m gf2m_decomp_rootfind_state::calc_Fxj_j_neq_0( const polyn_gf2m & sigma, gf2
{
//needs the A_{ij} to compute F(x)_j
gf2m sum = 0;
- u32bit i;
+ uint32_t i;
std::shared_ptr<GF2m_Field> sp_field = sigma.get_sp_field();
const gf2m jl_gray = sp_field->gf_l_from_n(j_gray);
gf2m xl_j_tt_5 = sp_field->gf_square_rr(jl_gray);
@@ -270,7 +270,7 @@ secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & si
const int sigma_degree = sigma.get_degree();
BOTAN_ASSERT(sigma_degree > 0, "Valid sigma");
secure_vector<gf2m> result(sigma_degree);
- u32bit root_pos = 0;
+ uint32_t root_pos = 0;
this->calc_Ai_zero(sigma);
this->calc_LiK(sigma);
@@ -293,7 +293,7 @@ secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & si
root_pos++;
}
- if(this->m_j + static_cast<u32bit>(1) == this->get_code_length())
+ if(this->m_j + static_cast<uint32_t>(1) == this->get_code_length())
{
break;
}
@@ -308,7 +308,7 @@ secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & si
} // end anonymous namespace
-secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, u32bit code_length)
+secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, uint32_t code_length)
{
gf2m_decomp_rootfind_state state(polyn, code_length);
return state.find_roots(polyn);
diff --git a/src/lib/pubkey/mce/gf2m_small_m.cpp b/src/lib/pubkey/mce/gf2m_small_m.cpp
index e74e5c71f..95187c7af 100644
--- a/src/lib/pubkey/mce/gf2m_small_m.cpp
+++ b/src/lib/pubkey/mce/gf2m_small_m.cpp
@@ -94,14 +94,14 @@ const std::vector<gf2m>& log_table(size_t deg)
}
-u32bit encode_gf2m(gf2m to_enc, byte* mem)
+uint32_t encode_gf2m(gf2m to_enc, uint8_t* mem)
{
mem[0] = to_enc >> 8;
mem[1] = to_enc & 0xFF;
return sizeof(to_enc);
}
-gf2m decode_gf2m(const byte* mem)
+gf2m decode_gf2m(const uint8_t* mem)
{
gf2m result;
result = mem[0] << 8;
@@ -118,9 +118,9 @@ GF2m_Field::GF2m_Field(size_t extdeg) : m_gf_extension_degree(extdeg),
gf2m GF2m_Field::gf_div(gf2m x, gf2m y) const
{
- const s32bit sub_res = static_cast<s32bit>(gf_log(x) - static_cast<s32bit>(gf_log(y)));
- const s32bit modq_res = static_cast<s32bit>(_gf_modq_1(sub_res));
- const s32bit div_res = static_cast<s32bit>(x) ? static_cast<s32bit>(gf_exp(modq_res)) : 0;
+ const int32_t sub_res = static_cast<int32_t>(gf_log(x) - static_cast<int32_t>(gf_log(y)));
+ const int32_t modq_res = static_cast<int32_t>(_gf_modq_1(sub_res));
+ const int32_t div_res = static_cast<int32_t>(x) ? static_cast<int32_t>(gf_exp(modq_res)) : 0;
return static_cast<gf2m>(div_res);
}
diff --git a/src/lib/pubkey/mce/gf2m_small_m.h b/src/lib/pubkey/mce/gf2m_small_m.h
index 595ef3999..d49325def 100644
--- a/src/lib/pubkey/mce/gf2m_small_m.h
+++ b/src/lib/pubkey/mce/gf2m_small_m.h
@@ -17,7 +17,7 @@
namespace Botan {
-typedef u16bit gf2m;
+typedef uint16_t gf2m;
/**
* GF(2^m) field for m = [2...16]
@@ -196,7 +196,7 @@ class BOTAN_DLL GF2m_Field
}
private:
- gf2m _gf_modq_1(s32bit d) const
+ gf2m _gf_modq_1(int32_t d) const
{
/* residual modulo q-1
when -q < d < 0, we get (q-1+d)
@@ -211,9 +211,9 @@ class BOTAN_DLL GF2m_Field
const std::vector<gf2m>& m_gf_exp_table;
};
-u32bit encode_gf2m(gf2m to_enc, byte* mem);
+uint32_t encode_gf2m(gf2m to_enc, uint8_t* mem);
-gf2m decode_gf2m(const byte* mem);
+gf2m decode_gf2m(const uint8_t* mem);
}
diff --git a/src/lib/pubkey/mce/goppa_code.cpp b/src/lib/pubkey/mce/goppa_code.cpp
index cbec6302a..97cdf947e 100644
--- a/src/lib/pubkey/mce/goppa_code.cpp
+++ b/src/lib/pubkey/mce/goppa_code.cpp
@@ -16,11 +16,11 @@ namespace Botan {
namespace {
-void matrix_arr_mul(std::vector<u32bit> matrix,
- u32bit numo_rows,
- u32bit words_per_row,
- const byte* input_vec,
- u32bit* output_vec, u32bit output_vec_len)
+void matrix_arr_mul(std::vector<uint32_t> matrix,
+ uint32_t numo_rows,
+ uint32_t words_per_row,
+ const uint8_t* input_vec,
+ uint32_t* output_vec, uint32_t output_vec_len)
{
for(size_t j = 0; j < numo_rows; j++)
{
@@ -43,8 +43,8 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn,
const std::vector<gf2m> & Linv)
{
gf2m a;
- u32bit code_length = Linv.size();
- u32bit t = g.get_degree();
+ uint32_t code_length = Linv.size();
+ uint32_t t = g.get_degree();
std::shared_ptr<GF2m_Field> sp_field = g.get_sp_field();
@@ -63,13 +63,13 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn,
// compute S square root of h (using sqrtmod)
polyn_gf2m S(t - 1, g.get_sp_field());
- for(u32bit i=0;i<t;i++)
+ for(uint32_t i=0;i<t;i++)
{
a = sp_field->gf_sqrt(h.get_coef(i));
if(i & 1)
{
- for(u32bit j=0;j<t;j++)
+ for(uint32_t j=0;j<t;j++)
{
S.add_to_coef( j, sp_field->gf_mul(a, sqrtmod[i/2].get_coef(j)));
}
@@ -107,7 +107,7 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn,
size_t d = res.size();
secure_vector<gf2m> result(d);
- for(u32bit i = 0; i < d; ++i)
+ for(uint32_t i = 0; i < d; ++i)
{
gf2m current = res[i];
@@ -124,18 +124,18 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn,
}
}
-void mceliece_decrypt(secure_vector<byte>& plaintext_out,
- secure_vector<byte>& error_mask_out,
- const secure_vector<byte>& ciphertext,
+void mceliece_decrypt(secure_vector<uint8_t>& plaintext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const secure_vector<uint8_t>& ciphertext,
const McEliece_PrivateKey& key)
{
mceliece_decrypt(plaintext_out, error_mask_out, ciphertext.data(), ciphertext.size(), key);
}
void mceliece_decrypt(
- secure_vector<byte>& plaintext,
- secure_vector<byte> & error_mask,
- const byte ciphertext[],
+ secure_vector<uint8_t>& plaintext,
+ secure_vector<uint8_t> & error_mask,
+ const uint8_t ciphertext[],
size_t ciphertext_len,
const McEliece_PrivateKey & key)
{
@@ -143,7 +143,7 @@ void mceliece_decrypt(
plaintext = mceliece_decrypt(error_pos, ciphertext, ciphertext_len, key);
const size_t code_length = key.get_code_length();
- secure_vector<byte> result((code_length+7)/8);
+ secure_vector<uint8_t> result((code_length+7)/8);
for(auto&& pos : error_pos)
{
if(pos > code_length)
@@ -160,40 +160,40 @@ void mceliece_decrypt(
* @p p_err_pos_len must point to the available length of @p error_pos on input, the
* function will set it to the actual number of errors returned in the @p error_pos
* array */
-secure_vector<byte> mceliece_decrypt(
+secure_vector<uint8_t> mceliece_decrypt(
secure_vector<gf2m> & error_pos,
- const byte *ciphertext, u32bit ciphertext_len,
+ const uint8_t *ciphertext, uint32_t ciphertext_len,
const McEliece_PrivateKey & key)
{
- u32bit dimension = key.get_dimension();
- u32bit codimension = key.get_codimension();
- u32bit t = key.get_goppa_polyn().get_degree();
+ uint32_t dimension = key.get_dimension();
+ uint32_t codimension = key.get_codimension();
+ uint32_t t = key.get_goppa_polyn().get_degree();
polyn_gf2m syndrome_polyn(key.get_goppa_polyn().get_sp_field()); // init as zero polyn
const unsigned unused_pt_bits = dimension % 8;
- const byte unused_pt_bits_mask = (1 << unused_pt_bits) - 1;
+ const uint8_t unused_pt_bits_mask = (1 << unused_pt_bits) - 1;
if(ciphertext_len != (key.get_code_length()+7)/8)
{
throw Invalid_Argument("wrong size of McEliece ciphertext");
}
- u32bit cleartext_len = (key.get_message_word_bit_length()+7)/8;
+ uint32_t cleartext_len = (key.get_message_word_bit_length()+7)/8;
if(cleartext_len != bit_size_to_byte_size(dimension))
{
throw Invalid_Argument("mce-decryption: wrong length of cleartext buffer");
}
- secure_vector<u32bit> syndrome_vec(bit_size_to_32bit_size(codimension));
+ secure_vector<uint32_t> syndrome_vec(bit_size_to_32bit_size(codimension));
matrix_arr_mul(key.get_H_coeffs(),
key.get_code_length(),
bit_size_to_32bit_size(codimension),
ciphertext,
syndrome_vec.data(), syndrome_vec.size());
- secure_vector<byte> syndrome_byte_vec(bit_size_to_byte_size(codimension));
- u32bit syndrome_byte_vec_size = syndrome_byte_vec.size();
- for(u32bit i = 0; i < syndrome_byte_vec_size; i++)
+ secure_vector<uint8_t> syndrome_byte_vec(bit_size_to_byte_size(codimension));
+ uint32_t syndrome_byte_vec_size = syndrome_byte_vec.size();
+ for(uint32_t i = 0; i < syndrome_byte_vec_size; i++)
{
syndrome_byte_vec[i] = syndrome_vec[i/4] >> (8* (i % 4));
}
@@ -203,12 +203,12 @@ secure_vector<byte> mceliece_decrypt(
syndrome_polyn.get_degree();
error_pos = goppa_decode(syndrome_polyn, key.get_goppa_polyn(), key.get_sqrtmod(), key.get_Linv());
- u32bit nb_err = error_pos.size();
+ uint32_t nb_err = error_pos.size();
- secure_vector<byte> cleartext(cleartext_len);
+ secure_vector<uint8_t> cleartext(cleartext_len);
copy_mem(cleartext.data(), ciphertext, cleartext_len);
- for(u32bit i = 0; i < nb_err; i++)
+ for(uint32_t i = 0; i < nb_err; i++)
{
gf2m current = error_pos[i];
diff --git a/src/lib/pubkey/mce/mce_internal.h b/src/lib/pubkey/mce/mce_internal.h
index fb995e758..81fa970bb 100644
--- a/src/lib/pubkey/mce/mce_internal.h
+++ b/src/lib/pubkey/mce/mce_internal.h
@@ -19,32 +19,32 @@
namespace Botan {
-void mceliece_decrypt(secure_vector<byte>& plaintext_out,
- secure_vector<byte>& error_mask_out,
- const byte ciphertext[],
+void mceliece_decrypt(secure_vector<uint8_t>& plaintext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const uint8_t ciphertext[],
size_t ciphertext_len,
const McEliece_PrivateKey& key);
-void mceliece_decrypt(secure_vector<byte>& plaintext_out,
- secure_vector<byte>& error_mask_out,
- const secure_vector<byte>& ciphertext,
+void mceliece_decrypt(secure_vector<uint8_t>& plaintext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const secure_vector<uint8_t>& ciphertext,
const McEliece_PrivateKey& key);
-secure_vector<byte> mceliece_decrypt(
+secure_vector<uint8_t> mceliece_decrypt(
secure_vector<gf2m> & error_pos,
- const byte *ciphertext, u32bit ciphertext_len,
+ const uint8_t *ciphertext, uint32_t ciphertext_len,
const McEliece_PrivateKey & key);
-void mceliece_encrypt(secure_vector<byte>& ciphertext_out,
- secure_vector<byte>& error_mask_out,
- const secure_vector<byte>& plaintext,
+void mceliece_encrypt(secure_vector<uint8_t>& ciphertext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const secure_vector<uint8_t>& plaintext,
const McEliece_PublicKey& key,
RandomNumberGenerator& rng);
McEliece_PrivateKey generate_mceliece_key(RandomNumberGenerator &rng,
- u32bit ext_deg,
- u32bit code_length,
- u32bit t);
+ uint32_t ext_deg,
+ uint32_t code_length,
+ uint32_t t);
}
diff --git a/src/lib/pubkey/mce/mceliece.cpp b/src/lib/pubkey/mce/mceliece.cpp
index 7617ff11f..fd985c032 100644
--- a/src/lib/pubkey/mce/mceliece.cpp
+++ b/src/lib/pubkey/mce/mceliece.cpp
@@ -19,10 +19,10 @@ namespace Botan {
namespace {
-secure_vector<byte> concat_vectors(const secure_vector<byte>& a, const secure_vector<byte>& b,
- u32bit dimension, u32bit codimension)
+secure_vector<uint8_t> concat_vectors(const secure_vector<uint8_t>& a, const secure_vector<uint8_t>& b,
+ uint32_t dimension, uint32_t codimension)
{
- secure_vector<byte> x(bit_size_to_byte_size(dimension) + bit_size_to_byte_size(codimension));
+ secure_vector<uint8_t> x(bit_size_to_byte_size(dimension) + bit_size_to_byte_size(codimension));
const size_t final_bits = dimension % 8;
@@ -35,31 +35,31 @@ secure_vector<byte> concat_vectors(const secure_vector<byte>& a, const secure_ve
else
{
copy_mem(&x[0], a.data(), (dimension / 8));
- u32bit l = dimension / 8;
- x[l] = static_cast<byte>(a[l] & ((1 << final_bits) - 1));
+ uint32_t l = dimension / 8;
+ x[l] = static_cast<uint8_t>(a[l] & ((1 << final_bits) - 1));
- for(u32bit k = 0; k < codimension / 8; ++k)
+ for(uint32_t k = 0; k < codimension / 8; ++k)
{
- x[l] ^= static_cast<byte>(b[k] << final_bits);
+ x[l] ^= static_cast<uint8_t>(b[k] << final_bits);
++l;
- x[l] = static_cast<byte>(b[k] >> (8 - final_bits));
+ x[l] = static_cast<uint8_t>(b[k] >> (8 - final_bits));
}
- x[l] ^= static_cast<byte>(b[codimension/8] << final_bits);
+ x[l] ^= static_cast<uint8_t>(b[codimension/8] << final_bits);
}
return x;
}
-secure_vector<byte> mult_by_pubkey(const secure_vector<byte>& cleartext,
- std::vector<byte> const& public_matrix,
- u32bit code_length, u32bit t)
+secure_vector<uint8_t> mult_by_pubkey(const secure_vector<uint8_t>& cleartext,
+ std::vector<uint8_t> const& public_matrix,
+ uint32_t code_length, uint32_t t)
{
- const u32bit ext_deg = ceil_log2(code_length);
- const u32bit codimension = ext_deg * t;
- const u32bit dimension = code_length - codimension;
- secure_vector<byte> cR(bit_size_to_32bit_size(codimension) * sizeof(u32bit));
+ const uint32_t ext_deg = ceil_log2(code_length);
+ const uint32_t codimension = ext_deg * t;
+ const uint32_t dimension = code_length - codimension;
+ secure_vector<uint8_t> cR(bit_size_to_32bit_size(codimension) * sizeof(uint32_t));
- const byte* pt = public_matrix.data();
+ const uint8_t* pt = public_matrix.data();
for(size_t i = 0; i < dimension / 8; ++i)
{
@@ -82,16 +82,16 @@ secure_vector<byte> mult_by_pubkey(const secure_vector<byte>& cleartext,
pt += cR.size();
}
- secure_vector<byte> ciphertext = concat_vectors(cleartext, cR, dimension, codimension);
+ secure_vector<uint8_t> ciphertext = concat_vectors(cleartext, cR, dimension, codimension);
ciphertext.resize((code_length+7)/8);
return ciphertext;
}
-secure_vector<byte> create_random_error_vector(unsigned code_length,
+secure_vector<uint8_t> create_random_error_vector(unsigned code_length,
unsigned error_weight,
RandomNumberGenerator& rng)
{
- secure_vector<byte> result((code_length+7)/8);
+ secure_vector<uint8_t> result((code_length+7)/8);
size_t bits_set = 0;
@@ -101,7 +101,7 @@ secure_vector<byte> create_random_error_vector(unsigned code_length,
const size_t byte_pos = x / 8, bit_pos = x % 8;
- const byte mask = (1 << bit_pos);
+ const uint8_t mask = (1 << bit_pos);
if(result[byte_pos] & mask)
continue; // already set this bit
@@ -115,15 +115,15 @@ secure_vector<byte> create_random_error_vector(unsigned code_length,
}
-void mceliece_encrypt(secure_vector<byte>& ciphertext_out,
- secure_vector<byte>& error_mask_out,
- const secure_vector<byte>& plaintext,
+void mceliece_encrypt(secure_vector<uint8_t>& ciphertext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const secure_vector<uint8_t>& plaintext,
const McEliece_PublicKey& key,
RandomNumberGenerator& rng)
{
- secure_vector<byte> error_mask = create_random_error_vector(key.get_code_length(), key.get_t(), rng);
+ secure_vector<uint8_t> error_mask = create_random_error_vector(key.get_code_length(), key.get_t(), rng);
- secure_vector<byte> ciphertext = mult_by_pubkey(plaintext, key.get_public_matrix(),
+ secure_vector<uint8_t> ciphertext = mult_by_pubkey(plaintext, key.get_public_matrix(),
key.get_code_length(), key.get_t());
ciphertext ^= error_mask;
diff --git a/src/lib/pubkey/mce/mceliece.h b/src/lib/pubkey/mce/mceliece.h
index 0731e0c68..58c242360 100644
--- a/src/lib/pubkey/mce/mceliece.h
+++ b/src/lib/pubkey/mce/mceliece.h
@@ -21,9 +21,9 @@ namespace Botan {
class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
{
public:
- explicit McEliece_PublicKey(const std::vector<byte>& key_bits);
+ explicit McEliece_PublicKey(const std::vector<uint8_t>& key_bits);
- McEliece_PublicKey(std::vector<byte> const& pub_matrix, u32bit the_t, u32bit the_code_length) :
+ McEliece_PublicKey(std::vector<uint8_t> const& pub_matrix, uint32_t the_t, uint32_t the_code_length) :
m_public_matrix(pub_matrix),
m_t(the_t),
m_code_length(the_code_length)
@@ -31,7 +31,7 @@ class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
McEliece_PublicKey(const McEliece_PublicKey& other);
- secure_vector<byte> random_plaintext_element(RandomNumberGenerator& rng) const;
+ secure_vector<uint8_t> random_plaintext_element(RandomNumberGenerator& rng) const;
std::string algo_name() const override { return "McEliece"; }
@@ -40,15 +40,15 @@ class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
size_t key_length() const override;
size_t estimated_strength() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
bool check_key(RandomNumberGenerator&, bool) const override
{ return true; }
- u32bit get_t() const { return m_t; }
- u32bit get_code_length() const { return m_code_length; }
- u32bit get_message_word_bit_length() const;
- const std::vector<byte>& get_public_matrix() const { return m_public_matrix; }
+ uint32_t get_t() const { return m_t; }
+ uint32_t get_code_length() const { return m_code_length; }
+ uint32_t get_message_word_bit_length() const;
+ const std::vector<uint8_t>& get_public_matrix() const { return m_public_matrix; }
bool operator==(const McEliece_PublicKey& other) const;
bool operator!=(const McEliece_PublicKey& other) const { return !(*this == other); }
@@ -61,9 +61,9 @@ class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
protected:
McEliece_PublicKey() : m_t(0), m_code_length(0) {}
- std::vector<byte> m_public_matrix;
- u32bit m_t;
- u32bit m_code_length;
+ std::vector<uint8_t> m_public_matrix;
+ uint32_t m_t;
+ uint32_t m_code_length;
};
class BOTAN_DLL McEliece_PrivateKey : public virtual McEliece_PublicKey,
@@ -85,26 +85,26 @@ class BOTAN_DLL McEliece_PrivateKey : public virtual McEliece_PublicKey,
*/
McEliece_PrivateKey(RandomNumberGenerator& rng, size_t code_length, size_t t);
- explicit McEliece_PrivateKey(const secure_vector<byte>& key_bits);
+ explicit McEliece_PrivateKey(const secure_vector<uint8_t>& key_bits);
McEliece_PrivateKey(polyn_gf2m const& goppa_polyn,
- std::vector<u32bit> const& parity_check_matrix_coeffs,
+ std::vector<uint32_t> const& parity_check_matrix_coeffs,
std::vector<polyn_gf2m> const& square_root_matrix,
std::vector<gf2m> const& inverse_support,
- std::vector<byte> const& public_matrix );
+ std::vector<uint8_t> const& public_matrix );
bool check_key(RandomNumberGenerator& rng, bool strong) const override;
polyn_gf2m const& get_goppa_polyn() const { return m_g; }
- std::vector<u32bit> const& get_H_coeffs() const { return m_coeffs; }
+ std::vector<uint32_t> const& get_H_coeffs() const { return m_coeffs; }
std::vector<gf2m> const& get_Linv() const { return m_Linv; }
std::vector<polyn_gf2m> const& get_sqrtmod() const { return m_sqrtmod; }
- inline u32bit get_dimension() const { return m_dimension; }
+ inline uint32_t get_dimension() const { return m_dimension; }
- inline u32bit get_codimension() const { return m_codimension; }
+ inline uint32_t get_codimension() const { return m_codimension; }
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
bool operator==(const McEliece_PrivateKey & other) const;
@@ -118,10 +118,10 @@ class BOTAN_DLL McEliece_PrivateKey : public virtual McEliece_PublicKey,
polyn_gf2m m_g;
std::vector<polyn_gf2m> m_sqrtmod;
std::vector<gf2m> m_Linv;
- std::vector<u32bit> m_coeffs;
+ std::vector<uint32_t> m_coeffs;
- u32bit m_codimension;
- u32bit m_dimension;
+ uint32_t m_codimension;
+ uint32_t m_dimension;
};
/**
diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp
index 409688153..798f7a91f 100644
--- a/src/lib/pubkey/mce/mceliece_key.cpp
+++ b/src/lib/pubkey/mce/mceliece_key.cpp
@@ -21,10 +21,10 @@
namespace Botan {
McEliece_PrivateKey::McEliece_PrivateKey(polyn_gf2m const& goppa_polyn,
- std::vector<u32bit> const& parity_check_matrix_coeffs,
+ std::vector<uint32_t> const& parity_check_matrix_coeffs,
std::vector<polyn_gf2m> const& square_root_matrix,
std::vector<gf2m> const& inverse_support,
- std::vector<byte> const& public_matrix) :
+ std::vector<uint8_t> const& public_matrix) :
McEliece_PublicKey(public_matrix, goppa_polyn.get_degree(), inverse_support.size()),
m_g(goppa_polyn),
m_sqrtmod(square_root_matrix),
@@ -37,27 +37,27 @@ McEliece_PrivateKey::McEliece_PrivateKey(polyn_gf2m const& goppa_polyn,
McEliece_PrivateKey::McEliece_PrivateKey(RandomNumberGenerator& rng, size_t code_length, size_t t)
{
- u32bit ext_deg = ceil_log2(code_length);
+ uint32_t ext_deg = ceil_log2(code_length);
*this = generate_mceliece_key(rng, ext_deg, code_length, t);
}
-u32bit McEliece_PublicKey::get_message_word_bit_length() const
+uint32_t McEliece_PublicKey::get_message_word_bit_length() const
{
- u32bit codimension = ceil_log2(m_code_length) * m_t;
+ uint32_t codimension = ceil_log2(m_code_length) * m_t;
return m_code_length - codimension;
}
-secure_vector<byte> McEliece_PublicKey::random_plaintext_element(RandomNumberGenerator& rng) const
+secure_vector<uint8_t> McEliece_PublicKey::random_plaintext_element(RandomNumberGenerator& rng) const
{
const size_t bits = get_message_word_bit_length();
- secure_vector<byte> plaintext((bits+7)/8);
+ secure_vector<uint8_t> plaintext((bits+7)/8);
rng.randomize(plaintext.data(), plaintext.size());
// unset unused bits in the last plaintext byte
- if(u32bit used = bits % 8)
+ if(uint32_t used = bits % 8)
{
- const byte mask = (1 << used) - 1;
+ const uint8_t mask = (1 << used) - 1;
plaintext[plaintext.size() - 1] &= mask;
}
@@ -66,10 +66,10 @@ secure_vector<byte> McEliece_PublicKey::random_plaintext_element(RandomNumberGen
AlgorithmIdentifier McEliece_PublicKey::algorithm_identifier() const
{
- return AlgorithmIdentifier(get_oid(), std::vector<byte>());
+ return AlgorithmIdentifier(get_oid(), std::vector<uint8_t>());
}
-std::vector<byte> McEliece_PublicKey::public_key_bits() const
+std::vector<uint8_t> McEliece_PublicKey::public_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -99,7 +99,7 @@ size_t McEliece_PublicKey::estimated_strength() const
return mceliece_work_factor(m_code_length, m_t);
}
-McEliece_PublicKey::McEliece_PublicKey(const std::vector<byte>& key_bits)
+McEliece_PublicKey::McEliece_PublicKey(const std::vector<uint8_t>& key_bits)
{
BER_Decoder dec(key_bits);
size_t n;
@@ -115,7 +115,7 @@ McEliece_PublicKey::McEliece_PublicKey(const std::vector<byte>& key_bits)
m_code_length = n;
}
-secure_vector<byte> McEliece_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> McEliece_PrivateKey::private_key_bits() const
{
DER_Encoder enc;
enc.start_cons(SEQUENCE)
@@ -126,20 +126,20 @@ secure_vector<byte> McEliece_PrivateKey::private_key_bits() const
.encode(m_public_matrix, OCTET_STRING)
.encode(m_g.encode(), OCTET_STRING); // g as octet string
enc.start_cons(SEQUENCE);
- for(u32bit i = 0; i < m_sqrtmod.size(); i++)
+ for(uint32_t i = 0; i < m_sqrtmod.size(); i++)
{
enc.encode(m_sqrtmod[i].encode(), OCTET_STRING);
}
enc.end_cons();
- secure_vector<byte> enc_support;
- for(u32bit i = 0; i < m_Linv.size(); i++)
+ secure_vector<uint8_t> enc_support;
+ for(uint32_t i = 0; i < m_Linv.size(); i++)
{
enc_support.push_back(m_Linv[i] >> 8);
enc_support.push_back(m_Linv[i]);
}
enc.encode(enc_support, OCTET_STRING);
- secure_vector<byte> enc_H;
- for(u32bit i = 0; i < m_coeffs.size(); i++)
+ secure_vector<uint8_t> enc_H;
+ for(uint32_t i = 0; i < m_coeffs.size(); i++)
{
enc_H.push_back(m_coeffs[i] >> 24);
enc_H.push_back(m_coeffs[i] >> 16);
@@ -153,14 +153,14 @@ secure_vector<byte> McEliece_PrivateKey::private_key_bits() const
bool McEliece_PrivateKey::check_key(RandomNumberGenerator& rng, bool) const
{
- const secure_vector<byte> plaintext = this->random_plaintext_element(rng);
+ const secure_vector<uint8_t> plaintext = this->random_plaintext_element(rng);
- secure_vector<byte> ciphertext;
- secure_vector<byte> errors;
+ secure_vector<uint8_t> ciphertext;
+ secure_vector<uint8_t> errors;
mceliece_encrypt(ciphertext, errors, plaintext, *this, rng);
- secure_vector<byte> plaintext_out;
- secure_vector<byte> errors_out;
+ secure_vector<uint8_t> plaintext_out;
+ secure_vector<uint8_t> errors_out;
mceliece_decrypt(plaintext_out, errors_out, ciphertext, *this);
if(errors != errors_out || plaintext != plaintext_out)
@@ -169,10 +169,10 @@ bool McEliece_PrivateKey::check_key(RandomNumberGenerator& rng, bool) const
return true;
}
-McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
+McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<uint8_t>& key_bits)
{
size_t n, t;
- secure_vector<byte> g_enc;
+ secure_vector<uint8_t> g_enc;
BER_Decoder dec_base(key_bits);
BER_Decoder dec = dec_base.start_cons(SEQUENCE)
.start_cons(SEQUENCE)
@@ -185,7 +185,7 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
if(t == 0 || n == 0)
throw Decoding_Error("invalid McEliece parameters");
- u32bit ext_deg = ceil_log2(n);
+ uint32_t ext_deg = ceil_log2(n);
m_code_length = n;
m_t = t;
m_codimension = (ext_deg * t);
@@ -198,9 +198,9 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
throw Decoding_Error("degree of decoded Goppa polynomial is incorrect");
}
BER_Decoder dec2 = dec.start_cons(SEQUENCE);
- for(u32bit i = 0; i < t/2; i++)
+ for(uint32_t i = 0; i < t/2; i++)
{
- secure_vector<byte> sqrt_enc;
+ secure_vector<uint8_t> sqrt_enc;
dec2.decode(sqrt_enc, OCTET_STRING);
while(sqrt_enc.size() < (t*2))
{
@@ -214,7 +214,7 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
}
m_sqrtmod.push_back(polyn_gf2m(sqrt_enc, sp_field));
}
- secure_vector<byte> enc_support;
+ secure_vector<uint8_t> enc_support;
BER_Decoder dec3 = dec2.end_cons()
.decode(enc_support, OCTET_STRING);
if(enc_support.size() % 2)
@@ -225,12 +225,12 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
{
throw Decoding_Error("encoded support has length different from code length");
}
- for(u32bit i = 0; i < n*2; i+=2)
+ for(uint32_t i = 0; i < n*2; i+=2)
{
gf2m el = (enc_support[i] << 8) | enc_support[i+1];
m_Linv.push_back(el);
}
- secure_vector<byte> enc_H;
+ secure_vector<uint8_t> enc_H;
dec3.decode(enc_H, OCTET_STRING)
.end_cons();
if(enc_H.size() % 4)
@@ -242,9 +242,9 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
throw Decoding_Error("encoded parity check matrix has wrong length");
}
- for(u32bit i = 0; i < enc_H.size(); i+=4)
+ for(uint32_t i = 0; i < enc_H.size(); i+=4)
{
- u32bit coeff = (enc_H[i] << 24) | (enc_H[i+1] << 16) | (enc_H[i+2] << 8) | enc_H[i+3];
+ uint32_t coeff = (enc_H[i] << 24) | (enc_H[i+1] << 16) | (enc_H[i+2] << 8) | enc_H[i+3];
m_coeffs.push_back(coeff);
}
@@ -310,13 +310,13 @@ class MCE_KEM_Encryptor : public PK_Ops::KEM_Encryption_with_KDF
KEM_Encryption_with_KDF(kdf), m_key(key) {}
private:
- void raw_kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& raw_shared_key,
+ void raw_kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& raw_shared_key,
Botan::RandomNumberGenerator& rng) override
{
- secure_vector<byte> plaintext = m_key.random_plaintext_element(rng);
+ secure_vector<uint8_t> plaintext = m_key.random_plaintext_element(rng);
- secure_vector<byte> ciphertext, error_mask;
+ secure_vector<uint8_t> ciphertext, error_mask;
mceliece_encrypt(ciphertext, error_mask, plaintext, m_key, rng);
raw_shared_key.clear();
@@ -338,13 +338,13 @@ class MCE_KEM_Decryptor : public PK_Ops::KEM_Decryption_with_KDF
KEM_Decryption_with_KDF(kdf), m_key(key) {}
private:
- secure_vector<byte>
- raw_kem_decrypt(const byte encap_key[], size_t len) override
+ secure_vector<uint8_t>
+ raw_kem_decrypt(const uint8_t encap_key[], size_t len) override
{
- secure_vector<byte> plaintext, error_mask;
+ secure_vector<uint8_t> plaintext, error_mask;
mceliece_decrypt(plaintext, error_mask, encap_key, len, m_key);
- secure_vector<byte> output;
+ secure_vector<uint8_t> output;
output.reserve(plaintext.size() + error_mask.size());
output.insert(output.end(), plaintext.begin(), plaintext.end());
output.insert(output.end(), error_mask.begin(), error_mask.end());
diff --git a/src/lib/pubkey/mce/polyn_gf2m.cpp b/src/lib/pubkey/mce/polyn_gf2m.cpp
index 2815181c1..f4fd88f5d 100644
--- a/src/lib/pubkey/mce/polyn_gf2m.cpp
+++ b/src/lib/pubkey/mce/polyn_gf2m.cpp
@@ -30,7 +30,7 @@ gf2m generate_gf2m_mask(gf2m a)
/**
* number of leading zeros
*/
-unsigned nlz_16bit(u16bit x)
+unsigned nlz_16bit(uint16_t x)
{
unsigned n;
if(x == 0) return 16;
@@ -47,8 +47,8 @@ int polyn_gf2m::calc_degree_secure() const
{
int i = this->coeff.size() - 1;
int result = 0;
- u32bit found_mask = 0;
- u32bit tracker_mask = 0xffff;
+ uint32_t found_mask = 0;
+ uint32_t tracker_mask = 0xffff;
for( ; i >= 0; i--)
{
found_mask = expand_mask_16bit(this->coeff[i]);
@@ -63,9 +63,9 @@ int polyn_gf2m::calc_degree_secure() const
gf2m random_gf2m(RandomNumberGenerator& rng)
{
- byte b[2];
+ uint8_t b[2];
rng.randomize(b, sizeof(b));
- return make_u16bit(b[1], b[0]);
+ return make_uint16(b[1], b[0]);
}
gf2m random_code_element(unsigned code_length, RandomNumberGenerator& rng)
@@ -118,12 +118,12 @@ std::string polyn_gf2m::to_string() const
/**
* doesn't save coefficients:
*/
-void polyn_gf2m::realloc(u32bit new_size)
+void polyn_gf2m::realloc(uint32_t new_size)
{
this->coeff = secure_vector<gf2m>(new_size);
}
-polyn_gf2m::polyn_gf2m(const byte* mem, u32bit mem_len, std::shared_ptr<GF2m_Field> sp_field)
+polyn_gf2m::polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2m_Field> sp_field)
:msp_field(sp_field)
{
if(mem_len % sizeof(gf2m))
@@ -131,15 +131,15 @@ polyn_gf2m::polyn_gf2m(const byte* mem, u32bit mem_len, std::shared_ptr<GF2m_Fie
throw new Botan::Decoding_Error("illegal length of memory to decode ");
}
- u32bit size = (mem_len / sizeof(this->coeff[0])) ;
+ uint32_t size = (mem_len / sizeof(this->coeff[0])) ;
this->coeff = secure_vector<gf2m>(size);
this->m_deg = -1;
- for(u32bit i = 0; i < size; i++)
+ for(uint32_t i = 0; i < size; i++)
{
this->coeff[i] = decode_gf2m(mem);
mem += sizeof(this->coeff[0]);
}
- for(u32bit i = 0; i < size; i++)
+ for(uint32_t i = 0; i < size; i++)
{
if(this->coeff[i] >= (1 << sp_field->get_extension_degree()))
{
@@ -156,12 +156,12 @@ polyn_gf2m::polyn_gf2m( std::shared_ptr<GF2m_Field> sp_field )
msp_field(sp_field)
{}
-polyn_gf2m::polyn_gf2m(int degree, const unsigned char* mem, u32bit mem_byte_len, std::shared_ptr<GF2m_Field> sp_field)
+polyn_gf2m::polyn_gf2m(int degree, const unsigned char* mem, uint32_t mem_byte_len, std::shared_ptr<GF2m_Field> sp_field)
:msp_field(sp_field)
{
- u32bit j, k, l;
+ uint32_t j, k, l;
gf2m a;
- u32bit polyn_size;
+ uint32_t polyn_size;
polyn_size = degree + 1;
if(polyn_size * sp_field->get_extension_degree() > 8 * mem_byte_len)
{
@@ -191,12 +191,12 @@ polyn_gf2m::polyn_gf2m(int degree, const unsigned char* mem, u32bit mem_byte_le
}
#if 0
-void polyn_gf2m::encode(u32bit min_numo_coeffs, byte* mem, u32bit mem_len) const
+void polyn_gf2m::encode(uint32_t min_numo_coeffs, uint8_t* mem, uint32_t mem_len) const
{
- u32bit i;
- u32bit numo_coeffs, needed_size;
+ uint32_t i;
+ uint32_t numo_coeffs, needed_size;
this->get_degree();
- numo_coeffs = (min_numo_coeffs > static_cast<u32bit>(this->m_deg+1)) ? min_numo_coeffs : this->m_deg+1;
+ numo_coeffs = (min_numo_coeffs > static_cast<uint32_t>(this->m_deg+1)) ? min_numo_coeffs : this->m_deg+1;
needed_size = sizeof(this->coeff[0]) * numo_coeffs;
if(mem_len < needed_size)
{
@@ -206,7 +206,7 @@ void polyn_gf2m::encode(u32bit min_numo_coeffs, byte* mem, u32bit mem_len) const
for(i = 0; i < numo_coeffs; i++)
{
gf2m to_enc;
- if(i >= static_cast<u32bit>(this->m_deg+1))
+ if(i >= static_cast<uint32_t>(this->m_deg+1))
{
/* encode a zero */
to_enc = 0;
@@ -295,10 +295,10 @@ std::vector<polyn_gf2m> polyn_gf2m::sqmod_init(const polyn_gf2m & g)
if(signed_deg <= 0)
throw Invalid_Argument("cannot compute sqmod for such low degree");
- const u32bit d = static_cast<u32bit>(signed_deg);
- u32bit t = g.m_deg;
+ const uint32_t d = static_cast<uint32_t>(signed_deg);
+ uint32_t t = g.m_deg;
// create t zero polynomials
- u32bit i;
+ uint32_t i;
for (i = 0; i < t; ++i)
{
sq.push_back(polyn_gf2m(t+1, g.get_sp_field()));
@@ -428,16 +428,16 @@ void polyn_gf2m::degppf(const polyn_gf2m & g, int* p_result)
}
-void polyn_gf2m::patchup_deg_secure( u32bit trgt_deg, volatile gf2m patch_elem)
+void polyn_gf2m::patchup_deg_secure( uint32_t trgt_deg, volatile gf2m patch_elem)
{
- u32bit i;
+ uint32_t i;
if(this->coeff.size() < trgt_deg)
{
return;
}
for(i = 0; i < this->coeff.size(); i++)
{
- u32bit equal, equal_mask;
+ uint32_t equal, equal_mask;
this->coeff[i] |= patch_elem;
equal = (i == trgt_deg);
equal_mask = expand_mask_16bit(equal);
@@ -539,7 +539,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
if(break_deg == 1) /* syndrome inversion */
{
volatile gf2m fake_elem = 0x00;
- volatile u32bit trgt_deg = 0;
+ volatile uint32_t trgt_deg = 0;
r0.calc_degree_secure();
u0.calc_degree_secure();
/**
@@ -559,7 +559,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
*/
if(u0.get_degree() == 4)
{
- u32bit mask = 0;
+ uint32_t mask = 0;
/**
* Condition that the EEA would break now
*/
@@ -587,7 +587,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
}
else if(u0.get_degree() == 6)
{
- u32bit mask = 0;
+ uint32_t mask = 0;
int cond_r= r0.get_degree() == 0;
int cond_u1 = msp_field->gf_mul(u0.coeff[1], msp_field->gf_inv(r0.coeff[0])) == 1;
int cond_u3 = u0.coeff[3] == 0;
@@ -601,7 +601,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
}
else if(u0.get_degree() == 8)
{
- u32bit mask = 0;
+ uint32_t mask = 0;
int cond_r= r0.get_degree() == 0;
int cond_u1 = msp_field->gf_mul(u0[1], msp_field->gf_inv(r0[0])) == 1;
int cond_u3 = u0.coeff[3] == 0;
@@ -677,8 +677,8 @@ void polyn_gf2m::poly_shiftmod( const polyn_gf2m & g)
std::vector<polyn_gf2m> polyn_gf2m::sqrt_mod_init(const polyn_gf2m & g)
{
- u32bit i, t;
- u32bit nb_polyn_sqrt_mat;
+ uint32_t i, t;
+ uint32_t nb_polyn_sqrt_mat;
std::shared_ptr<GF2m_Field> msp_field = g.msp_field;
std::vector<polyn_gf2m> result;
t = g.get_degree();
@@ -753,14 +753,14 @@ std::vector<polyn_gf2m> syndrome_init(polyn_gf2m const& generator, std::vector<g
return result;
}
-polyn_gf2m::polyn_gf2m(const secure_vector<byte>& encoded, std::shared_ptr<GF2m_Field> sp_field )
+polyn_gf2m::polyn_gf2m(const secure_vector<uint8_t>& encoded, std::shared_ptr<GF2m_Field> sp_field )
:msp_field(sp_field)
{
if(encoded.size() % 2)
{
throw Decoding_Error("encoded polynomial has odd length");
}
- for(u32bit i = 0; i < encoded.size(); i += 2)
+ for(uint32_t i = 0; i < encoded.size(); i += 2)
{
gf2m el = (encoded[i] << 8) | encoded[i + 1];
coeff.push_back(el);
@@ -768,9 +768,9 @@ polyn_gf2m::polyn_gf2m(const secure_vector<byte>& encoded, std::shared_ptr<GF2m_
get_degree();
}
-secure_vector<byte> polyn_gf2m::encode() const
+secure_vector<uint8_t> polyn_gf2m::encode() const
{
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
if(m_deg < 1)
{
@@ -779,7 +779,7 @@ secure_vector<byte> polyn_gf2m::encode() const
return result;
}
- u32bit len = m_deg+1;
+ uint32_t len = m_deg+1;
for(unsigned i = 0; i < len; i++)
{
// "big endian" encoding of the GF(2^m) elements
diff --git a/src/lib/pubkey/mce/polyn_gf2m.h b/src/lib/pubkey/mce/polyn_gf2m.h
index 73e495fba..0782406ea 100644
--- a/src/lib/pubkey/mce/polyn_gf2m.h
+++ b/src/lib/pubkey/mce/polyn_gf2m.h
@@ -33,7 +33,7 @@ struct polyn_gf2m
:m_deg(-1)
{};
- polyn_gf2m(const secure_vector<byte>& encoded, std::shared_ptr<GF2m_Field> sp_field );
+ polyn_gf2m(const secure_vector<uint8_t>& encoded, std::shared_ptr<GF2m_Field> sp_field );
polyn_gf2m& operator=(const polyn_gf2m&) = default;
@@ -57,7 +57,7 @@ struct polyn_gf2m
void swap(polyn_gf2m& other);
- secure_vector<byte> encode() const;
+ secure_vector<uint8_t> encode() const;
/**
* create zero polynomial with reservation of space for a degree d polynomial
*/
@@ -82,14 +82,14 @@ struct polyn_gf2m
gf2m get_lead_coef() const { return coeff[m_deg]; }
- gf2m get_coef(u32bit i) const { return coeff[i]; }
+ gf2m get_coef(uint32_t i) const { return coeff[i]; }
- inline void set_coef(u32bit i, gf2m v)
+ inline void set_coef(uint32_t i, gf2m v)
{
coeff[i] = v;
};
- inline void add_to_coef(u32bit i, gf2m v)
+ inline void add_to_coef(uint32_t i, gf2m v)
{
coeff[i] = coeff[i] ^ v;
}
@@ -97,14 +97,14 @@ struct polyn_gf2m
std::string to_string() const;
/** decode a polynomial from memory: **/
- polyn_gf2m(const byte* mem, u32bit mem_len, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2m_Field> sp_field);
// remove one! ^v!
/**
* create a polynomial from memory area (encoded)
*/
- polyn_gf2m(int degree, const unsigned char* mem, u32bit mem_byte_len, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(int degree, const unsigned char* mem, uint32_t mem_byte_len, std::shared_ptr<GF2m_Field> sp_field);
- void encode(u32bit min_numo_coeffs, byte* mem, u32bit mem_len) const;
+ void encode(uint32_t min_numo_coeffs, uint8_t* mem, uint32_t mem_len) const;
int get_degree() const;
@@ -130,14 +130,14 @@ struct polyn_gf2m
const polyn_gf2m & g,
int break_deg);
- void patchup_deg_secure( u32bit trgt_deg, volatile gf2m patch_elem);
+ void patchup_deg_secure( uint32_t trgt_deg, volatile gf2m patch_elem);
private:
void set_degree(int d) { m_deg = d; }
void poly_shiftmod( const polyn_gf2m & g);
- void realloc(u32bit new_size);
+ void realloc(uint32_t new_size);
static polyn_gf2m gcd(polyn_gf2m const& p1, polyn_gf2m const& p2);
/**
@@ -166,7 +166,7 @@ std::vector<polyn_gf2m> syndrome_init(polyn_gf2m const& generator, std::vector<g
* Find the roots of a polynomial over GF(2^m) using the method by Federenko
* et al.
*/
-secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, u32bit code_length);
+secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, uint32_t code_length);
}
diff --git a/src/lib/pubkey/mceies/mceies.cpp b/src/lib/pubkey/mceies/mceies.cpp
index 253e9ddee..e50df3156 100644
--- a/src/lib/pubkey/mceies/mceies.cpp
+++ b/src/lib/pubkey/mceies/mceies.cpp
@@ -14,14 +14,14 @@ namespace Botan {
namespace {
-secure_vector<byte> aead_key(const secure_vector<byte>& mk,
+secure_vector<uint8_t> aead_key(const secure_vector<uint8_t>& mk,
const AEAD_Mode& aead)
{
// Fold the key as required for the AEAD mode in use
if(aead.valid_keylength(mk.size()))
return mk;
- secure_vector<byte> r(aead.key_spec().maximum_keylength());
+ secure_vector<uint8_t> r(aead.key_spec().maximum_keylength());
for(size_t i = 0; i != mk.size(); ++i)
r[i % r.size()] ^= mk[i];
return r;
@@ -29,16 +29,16 @@ secure_vector<byte> aead_key(const secure_vector<byte>& mk,
}
-secure_vector<byte>
+secure_vector<uint8_t>
mceies_encrypt(const McEliece_PublicKey& pubkey,
- const byte pt[], size_t pt_len,
- const byte ad[], size_t ad_len,
+ const uint8_t pt[], size_t pt_len,
+ const uint8_t ad[], size_t ad_len,
RandomNumberGenerator& rng,
const std::string& algo)
{
PK_KEM_Encryptor kem_op(pubkey, rng, "KDF1(SHA-512)");
- secure_vector<byte> mce_ciphertext, mce_key;
+ secure_vector<uint8_t> mce_ciphertext, mce_key;
kem_op.encrypt(mce_ciphertext, mce_key, 64, rng);
const size_t mce_code_bytes = (pubkey.get_code_length() + 7) / 8;
@@ -54,9 +54,9 @@ mceies_encrypt(const McEliece_PublicKey& pubkey,
aead->set_key(aead_key(mce_key, *aead));
aead->set_associated_data(ad, ad_len);
- const secure_vector<byte> nonce = rng.random_vec(nonce_len);
+ const secure_vector<uint8_t> nonce = rng.random_vec(nonce_len);
- secure_vector<byte> msg(mce_ciphertext.size() + nonce.size() + pt_len);
+ secure_vector<uint8_t> msg(mce_ciphertext.size() + nonce.size() + pt_len);
copy_mem(msg.data(), mce_ciphertext.data(), mce_ciphertext.size());
copy_mem(msg.data() + mce_ciphertext.size(), nonce.data(), nonce.size());
copy_mem(msg.data() + mce_ciphertext.size() + nonce.size(), pt, pt_len);
@@ -66,10 +66,10 @@ mceies_encrypt(const McEliece_PublicKey& pubkey,
return msg;
}
-secure_vector<byte>
+secure_vector<uint8_t>
mceies_decrypt(const McEliece_PrivateKey& privkey,
- const byte ct[], size_t ct_len,
- const byte ad[], size_t ad_len,
+ const uint8_t ct[], size_t ct_len,
+ const uint8_t ad[], size_t ad_len,
const std::string& algo)
{
try
@@ -88,12 +88,12 @@ mceies_decrypt(const McEliece_PrivateKey& privkey,
if(ct_len < mce_code_bytes + nonce_len + aead->tag_size())
throw Exception("Input message too small to be valid");
- const secure_vector<byte> mce_key = kem_op.decrypt(ct, mce_code_bytes, 64);
+ const secure_vector<uint8_t> mce_key = kem_op.decrypt(ct, mce_code_bytes, 64);
aead->set_key(aead_key(mce_key, *aead));
aead->set_associated_data(ad, ad_len);
- secure_vector<byte> pt(ct + mce_code_bytes + nonce_len, ct + ct_len);
+ secure_vector<uint8_t> pt(ct + mce_code_bytes + nonce_len, ct + ct_len);
aead->start(&ct[mce_code_bytes], nonce_len);
aead->finish(pt, 0);
diff --git a/src/lib/pubkey/mceies/mceies.h b/src/lib/pubkey/mceies/mceies.h
index b43e2065f..372404cc1 100644
--- a/src/lib/pubkey/mceies/mceies.h
+++ b/src/lib/pubkey/mceies/mceies.h
@@ -21,10 +21,10 @@ class McEliece_PrivateKey;
* Derive a shared key using MCE KEM and encrypt/authenticate the
* plaintext and AD using AES-256 in OCB mode.
*/
-secure_vector<byte>
+secure_vector<uint8_t>
BOTAN_DLL mceies_encrypt(const McEliece_PublicKey& pubkey,
- const byte pt[], size_t pt_len,
- const byte ad[], size_t ad_len,
+ const uint8_t pt[], size_t pt_len,
+ const uint8_t ad[], size_t ad_len,
RandomNumberGenerator& rng,
const std::string& aead = "AES-256/OCB");
@@ -33,10 +33,10 @@ BOTAN_DLL mceies_encrypt(const McEliece_PublicKey& pubkey,
* Derive a shared key using MCE KEM and decrypt/authenticate the
* ciphertext and AD using AES-256 in OCB mode.
*/
-secure_vector<byte>
+secure_vector<uint8_t>
BOTAN_DLL mceies_decrypt(const McEliece_PrivateKey& privkey,
- const byte ct[], size_t ct_len,
- const byte ad[], size_t ad_len,
+ const uint8_t ct[], size_t ct_len,
+ const uint8_t ad[], size_t ad_len,
const std::string& aead = "AES-256/OCB");
diff --git a/src/lib/pubkey/newhope/newhope.cpp b/src/lib/pubkey/newhope/newhope.cpp
index 77194207e..2a48a4638 100644
--- a/src/lib/pubkey/newhope/newhope.cpp
+++ b/src/lib/pubkey/newhope/newhope.cpp
@@ -155,7 +155,7 @@ inline void poly_getnoise(Botan::RandomNumberGenerator& rng, poly *r)
for(size_t i=0;i<PARAM_N;i++)
{
- uint32_t t = load_le<u32bit>(buf, i);
+ uint32_t t = load_le<uint32_t>(buf, i);
uint32_t d = 0;
for(int j=0;j<8;j++)
d += (t >> j) & 0x01010101;
diff --git a/src/lib/pubkey/pbes2/pbes2.cpp b/src/lib/pubkey/pbes2/pbes2.cpp
index c66b293e8..3f1000170 100644
--- a/src/lib/pubkey/pbes2/pbes2.cpp
+++ b/src/lib/pubkey/pbes2/pbes2.cpp
@@ -23,10 +23,10 @@ namespace {
/*
* Encode PKCS#5 PBES2 parameters
*/
-std::vector<byte> encode_pbes2_params(const std::string& cipher,
+std::vector<uint8_t> encode_pbes2_params(const std::string& cipher,
const std::string& prf,
- const secure_vector<byte>& salt,
- const secure_vector<byte>& iv,
+ const secure_vector<uint8_t>& salt,
+ const secure_vector<uint8_t>& iv,
size_t iterations,
size_t key_length)
{
@@ -60,8 +60,8 @@ std::vector<byte> encode_pbes2_params(const std::string& cipher,
/*
* PKCS#5 v2.0 PBE Constructor
*/
-std::pair<AlgorithmIdentifier, std::vector<byte>>
-pbes2_encrypt(const secure_vector<byte>& key_bits,
+std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
+pbes2_encrypt(const secure_vector<uint8_t>& key_bits,
const std::string& passphrase,
std::chrono::milliseconds msec,
const std::string& cipher,
@@ -74,7 +74,7 @@ pbes2_encrypt(const secure_vector<byte>& key_bits,
if(cipher_spec.size() != 2)
throw Decoding_Error("PBE-PKCS5 v2.0: Invalid cipher spec " + cipher);
- const secure_vector<byte> salt = rng.random_vec(12);
+ const secure_vector<uint8_t> salt = rng.random_vec(12);
if(cipher_spec[1] != "CBC" && cipher_spec[1] != "GCM")
throw Decoding_Error("PBE-PKCS5 v2.0: Don't know param format for " + cipher);
@@ -89,13 +89,13 @@ pbes2_encrypt(const secure_vector<byte>& key_bits,
const size_t key_length = enc->key_spec().maximum_keylength();
size_t iterations = 0;
- secure_vector<byte> iv = rng.random_vec(enc->default_nonce_length());
+ secure_vector<uint8_t> iv = rng.random_vec(enc->default_nonce_length());
enc->set_key(pbkdf->derive_key(key_length, passphrase, salt.data(), salt.size(),
msec, iterations).bits_of());
enc->start(iv);
- secure_vector<byte> buf = key_bits;
+ secure_vector<uint8_t> buf = key_bits;
enc->finish(buf);
AlgorithmIdentifier id(
@@ -105,10 +105,10 @@ pbes2_encrypt(const secure_vector<byte>& key_bits,
return std::make_pair(id, unlock(buf));
}
-secure_vector<byte>
-pbes2_decrypt(const secure_vector<byte>& key_bits,
+secure_vector<uint8_t>
+pbes2_decrypt(const secure_vector<uint8_t>& key_bits,
const std::string& passphrase,
- const std::vector<byte>& params)
+ const std::vector<uint8_t>& params)
{
AlgorithmIdentifier kdf_algo, enc_algo;
@@ -125,7 +125,7 @@ pbes2_decrypt(const secure_vector<byte>& key_bits,
throw Decoding_Error("PBE-PKCS5 v2.0: Unknown KDF algorithm " +
kdf_algo.oid.as_string());
- secure_vector<byte> salt;
+ secure_vector<uint8_t> salt;
size_t iterations = 0, key_length = 0;
BER_Decoder(kdf_algo.parameters)
@@ -149,7 +149,7 @@ pbes2_decrypt(const secure_vector<byte>& key_bits,
if(salt.size() < 8)
throw Decoding_Error("PBE-PKCS5 v2.0: Encoded salt is too small");
- secure_vector<byte> iv;
+ secure_vector<uint8_t> iv;
BER_Decoder(enc_algo.parameters).decode(iv, OCTET_STRING).verify_end();
const std::string prf = OIDS::lookup(prf_algo.oid);
@@ -167,7 +167,7 @@ pbes2_decrypt(const secure_vector<byte>& key_bits,
dec->start(iv);
- secure_vector<byte> buf = key_bits;
+ secure_vector<uint8_t> buf = key_bits;
dec->finish(buf);
return buf;
diff --git a/src/lib/pubkey/pbes2/pbes2.h b/src/lib/pubkey/pbes2/pbes2.h
index 7c8c4095d..e50896c6d 100644
--- a/src/lib/pubkey/pbes2/pbes2.h
+++ b/src/lib/pubkey/pbes2/pbes2.h
@@ -23,8 +23,8 @@ namespace Botan {
* @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
* @param rng a random number generator
*/
-std::pair<AlgorithmIdentifier, std::vector<byte>>
-BOTAN_DLL pbes2_encrypt(const secure_vector<byte>& key_bits,
+std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
+BOTAN_DLL pbes2_encrypt(const secure_vector<uint8_t>& key_bits,
const std::string& passphrase,
std::chrono::milliseconds msec,
const std::string& cipher,
@@ -37,10 +37,10 @@ BOTAN_DLL pbes2_encrypt(const secure_vector<byte>& key_bits,
* @param passphrase the passphrase to use for decryption
* @param params the PBES2 parameters
*/
-secure_vector<byte>
-BOTAN_DLL pbes2_decrypt(const secure_vector<byte>& key_bits,
+secure_vector<uint8_t>
+BOTAN_DLL pbes2_decrypt(const secure_vector<uint8_t>& key_bits,
const std::string& passphrase,
- const std::vector<byte>& params);
+ const std::vector<uint8_t>& params);
}
diff --git a/src/lib/pubkey/pem/pem.cpp b/src/lib/pubkey/pem/pem.cpp
index 83b48c07b..bc94e3b53 100644
--- a/src/lib/pubkey/pem/pem.cpp
+++ b/src/lib/pubkey/pem/pem.cpp
@@ -40,7 +40,7 @@ std::string linewrap(size_t width, const std::string& in)
/*
* PEM encode BER/DER-encoded objects
*/
-std::string encode(const byte der[], size_t length, const std::string& label, size_t width)
+std::string encode(const uint8_t der[], size_t length, const std::string& label, size_t width)
{
const std::string PEM_HEADER = "-----BEGIN " + label + "-----\n";
const std::string PEM_TRAILER = "-----END " + label + "-----\n";
@@ -51,11 +51,11 @@ std::string encode(const byte der[], size_t length, const std::string& label, si
/*
* Decode PEM down to raw BER/DER
*/
-secure_vector<byte> decode_check_label(DataSource& source,
+secure_vector<uint8_t> decode_check_label(DataSource& source,
const std::string& label_want)
{
std::string label_got;
- secure_vector<byte> ber = decode(source, label_got);
+ secure_vector<uint8_t> ber = decode(source, label_got);
if(label_got != label_want)
throw Decoding_Error("PEM: Label mismatch, wanted " + label_want +
", got " + label_got);
@@ -65,7 +65,7 @@ secure_vector<byte> decode_check_label(DataSource& source,
/*
* Decode PEM down to raw BER/DER
*/
-secure_vector<byte> decode(DataSource& source, std::string& label)
+secure_vector<uint8_t> decode(DataSource& source, std::string& label)
{
const size_t RANDOM_CHAR_LIMIT = 8;
@@ -75,7 +75,7 @@ secure_vector<byte> decode(DataSource& source, std::string& label)
while(position != PEM_HEADER1.length())
{
- byte b;
+ uint8_t b;
if(!source.read_byte(b))
throw Decoding_Error("PEM: No PEM header found");
if(b == PEM_HEADER1[position])
@@ -88,7 +88,7 @@ secure_vector<byte> decode(DataSource& source, std::string& label)
position = 0;
while(position != PEM_HEADER2.length())
{
- byte b;
+ uint8_t b;
if(!source.read_byte(b))
throw Decoding_Error("PEM: No PEM header found");
if(b == PEM_HEADER2[position])
@@ -106,7 +106,7 @@ secure_vector<byte> decode(DataSource& source, std::string& label)
position = 0;
while(position != PEM_TRAILER.length())
{
- byte b;
+ uint8_t b;
if(!source.read_byte(b))
throw Decoding_Error("PEM: No PEM trailer found");
if(b == PEM_TRAILER[position])
@@ -121,14 +121,14 @@ secure_vector<byte> decode(DataSource& source, std::string& label)
return base64_decode(b64.data(), b64.size());
}
-secure_vector<byte> decode_check_label(const std::string& pem,
+secure_vector<uint8_t> decode_check_label(const std::string& pem,
const std::string& label_want)
{
DataSource_Memory src(pem);
return decode_check_label(src, label_want);
}
-secure_vector<byte> decode(const std::string& pem, std::string& label)
+secure_vector<uint8_t> decode(const std::string& pem, std::string& label)
{
DataSource_Memory src(pem);
return decode(src, label);
@@ -142,7 +142,7 @@ bool matches(DataSource& source, const std::string& extra,
{
const std::string PEM_HEADER = "-----BEGIN " + extra;
- secure_vector<byte> search_buf(search_range);
+ secure_vector<uint8_t> search_buf(search_range);
size_t got = source.peek(search_buf.data(), search_buf.size(), 0);
if(got < PEM_HEADER.length())
diff --git a/src/lib/pubkey/pem/pem.h b/src/lib/pubkey/pem/pem.h
index acbd40a77..1f9483ea8 100644
--- a/src/lib/pubkey/pem/pem.h
+++ b/src/lib/pubkey/pem/pem.h
@@ -21,7 +21,7 @@ namespace PEM_Code {
* @param label PEM label put after BEGIN and END
* @param line_width after this many characters, a new line is inserted
*/
-BOTAN_DLL std::string encode(const byte data[],
+BOTAN_DLL std::string encode(const uint8_t data[],
size_t data_len,
const std::string& label,
size_t line_width = 64);
@@ -32,7 +32,7 @@ BOTAN_DLL std::string encode(const byte data[],
* @param label PEM label
* @param line_width after this many characters, a new line is inserted
*/
-inline std::string encode(const std::vector<byte>& data,
+inline std::string encode(const std::vector<uint8_t>& data,
const std::string& label,
size_t line_width = 64)
{
@@ -45,7 +45,7 @@ inline std::string encode(const std::vector<byte>& data,
* @param label PEM label put after BEGIN and END
* @param line_width after this many characters, a new line is inserted
*/
-inline std::string encode(const secure_vector<byte>& data,
+inline std::string encode(const secure_vector<uint8_t>& data,
const std::string& label,
size_t line_width = 64)
{
@@ -57,7 +57,7 @@ inline std::string encode(const secure_vector<byte>& data,
* @param pem a datasource containing PEM encoded data
* @param label is set to the PEM label found for later inspection
*/
-BOTAN_DLL secure_vector<byte> decode(DataSource& pem,
+BOTAN_DLL secure_vector<uint8_t> decode(DataSource& pem,
std::string& label);
/**
@@ -65,7 +65,7 @@ BOTAN_DLL secure_vector<byte> decode(DataSource& pem,
* @param pem a string containing PEM encoded data
* @param label is set to the PEM label found for later inspection
*/
-BOTAN_DLL secure_vector<byte> decode(const std::string& pem,
+BOTAN_DLL secure_vector<uint8_t> decode(const std::string& pem,
std::string& label);
/**
@@ -73,7 +73,7 @@ BOTAN_DLL secure_vector<byte> decode(const std::string& pem,
* @param pem a datasource containing PEM encoded data
* @param label is what we expect the label to be
*/
-BOTAN_DLL secure_vector<byte> decode_check_label(
+BOTAN_DLL secure_vector<uint8_t> decode_check_label(
DataSource& pem,
const std::string& label);
@@ -82,7 +82,7 @@ BOTAN_DLL secure_vector<byte> decode_check_label(
* @param pem a string containing PEM encoded data
* @param label is what we expect the label to be
*/
-BOTAN_DLL secure_vector<byte> decode_check_label(
+BOTAN_DLL secure_vector<uint8_t> decode_check_label(
const std::string& pem,
const std::string& label);
diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp
index 696c4528b..1e1fd739a 100644
--- a/src/lib/pubkey/pk_algs.cpp
+++ b/src/lib/pubkey/pk_algs.cpp
@@ -60,7 +60,7 @@ namespace Botan {
std::unique_ptr<Public_Key>
load_public_key(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
const std::string alg_name = OIDS::lookup(alg_id.oid);
if(alg_name == "")
@@ -131,7 +131,7 @@ load_public_key(const AlgorithmIdentifier& alg_id,
std::unique_ptr<Private_Key>
load_private_key(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits)
+ const secure_vector<uint8_t>& key_bits)
{
const std::string alg_name = OIDS::lookup(alg_id.oid);
if(alg_name == "")
diff --git a/src/lib/pubkey/pk_algs.h b/src/lib/pubkey/pk_algs.h
index 42613d0c3..04248459b 100644
--- a/src/lib/pubkey/pk_algs.h
+++ b/src/lib/pubkey/pk_algs.h
@@ -16,11 +16,11 @@ namespace Botan {
BOTAN_DLL std::unique_ptr<Public_Key>
load_public_key(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
BOTAN_DLL std::unique_ptr<Private_Key>
load_private_key(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Create a new key
diff --git a/src/lib/pubkey/pk_keys.cpp b/src/lib/pubkey/pk_keys.cpp
index 06833958d..52304eb03 100644
--- a/src/lib/pubkey/pk_keys.cpp
+++ b/src/lib/pubkey/pk_keys.cpp
@@ -14,7 +14,7 @@
namespace Botan {
-std::vector<byte> Public_Key::subject_public_key() const
+std::vector<uint8_t> Public_Key::subject_public_key() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -38,7 +38,7 @@ OID Public_Key::get_oid() const
}
}
-secure_vector<byte> Private_Key::private_key_info() const
+secure_vector<uint8_t> Private_Key::private_key_info() const
{
const size_t PKCS8_VERSION = 0;
@@ -56,7 +56,7 @@ secure_vector<byte> Private_Key::private_key_info() const
*/
std::string Private_Key::fingerprint(const std::string& alg) const
{
- secure_vector<byte> buf = private_key_bits();
+ secure_vector<uint8_t> buf = private_key_bits();
std::unique_ptr<HashFunction> hash(HashFunction::create(alg));
hash->update(buf);
const auto hex_print = hex_encode(hash->final());
diff --git a/src/lib/pubkey/pk_keys.h b/src/lib/pubkey/pk_keys.h
index f8242f429..1e7bd3216 100644
--- a/src/lib/pubkey/pk_keys.h
+++ b/src/lib/pubkey/pk_keys.h
@@ -76,12 +76,12 @@ class BOTAN_DLL Public_Key
/**
* @return BER encoded public key bits
*/
- virtual std::vector<byte> public_key_bits() const = 0;
+ virtual std::vector<uint8_t> public_key_bits() const = 0;
/**
* @return X.509 subject key encoding for this key object
*/
- std::vector<byte> subject_public_key() const;
+ std::vector<uint8_t> subject_public_key() const;
// Internal or non-public declarations follow
@@ -166,12 +166,12 @@ class BOTAN_DLL Private_Key : public virtual Public_Key
/**
* @return BER encoded private key bits
*/
- virtual secure_vector<byte> private_key_bits() const = 0;
+ virtual secure_vector<uint8_t> private_key_bits() const = 0;
/**
* @return PKCS #8 private key encoding for this key object
*/
- secure_vector<byte> private_key_info() const;
+ secure_vector<uint8_t> private_key_info() const;
/**
* @return PKCS #8 AlgorithmIdentifier for this key
@@ -266,7 +266,7 @@ class BOTAN_DLL PK_Key_Agreement_Key : public virtual Private_Key
/*
* @return public component of this key
*/
- virtual std::vector<byte> public_value() const = 0;
+ virtual std::vector<uint8_t> public_value() const = 0;
virtual ~PK_Key_Agreement_Key() {}
};
diff --git a/src/lib/pubkey/pk_ops.cpp b/src/lib/pubkey/pk_ops.cpp
index dba82345e..cf10c4ba2 100644
--- a/src/lib/pubkey/pk_ops.cpp
+++ b/src/lib/pubkey/pk_ops.cpp
@@ -27,11 +27,11 @@ size_t PK_Ops::Encryption_with_EME::max_input_bits() const
return m_eme->maximum_input_size(max_raw_input_bits());
}
-secure_vector<byte> PK_Ops::Encryption_with_EME::encrypt(const byte msg[], size_t msg_len,
+secure_vector<uint8_t> PK_Ops::Encryption_with_EME::encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const size_t max_raw = max_raw_input_bits();
- const std::vector<byte> encoded = unlock(m_eme->encode(msg, msg_len, max_raw, rng));
+ const std::vector<uint8_t> encoded = unlock(m_eme->encode(msg, msg_len, max_raw, rng));
return raw_encrypt(encoded.data(), encoded.size(), rng);
}
@@ -44,12 +44,12 @@ PK_Ops::Decryption_with_EME::Decryption_with_EME(const std::string& eme)
PK_Ops::Decryption_with_EME::~Decryption_with_EME() {}
-secure_vector<byte>
-PK_Ops::Decryption_with_EME::decrypt(byte& valid_mask,
- const byte ciphertext[],
+secure_vector<uint8_t>
+PK_Ops::Decryption_with_EME::decrypt(uint8_t& valid_mask,
+ const uint8_t ciphertext[],
size_t ciphertext_len)
{
- const secure_vector<byte> raw = raw_decrypt(ciphertext, ciphertext_len);
+ const secure_vector<uint8_t> raw = raw_decrypt(ciphertext, ciphertext_len);
return m_eme->unpad(valid_mask, raw.data(), raw.size());
}
@@ -61,11 +61,11 @@ PK_Ops::Key_Agreement_with_KDF::Key_Agreement_with_KDF(const std::string& kdf)
PK_Ops::Key_Agreement_with_KDF::~Key_Agreement_with_KDF() {}
-secure_vector<byte> PK_Ops::Key_Agreement_with_KDF::agree(size_t key_len,
- const byte w[], size_t w_len,
- const byte salt[], size_t salt_len)
+secure_vector<uint8_t> PK_Ops::Key_Agreement_with_KDF::agree(size_t key_len,
+ const uint8_t w[], size_t w_len,
+ const uint8_t salt[], size_t salt_len)
{
- secure_vector<byte> z = raw_agree(w, w_len);
+ secure_vector<uint8_t> z = raw_agree(w, w_len);
if(m_kdf)
return m_kdf->derive_key(key_len, z, salt, salt_len);
return z;
@@ -83,21 +83,21 @@ PK_Ops::Signature_with_EMSA::Signature_with_EMSA(const std::string& emsa) :
PK_Ops::Signature_with_EMSA::~Signature_with_EMSA() {}
-void PK_Ops::Signature_with_EMSA::update(const byte msg[], size_t msg_len)
+void PK_Ops::Signature_with_EMSA::update(const uint8_t msg[], size_t msg_len)
{
if(has_prefix() && !m_prefix_used)
{
m_prefix_used = true;
- secure_vector<byte> prefix = message_prefix();
+ secure_vector<uint8_t> prefix = message_prefix();
m_emsa->update(prefix.data(), prefix.size());
}
m_emsa->update(msg, msg_len);
}
-secure_vector<byte> PK_Ops::Signature_with_EMSA::sign(RandomNumberGenerator& rng)
+secure_vector<uint8_t> PK_Ops::Signature_with_EMSA::sign(RandomNumberGenerator& rng)
{
m_prefix_used = false;
- const secure_vector<byte> msg = m_emsa->raw_data();
+ const secure_vector<uint8_t> msg = m_emsa->raw_data();
const auto padded = m_emsa->encoding_of(msg, this->max_input_bits(), rng);
return raw_sign(padded.data(), padded.size(), rng);
}
@@ -114,43 +114,43 @@ PK_Ops::Verification_with_EMSA::Verification_with_EMSA(const std::string& emsa)
PK_Ops::Verification_with_EMSA::~Verification_with_EMSA() {}
-void PK_Ops::Verification_with_EMSA::update(const byte msg[], size_t msg_len)
+void PK_Ops::Verification_with_EMSA::update(const uint8_t msg[], size_t msg_len)
{
if(has_prefix() && !m_prefix_used)
{
m_prefix_used = true;
- secure_vector<byte> prefix = message_prefix();
+ secure_vector<uint8_t> prefix = message_prefix();
m_emsa->update(prefix.data(), prefix.size());
}
m_emsa->update(msg, msg_len);
}
-bool PK_Ops::Verification_with_EMSA::is_valid_signature(const byte sig[], size_t sig_len)
+bool PK_Ops::Verification_with_EMSA::is_valid_signature(const uint8_t sig[], size_t sig_len)
{
m_prefix_used = false;
- const secure_vector<byte> msg = m_emsa->raw_data();
+ const secure_vector<uint8_t> msg = m_emsa->raw_data();
if(with_recovery())
{
- secure_vector<byte> output_of_key = verify_mr(sig, sig_len);
+ secure_vector<uint8_t> output_of_key = verify_mr(sig, sig_len);
return m_emsa->verify(output_of_key, msg, max_input_bits());
}
else
{
Null_RNG rng;
- secure_vector<byte> encoded = m_emsa->encoding_of(msg, max_input_bits(), rng);
+ secure_vector<uint8_t> encoded = m_emsa->encoding_of(msg, max_input_bits(), rng);
return verify(encoded.data(), encoded.size(), sig, sig_len);
}
}
-void PK_Ops::KEM_Encryption_with_KDF::kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+void PK_Ops::KEM_Encryption_with_KDF::kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
size_t salt_len)
{
- secure_vector<byte> raw_shared;
+ secure_vector<uint8_t> raw_shared;
this->raw_kem_encrypt(out_encapsulated_key, raw_shared, rng);
out_shared_key = m_kdf->derive_key(desired_shared_key_len,
@@ -165,14 +165,14 @@ PK_Ops::KEM_Encryption_with_KDF::KEM_Encryption_with_KDF(const std::string& kdf)
PK_Ops::KEM_Encryption_with_KDF::~KEM_Encryption_with_KDF() {}
-secure_vector<byte>
-PK_Ops::KEM_Decryption_with_KDF::kem_decrypt(const byte encap_key[],
+secure_vector<uint8_t>
+PK_Ops::KEM_Decryption_with_KDF::kem_decrypt(const uint8_t encap_key[],
size_t len,
size_t desired_shared_key_len,
const uint8_t salt[],
size_t salt_len)
{
- secure_vector<byte> raw_shared = this->raw_kem_decrypt(encap_key, len);
+ secure_vector<uint8_t> raw_shared = this->raw_kem_decrypt(encap_key, len);
return m_kdf->derive_key(desired_shared_key_len,
raw_shared.data(), raw_shared.size(),
diff --git a/src/lib/pubkey/pk_ops.h b/src/lib/pubkey/pk_ops.h
index 4a136d90f..d3c4c0d9b 100644
--- a/src/lib/pubkey/pk_ops.h
+++ b/src/lib/pubkey/pk_ops.h
@@ -36,7 +36,7 @@ namespace PK_Ops {
class BOTAN_DLL Encryption
{
public:
- virtual secure_vector<byte> encrypt(const byte msg[],
+ virtual secure_vector<uint8_t> encrypt(const uint8_t msg[],
size_t msg_len,
RandomNumberGenerator& rng) = 0;
@@ -51,8 +51,8 @@ class BOTAN_DLL Encryption
class BOTAN_DLL Decryption
{
public:
- virtual secure_vector<byte> decrypt(byte& valid_mask,
- const byte ciphertext[],
+ virtual secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
+ const uint8_t ciphertext[],
size_t ciphertext_len) = 0;
virtual ~Decryption() {}
@@ -69,13 +69,13 @@ class BOTAN_DLL Verification
* @param msg the message
* @param msg_len the length of msg in bytes
*/
- virtual void update(const byte msg[], size_t msg_len) = 0;
+ virtual void update(const uint8_t msg[], size_t msg_len) = 0;
/*
* Perform a verification operation
* @param rng a random number generator
*/
- virtual bool is_valid_signature(const byte sig[], size_t sig_len) = 0;
+ virtual bool is_valid_signature(const uint8_t sig[], size_t sig_len) = 0;
virtual ~Verification() {}
};
@@ -91,13 +91,13 @@ class BOTAN_DLL Signature
* @param msg the message
* @param msg_len the length of msg in bytes
*/
- virtual void update(const byte msg[], size_t msg_len) = 0;
+ virtual void update(const uint8_t msg[], size_t msg_len) = 0;
/*
* Perform a signature operation
* @param rng a random number generator
*/
- virtual secure_vector<byte> sign(RandomNumberGenerator& rng) = 0;
+ virtual secure_vector<uint8_t> sign(RandomNumberGenerator& rng) = 0;
virtual ~Signature() {}
};
@@ -108,9 +108,9 @@ class BOTAN_DLL Signature
class BOTAN_DLL Key_Agreement
{
public:
- virtual secure_vector<byte> agree(size_t key_len,
- const byte other_key[], size_t other_key_len,
- const byte salt[], size_t salt_len) = 0;
+ virtual secure_vector<uint8_t> agree(size_t key_len,
+ const uint8_t other_key[], size_t other_key_len,
+ const uint8_t salt[], size_t salt_len) = 0;
virtual ~Key_Agreement() {}
};
@@ -121,8 +121,8 @@ class BOTAN_DLL Key_Agreement
class BOTAN_DLL KEM_Encryption
{
public:
- virtual void kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ virtual void kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
@@ -134,7 +134,7 @@ class BOTAN_DLL KEM_Encryption
class BOTAN_DLL KEM_Decryption
{
public:
- virtual secure_vector<byte> kem_decrypt(const byte encap_key[],
+ virtual secure_vector<uint8_t> kem_decrypt(const uint8_t encap_key[],
size_t len,
size_t desired_shared_key_len,
const uint8_t salt[],
diff --git a/src/lib/pubkey/pk_ops_impl.h b/src/lib/pubkey/pk_ops_impl.h
index 48552afab..f6c1b0510 100644
--- a/src/lib/pubkey/pk_ops_impl.h
+++ b/src/lib/pubkey/pk_ops_impl.h
@@ -19,7 +19,7 @@ class Encryption_with_EME : public Encryption
public:
size_t max_input_bits() const override;
- secure_vector<byte> encrypt(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
~Encryption_with_EME();
@@ -28,7 +28,7 @@ class Encryption_with_EME : public Encryption
private:
virtual size_t max_raw_input_bits() const = 0;
- virtual secure_vector<byte> raw_encrypt(const byte msg[], size_t len,
+ virtual secure_vector<uint8_t> raw_encrypt(const uint8_t msg[], size_t len,
RandomNumberGenerator& rng) = 0;
std::unique_ptr<EME> m_eme;
};
@@ -36,15 +36,15 @@ class Encryption_with_EME : public Encryption
class Decryption_with_EME : public Decryption
{
public:
- secure_vector<byte> decrypt(byte& valid_mask,
- const byte msg[], size_t msg_len) override;
+ secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
+ const uint8_t msg[], size_t msg_len) override;
~Decryption_with_EME();
protected:
explicit Decryption_with_EME(const std::string& eme);
private:
virtual size_t max_raw_input_bits() const = 0;
- virtual secure_vector<byte> raw_decrypt(const byte msg[], size_t len) = 0;
+ virtual secure_vector<uint8_t> raw_decrypt(const uint8_t msg[], size_t len) = 0;
std::unique_ptr<EME> m_eme;
};
@@ -53,11 +53,11 @@ class Verification_with_EMSA : public Verification
public:
~Verification_with_EMSA();
- void update(const byte msg[], size_t msg_len) override;
- bool is_valid_signature(const byte sig[], size_t sig_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
+ bool is_valid_signature(const uint8_t sig[], size_t sig_len) override;
- bool do_check(const secure_vector<byte>& msg,
- const byte sig[], size_t sig_len);
+ bool do_check(const secure_vector<uint8_t>& msg,
+ const uint8_t sig[], size_t sig_len);
std::string hash_for_signature() { return m_hash; }
@@ -80,7 +80,7 @@ class Verification_with_EMSA : public Verification
* @return the message prefix if this signature scheme uses
* a message prefix, signaled via has_prefix()
*/
- virtual secure_vector<byte> message_prefix() const { throw Exception( "No prefix" ); }
+ virtual secure_vector<uint8_t> message_prefix() const { throw Exception( "No prefix" ); }
/**
* @return boolean specifying if this key type supports message
@@ -96,8 +96,8 @@ class Verification_with_EMSA : public Verification
* @param sig_len the length of sig in bytes
* @returns if signature is a valid one for message
*/
- virtual bool verify(const byte[], size_t,
- const byte[], size_t)
+ virtual bool verify(const uint8_t[], size_t,
+ const uint8_t[], size_t)
{
throw Invalid_State("Message recovery required");
}
@@ -109,7 +109,7 @@ class Verification_with_EMSA : public Verification
* @param msg_len the length of msg in bytes
* @returns recovered message
*/
- virtual secure_vector<byte> verify_mr(const byte[], size_t)
+ virtual secure_vector<uint8_t> verify_mr(const uint8_t[], size_t)
{
throw Invalid_State("Message recovery not supported");
}
@@ -124,9 +124,9 @@ class Verification_with_EMSA : public Verification
class Signature_with_EMSA : public Signature
{
public:
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
- secure_vector<byte> sign(RandomNumberGenerator& rng) override;
+ secure_vector<uint8_t> sign(RandomNumberGenerator& rng) override;
protected:
explicit Signature_with_EMSA(const std::string& emsa);
~Signature_with_EMSA();
@@ -143,7 +143,7 @@ class Signature_with_EMSA : public Signature
* @return the message prefix if this signature scheme uses
* a message prefix, signaled via has_prefix()
*/
- virtual secure_vector<byte> message_prefix() const { throw Exception( "No prefix" ); }
+ virtual secure_vector<uint8_t> message_prefix() const { throw Exception( "No prefix" ); }
std::unique_ptr<EMSA> m_emsa;
private:
@@ -154,10 +154,10 @@ class Signature_with_EMSA : public Signature
*/
virtual size_t max_input_bits() const = 0;
- bool self_test_signature(const std::vector<byte>& msg,
- const std::vector<byte>& sig) const;
+ bool self_test_signature(const std::vector<uint8_t>& msg,
+ const std::vector<uint8_t>& sig) const;
- virtual secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ virtual secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) = 0;
const std::string m_hash;
@@ -167,31 +167,31 @@ class Signature_with_EMSA : public Signature
class Key_Agreement_with_KDF : public Key_Agreement
{
public:
- secure_vector<byte> agree(size_t key_len,
- const byte other_key[], size_t other_key_len,
- const byte salt[], size_t salt_len) override;
+ secure_vector<uint8_t> agree(size_t key_len,
+ const uint8_t other_key[], size_t other_key_len,
+ const uint8_t salt[], size_t salt_len) override;
protected:
explicit Key_Agreement_with_KDF(const std::string& kdf);
~Key_Agreement_with_KDF();
private:
- virtual secure_vector<byte> raw_agree(const byte w[], size_t w_len) = 0;
+ virtual secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) = 0;
std::unique_ptr<KDF> m_kdf;
};
class KEM_Encryption_with_KDF : public KEM_Encryption
{
public:
- void kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ void kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
size_t salt_len) override;
protected:
- virtual void raw_kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& raw_shared_key,
+ virtual void raw_kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& raw_shared_key,
Botan::RandomNumberGenerator& rng) = 0;
explicit KEM_Encryption_with_KDF(const std::string& kdf);
@@ -203,15 +203,15 @@ class KEM_Encryption_with_KDF : public KEM_Encryption
class KEM_Decryption_with_KDF : public KEM_Decryption
{
public:
- secure_vector<byte> kem_decrypt(const byte encap_key[],
+ secure_vector<uint8_t> kem_decrypt(const uint8_t encap_key[],
size_t len,
size_t desired_shared_key_len,
const uint8_t salt[],
size_t salt_len) override;
protected:
- virtual secure_vector<byte>
- raw_kem_decrypt(const byte encap_key[], size_t len) = 0;
+ virtual secure_vector<uint8_t>
+ raw_kem_decrypt(const uint8_t encap_key[], size_t len) = 0;
explicit KEM_Decryption_with_KDF(const std::string& kdf);
~KEM_Decryption_with_KDF();
diff --git a/src/lib/pubkey/pkcs8.cpp b/src/lib/pubkey/pkcs8.cpp
index 7857e3ee0..c4294d563 100644
--- a/src/lib/pubkey/pkcs8.cpp
+++ b/src/lib/pubkey/pkcs8.cpp
@@ -24,10 +24,10 @@ namespace {
/*
* Get info from an EncryptedPrivateKeyInfo
*/
-secure_vector<byte> PKCS8_extract(DataSource& source,
+secure_vector<uint8_t> PKCS8_extract(DataSource& source,
AlgorithmIdentifier& pbe_alg_id)
{
- secure_vector<byte> key_data;
+ secure_vector<uint8_t> key_data;
BER_Decoder(source)
.start_cons(SEQUENCE)
@@ -41,14 +41,14 @@ secure_vector<byte> PKCS8_extract(DataSource& source,
/*
* PEM decode and/or decrypt a private key
*/
-secure_vector<byte> PKCS8_decode(
+secure_vector<uint8_t> PKCS8_decode(
DataSource& source,
std::function<std::string ()> get_passphrase,
AlgorithmIdentifier& pk_alg_id,
bool is_encrypted)
{
AlgorithmIdentifier pbe_alg_id;
- secure_vector<byte> key_data, key;
+ secure_vector<uint8_t> key_data, key;
try {
if(ASN1::maybe_BER(source) && !PEM_Code::matches(source))
@@ -62,7 +62,7 @@ secure_vector<byte> PKCS8_decode(
// todo read more efficiently
while ( !source.end_of_data() )
{
- byte b;
+ uint8_t b;
size_t read = source.read_byte( b );
if ( read )
{
@@ -127,7 +127,7 @@ secure_vector<byte> PKCS8_decode(
/*
* BER encode a PKCS #8 private key, unencrypted
*/
-secure_vector<byte> BER_encode(const Private_Key& key)
+secure_vector<uint8_t> BER_encode(const Private_Key& key)
{
// keeping around for compat
return key.private_key_info();
@@ -166,7 +166,7 @@ choose_pbe_params(const std::string& pbe_algo, const std::string& key_algo)
/*
* BER encode a PKCS #8 private key, encrypted
*/
-std::vector<byte> BER_encode(const Private_Key& key,
+std::vector<uint8_t> BER_encode(const Private_Key& key,
RandomNumberGenerator& rng,
const std::string& pass,
std::chrono::milliseconds msec,
@@ -174,7 +174,7 @@ std::vector<byte> BER_encode(const Private_Key& key,
{
const auto pbe_params = choose_pbe_params(pbe_algo, key.algo_name());
- const std::pair<AlgorithmIdentifier, std::vector<byte>> pbe_info =
+ const std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbe_info =
pbes2_encrypt(PKCS8::BER_encode(key), pass, msec,
pbe_params.first, pbe_params.second, rng);
@@ -213,7 +213,7 @@ Private_Key* load_key(DataSource& source,
bool is_encrypted)
{
AlgorithmIdentifier alg_id;
- secure_vector<byte> pkcs8_key = PKCS8_decode(source, get_pass, alg_id, is_encrypted);
+ secure_vector<uint8_t> pkcs8_key = PKCS8_decode(source, get_pass, alg_id, is_encrypted);
const std::string alg_name = OIDS::lookup(alg_id.oid);
if(alg_name.empty() || alg_name == alg_id.oid.as_string())
diff --git a/src/lib/pubkey/pkcs8.h b/src/lib/pubkey/pkcs8.h
index 34c687ec1..309ca2798 100644
--- a/src/lib/pubkey/pkcs8.h
+++ b/src/lib/pubkey/pkcs8.h
@@ -33,7 +33,7 @@ namespace PKCS8 {
* @param key the private key to encode
* @return BER encoded key
*/
-BOTAN_DLL secure_vector<byte> BER_encode(const Private_Key& key);
+BOTAN_DLL secure_vector<uint8_t> BER_encode(const Private_Key& key);
/**
* Get a string containing a PEM encoded private key.
@@ -53,7 +53,7 @@ BOTAN_DLL std::string PEM_encode(const Private_Key& key);
default will be chosen.
* @return encrypted key in binary BER form
*/
-BOTAN_DLL std::vector<byte>
+BOTAN_DLL std::vector<uint8_t>
BER_encode(const Private_Key& key,
RandomNumberGenerator& rng,
const std::string& pass,
diff --git a/src/lib/pubkey/pubkey.cpp b/src/lib/pubkey/pubkey.cpp
index dc98d6551..b1bd4b824 100644
--- a/src/lib/pubkey/pubkey.cpp
+++ b/src/lib/pubkey/pubkey.cpp
@@ -13,11 +13,11 @@
namespace Botan {
-secure_vector<byte> PK_Decryptor::decrypt(const byte in[], size_t length) const
+secure_vector<uint8_t> PK_Decryptor::decrypt(const uint8_t in[], size_t length) const
{
- byte valid_mask = 0;
+ uint8_t valid_mask = 0;
- secure_vector<byte> decoded = do_decrypt(valid_mask, in, length);
+ secure_vector<uint8_t> decoded = do_decrypt(valid_mask, in, length);
if(valid_mask == 0)
throw Decoding_Error("Invalid public key ciphertext, cannot decrypt");
@@ -25,19 +25,19 @@ secure_vector<byte> PK_Decryptor::decrypt(const byte in[], size_t length) const
return decoded;
}
-secure_vector<byte>
-PK_Decryptor::decrypt_or_random(const byte in[],
+secure_vector<uint8_t>
+PK_Decryptor::decrypt_or_random(const uint8_t in[],
size_t length,
size_t expected_pt_len,
RandomNumberGenerator& rng,
- const byte required_content_bytes[],
- const byte required_content_offsets[],
+ const uint8_t required_content_bytes[],
+ const uint8_t required_content_offsets[],
size_t required_contents_length) const
{
- const secure_vector<byte> fake_pms = rng.random_vec(expected_pt_len);
+ const secure_vector<uint8_t> fake_pms = rng.random_vec(expected_pt_len);
- byte valid_mask = 0;
- secure_vector<byte> decoded = do_decrypt(valid_mask, in, length);
+ uint8_t valid_mask = 0;
+ secure_vector<uint8_t> decoded = do_decrypt(valid_mask, in, length);
valid_mask &= CT::is_equal(decoded.size(), expected_pt_len);
@@ -56,8 +56,8 @@ PK_Decryptor::decrypt_or_random(const byte in[],
Alternately could always reduce the offset modulo the length?
*/
- const byte exp = required_content_bytes[i];
- const byte off = required_content_offsets[i];
+ const uint8_t exp = required_content_bytes[i];
+ const uint8_t off = required_content_offsets[i];
BOTAN_ASSERT(off < expected_pt_len, "Offset in range of plaintext");
@@ -73,8 +73,8 @@ PK_Decryptor::decrypt_or_random(const byte in[],
return decoded;
}
-secure_vector<byte>
-PK_Decryptor::decrypt_or_random(const byte in[],
+secure_vector<uint8_t>
+PK_Decryptor::decrypt_or_random(const uint8_t in[],
size_t length,
size_t expected_pt_len,
RandomNumberGenerator& rng) const
@@ -95,8 +95,8 @@ PK_Encryptor_EME::PK_Encryptor_EME(const Public_Key& key,
PK_Encryptor_EME::~PK_Encryptor_EME() { /* for unique_ptr */ }
-std::vector<byte>
-PK_Encryptor_EME::enc(const byte in[], size_t length, RandomNumberGenerator& rng) const
+std::vector<uint8_t>
+PK_Encryptor_EME::enc(const uint8_t in[], size_t length, RandomNumberGenerator& rng) const
{
return unlock(m_op->encrypt(in, length, rng));
}
@@ -118,8 +118,8 @@ PK_Decryptor_EME::PK_Decryptor_EME(const Private_Key& key,
PK_Decryptor_EME::~PK_Decryptor_EME() { /* for unique_ptr */ }
-secure_vector<byte> PK_Decryptor_EME::do_decrypt(byte& valid_mask,
- const byte in[], size_t in_len) const
+secure_vector<uint8_t> PK_Decryptor_EME::do_decrypt(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_len) const
{
return m_op->decrypt(valid_mask, in, in_len);
}
@@ -136,8 +136,8 @@ PK_KEM_Encryptor::PK_KEM_Encryptor(const Public_Key& key,
PK_KEM_Encryptor::~PK_KEM_Encryptor() { /* for unique_ptr */ }
-void PK_KEM_Encryptor::encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+void PK_KEM_Encryptor::encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
@@ -163,7 +163,7 @@ PK_KEM_Decryptor::PK_KEM_Decryptor(const Private_Key& key,
PK_KEM_Decryptor::~PK_KEM_Decryptor() { /* for unique_ptr */ }
-secure_vector<byte> PK_KEM_Decryptor::decrypt(const byte encap_key[],
+secure_vector<uint8_t> PK_KEM_Decryptor::decrypt(const uint8_t encap_key[],
size_t encap_key_len,
size_t desired_shared_key_len,
const uint8_t salt[],
@@ -200,8 +200,8 @@ PK_Key_Agreement::PK_Key_Agreement(PK_Key_Agreement&& other) :
{}
SymmetricKey PK_Key_Agreement::derive_key(size_t key_len,
- const byte in[], size_t in_len,
- const byte salt[],
+ const uint8_t in[], size_t in_len,
+ const uint8_t salt[],
size_t salt_len) const
{
return m_op->agree(key_len, in, in_len, salt, salt_len);
@@ -223,14 +223,14 @@ PK_Signer::PK_Signer(const Private_Key& key,
PK_Signer::~PK_Signer() { /* for unique_ptr */ }
-void PK_Signer::update(const byte in[], size_t length)
+void PK_Signer::update(const uint8_t in[], size_t length)
{
m_op->update(in, length);
}
-std::vector<byte> PK_Signer::signature(RandomNumberGenerator& rng)
+std::vector<uint8_t> PK_Signer::signature(RandomNumberGenerator& rng)
{
- const std::vector<byte> sig = unlock(m_op->sign(rng));
+ const std::vector<uint8_t> sig = unlock(m_op->sign(rng));
if(m_sig_format == IEEE_1363)
{
@@ -277,19 +277,19 @@ void PK_Verifier::set_input_format(Signature_Format format)
m_sig_format = format;
}
-bool PK_Verifier::verify_message(const byte msg[], size_t msg_length,
- const byte sig[], size_t sig_length)
+bool PK_Verifier::verify_message(const uint8_t msg[], size_t msg_length,
+ const uint8_t sig[], size_t sig_length)
{
update(msg, msg_length);
return check_signature(sig, sig_length);
}
-void PK_Verifier::update(const byte in[], size_t length)
+void PK_Verifier::update(const uint8_t in[], size_t length)
{
m_op->update(in, length);
}
-bool PK_Verifier::check_signature(const byte sig[], size_t length)
+bool PK_Verifier::check_signature(const uint8_t sig[], size_t length)
{
try {
if(m_sig_format == IEEE_1363)
@@ -298,7 +298,7 @@ bool PK_Verifier::check_signature(const byte sig[], size_t length)
}
else if(m_sig_format == DER_SEQUENCE)
{
- std::vector<byte> real_sig;
+ std::vector<uint8_t> real_sig;
BER_Decoder decoder(sig, length);
BER_Decoder ber_sig = decoder.start_cons(SEQUENCE);
diff --git a/src/lib/pubkey/pubkey.h b/src/lib/pubkey/pubkey.h
index f80e761dd..a5202d973 100644
--- a/src/lib/pubkey/pubkey.h
+++ b/src/lib/pubkey/pubkey.h
@@ -43,7 +43,7 @@ class BOTAN_DLL PK_Encryptor
* @param rng the random number source to use
* @return encrypted message
*/
- std::vector<byte> encrypt(const byte in[], size_t length,
+ std::vector<uint8_t> encrypt(const uint8_t in[], size_t length,
RandomNumberGenerator& rng) const
{
return enc(in, length, rng);
@@ -56,7 +56,7 @@ class BOTAN_DLL PK_Encryptor
* @return encrypted message
*/
template<typename Alloc>
- std::vector<byte> encrypt(const std::vector<byte, Alloc>& in,
+ std::vector<uint8_t> encrypt(const std::vector<uint8_t, Alloc>& in,
RandomNumberGenerator& rng) const
{
return enc(in.data(), in.size(), rng);
@@ -75,7 +75,7 @@ class BOTAN_DLL PK_Encryptor
PK_Encryptor& operator=(const PK_Encryptor&) = delete;
private:
- virtual std::vector<byte> enc(const byte[], size_t,
+ virtual std::vector<uint8_t> enc(const uint8_t[], size_t,
RandomNumberGenerator&) const = 0;
};
@@ -94,7 +94,7 @@ class BOTAN_DLL PK_Decryptor
* @param length the length of the above byte array
* @return decrypted message
*/
- secure_vector<byte> decrypt(const byte in[], size_t length) const;
+ secure_vector<uint8_t> decrypt(const uint8_t in[], size_t length) const;
/**
* Same as above, but taking a vector
@@ -102,7 +102,7 @@ class BOTAN_DLL PK_Decryptor
* @return decrypted message
*/
template<typename Alloc>
- secure_vector<byte> decrypt(const std::vector<byte, Alloc>& in) const
+ secure_vector<uint8_t> decrypt(const std::vector<uint8_t, Alloc>& in) const
{
return decrypt(in.data(), in.size());
}
@@ -113,8 +113,8 @@ class BOTAN_DLL PK_Decryptor
* returns a random string of the expected length. Use to avoid
* oracle attacks, especially against PKCS #1 v1.5 decryption.
*/
- secure_vector<byte>
- decrypt_or_random(const byte in[],
+ secure_vector<uint8_t>
+ decrypt_or_random(const uint8_t in[],
size_t length,
size_t expected_pt_len,
RandomNumberGenerator& rng) const;
@@ -133,13 +133,13 @@ class BOTAN_DLL PK_Decryptor
* the content bytes: if there is any timing variation the version
* check can be used as an oracle to recover the key.
*/
- secure_vector<byte>
- decrypt_or_random(const byte in[],
+ secure_vector<uint8_t>
+ decrypt_or_random(const uint8_t in[],
size_t length,
size_t expected_pt_len,
RandomNumberGenerator& rng,
- const byte required_content_bytes[],
- const byte required_content_offsets[],
+ const uint8_t required_content_bytes[],
+ const uint8_t required_content_offsets[],
size_t required_contents) const;
PK_Decryptor() {}
@@ -149,8 +149,8 @@ class BOTAN_DLL PK_Decryptor
PK_Decryptor& operator=(const PK_Decryptor&) = delete;
private:
- virtual secure_vector<byte> do_decrypt(byte& valid_mask,
- const byte in[], size_t in_len) const = 0;
+ virtual secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_len) const = 0;
};
/**
@@ -206,7 +206,7 @@ class BOTAN_DLL PK_Signer final
* @param rng the rng to use
* @return signature
*/
- std::vector<byte> sign_message(const byte in[], size_t length,
+ std::vector<uint8_t> sign_message(const uint8_t in[], size_t length,
RandomNumberGenerator& rng)
{
this->update(in, length);
@@ -219,7 +219,7 @@ class BOTAN_DLL PK_Signer final
* @param rng the rng to use
* @return signature
*/
- std::vector<byte> sign_message(const std::vector<byte>& in,
+ std::vector<uint8_t> sign_message(const std::vector<uint8_t>& in,
RandomNumberGenerator& rng)
{ return sign_message(in.data(), in.size(), rng); }
@@ -229,7 +229,7 @@ class BOTAN_DLL PK_Signer final
* @param rng the rng to use
* @return signature
*/
- std::vector<byte> sign_message(const secure_vector<byte>& in,
+ std::vector<uint8_t> sign_message(const secure_vector<uint8_t>& in,
RandomNumberGenerator& rng)
{ return sign_message(in.data(), in.size(), rng); }
@@ -237,20 +237,20 @@ class BOTAN_DLL PK_Signer final
* Add a message part (single byte).
* @param in the byte to add
*/
- void update(byte in) { update(&in, 1); }
+ void update(uint8_t in) { update(&in, 1); }
/**
* Add a message part.
* @param in the message part to add as a byte array
* @param length the length of the above byte array
*/
- void update(const byte in[], size_t length);
+ void update(const uint8_t in[], size_t length);
/**
* Add a message part.
* @param in the message part to add
*/
- void update(const std::vector<byte>& in) { update(in.data(), in.size()); }
+ void update(const std::vector<uint8_t>& in) { update(in.data(), in.size()); }
/**
* Add a message part.
@@ -258,7 +258,7 @@ class BOTAN_DLL PK_Signer final
*/
void update(const std::string& in)
{
- update(reinterpret_cast<const byte*>(in.data()), in.size());
+ update(reinterpret_cast<const uint8_t*>(in.data()), in.size());
}
/**
@@ -267,7 +267,7 @@ class BOTAN_DLL PK_Signer final
* @param rng the rng to use
* @return signature of the total message
*/
- std::vector<byte> signature(RandomNumberGenerator& rng);
+ std::vector<uint8_t> signature(RandomNumberGenerator& rng);
/**
* Set the output format of the signature.
@@ -313,8 +313,8 @@ class BOTAN_DLL PK_Verifier final
* @param sig_length the length of the above byte array sig
* @return true if the signature is valid
*/
- bool verify_message(const byte msg[], size_t msg_length,
- const byte sig[], size_t sig_length);
+ bool verify_message(const uint8_t msg[], size_t msg_length,
+ const uint8_t sig[], size_t sig_length);
/**
* Verify a signature.
* @param msg the message that the signature belongs to
@@ -322,8 +322,8 @@ class BOTAN_DLL PK_Verifier final
* @return true if the signature is valid
*/
template<typename Alloc, typename Alloc2>
- bool verify_message(const std::vector<byte, Alloc>& msg,
- const std::vector<byte, Alloc2>& sig)
+ bool verify_message(const std::vector<uint8_t, Alloc>& msg,
+ const std::vector<uint8_t, Alloc2>& sig)
{
return verify_message(msg.data(), msg.size(),
sig.data(), sig.size());
@@ -334,7 +334,7 @@ class BOTAN_DLL PK_Verifier final
* signature to be verified.
* @param in the byte to add
*/
- void update(byte in) { update(&in, 1); }
+ void update(uint8_t in) { update(&in, 1); }
/**
* Add a message part of the message corresponding to the
@@ -342,14 +342,14 @@ class BOTAN_DLL PK_Verifier final
* @param msg_part the new message part as a byte array
* @param length the length of the above byte array
*/
- void update(const byte msg_part[], size_t length);
+ void update(const uint8_t msg_part[], size_t length);
/**
* Add a message part of the message corresponding to the
* signature to be verified.
* @param in the new message part
*/
- void update(const std::vector<byte>& in)
+ void update(const std::vector<uint8_t>& in)
{ update(in.data(), in.size()); }
/**
@@ -358,7 +358,7 @@ class BOTAN_DLL PK_Verifier final
*/
void update(const std::string& in)
{
- update(reinterpret_cast<const byte*>(in.data()), in.size());
+ update(reinterpret_cast<const uint8_t*>(in.data()), in.size());
}
/**
@@ -368,7 +368,7 @@ class BOTAN_DLL PK_Verifier final
* @param length the length of the above byte array
* @return true if the signature is valid, false otherwise
*/
- bool check_signature(const byte sig[], size_t length);
+ bool check_signature(const uint8_t sig[], size_t length);
/**
* Check the signature of the buffered message, i.e. the one build
@@ -377,7 +377,7 @@ class BOTAN_DLL PK_Verifier final
* @return true if the signature is valid, false otherwise
*/
template<typename Alloc>
- bool check_signature(const std::vector<byte, Alloc>& sig)
+ bool check_signature(const std::vector<uint8_t, Alloc>& sig)
{
return check_signature(sig.data(), sig.size());
}
@@ -446,9 +446,9 @@ class BOTAN_DLL PK_Key_Agreement final
* @param params_len the length of params in bytes
*/
SymmetricKey derive_key(size_t key_len,
- const byte in[],
+ const uint8_t in[],
size_t in_len,
- const byte params[],
+ const uint8_t params[],
size_t params_len) const;
/*
@@ -460,8 +460,8 @@ class BOTAN_DLL PK_Key_Agreement final
* @param params_len the length of params in bytes
*/
SymmetricKey derive_key(size_t key_len,
- const std::vector<byte>& in,
- const byte params[],
+ const std::vector<uint8_t>& in,
+ const uint8_t params[],
size_t params_len) const
{
return derive_key(key_len, in.data(), in.size(),
@@ -476,11 +476,11 @@ class BOTAN_DLL PK_Key_Agreement final
* @param params extra derivation params
*/
SymmetricKey derive_key(size_t key_len,
- const byte in[], size_t in_len,
+ const uint8_t in[], size_t in_len,
const std::string& params = "") const
{
return derive_key(key_len, in, in_len,
- reinterpret_cast<const byte*>(params.data()),
+ reinterpret_cast<const uint8_t*>(params.data()),
params.length());
}
@@ -491,11 +491,11 @@ class BOTAN_DLL PK_Key_Agreement final
* @param params extra derivation params
*/
SymmetricKey derive_key(size_t key_len,
- const std::vector<byte>& in,
+ const std::vector<uint8_t>& in,
const std::string& params = "") const
{
return derive_key(key_len, in.data(), in.size(),
- reinterpret_cast<const byte*>(params.data()),
+ reinterpret_cast<const uint8_t*>(params.data()),
params.length());
}
@@ -542,7 +542,7 @@ class BOTAN_DLL PK_Encryptor_EME final : public PK_Encryptor
PK_Encryptor_EME& operator=(const PK_Encryptor_EME&) = delete;
PK_Encryptor_EME(const PK_Encryptor_EME&) = delete;
private:
- std::vector<byte> enc(const byte[], size_t,
+ std::vector<uint8_t> enc(const uint8_t[], size_t,
RandomNumberGenerator& rng) const override;
std::unique_ptr<PK_Ops::Encryption> m_op;
@@ -584,8 +584,8 @@ class BOTAN_DLL PK_Decryptor_EME final : public PK_Decryptor
PK_Decryptor_EME& operator=(const PK_Decryptor_EME&) = delete;
PK_Decryptor_EME(const PK_Decryptor_EME&) = delete;
private:
- secure_vector<byte> do_decrypt(byte& valid_mask,
- const byte in[],
+ secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const override;
std::unique_ptr<PK_Ops::Decryption> m_op;
@@ -631,8 +631,8 @@ class BOTAN_DLL PK_KEM_Encryptor final
* @param salt a salt value used in the KDF
* @param salt_len size of the salt value in bytes
*/
- void encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ void encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
@@ -647,8 +647,8 @@ class BOTAN_DLL PK_KEM_Encryptor final
* @param salt a salt value used in the KDF
*/
template<typename Alloc>
- void encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ void encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const std::vector<uint8_t, Alloc>& salt)
@@ -668,8 +668,8 @@ class BOTAN_DLL PK_KEM_Encryptor final
* @param desired_shared_key_len desired size of the shared key in bytes
* @param rng the RNG to use
*/
- void encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ void encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng)
{
@@ -725,7 +725,7 @@ class BOTAN_DLL PK_KEM_Decryptor final
* @param salt_len size of the salt value in bytes
* @return the shared data encryption key
*/
- secure_vector<byte> decrypt(const byte encap_key[],
+ secure_vector<uint8_t> decrypt(const uint8_t encap_key[],
size_t encap_key_len,
size_t desired_shared_key_len,
const uint8_t salt[],
@@ -738,7 +738,7 @@ class BOTAN_DLL PK_KEM_Decryptor final
* @param desired_shared_key_len desired size of the shared key in bytes
* @return the shared data encryption key
*/
- secure_vector<byte> decrypt(const byte encap_key[],
+ secure_vector<uint8_t> decrypt(const uint8_t encap_key[],
size_t encap_key_len,
size_t desired_shared_key_len)
{
@@ -755,9 +755,9 @@ class BOTAN_DLL PK_KEM_Decryptor final
* @return the shared data encryption key
*/
template<typename Alloc1, typename Alloc2>
- secure_vector<byte> decrypt(const std::vector<byte, Alloc1>& encap_key,
+ secure_vector<uint8_t> decrypt(const std::vector<uint8_t, Alloc1>& encap_key,
size_t desired_shared_key_len,
- const std::vector<byte, Alloc2>& salt)
+ const std::vector<uint8_t, Alloc2>& salt)
{
return this->decrypt(encap_key.data(), encap_key.size(),
desired_shared_key_len,
diff --git a/src/lib/pubkey/rfc6979/rfc6979.h b/src/lib/pubkey/rfc6979/rfc6979.h
index 2518535f7..90b4e3697 100644
--- a/src/lib/pubkey/rfc6979/rfc6979.h
+++ b/src/lib/pubkey/rfc6979/rfc6979.h
@@ -34,7 +34,7 @@ class BOTAN_DLL RFC6979_Nonce_Generator
BigInt m_k;
size_t m_qlen, m_rlen;
std::unique_ptr<HMAC_DRBG> m_hmac_drbg;
- secure_vector<byte> m_rng_in, m_rng_out;
+ secure_vector<uint8_t> m_rng_in, m_rng_out;
};
/**
diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp
index 0e364f69f..46192c558 100644
--- a/src/lib/pubkey/rsa/rsa.cpp
+++ b/src/lib/pubkey/rsa/rsa.cpp
@@ -41,7 +41,7 @@ AlgorithmIdentifier RSA_PublicKey::algorithm_identifier() const
AlgorithmIdentifier::USE_NULL_PARAM);
}
-std::vector<byte> RSA_PublicKey::public_key_bits() const
+std::vector<uint8_t> RSA_PublicKey::public_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -52,7 +52,7 @@ std::vector<byte> RSA_PublicKey::public_key_bits() const
}
RSA_PublicKey::RSA_PublicKey(const AlgorithmIdentifier&,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
@@ -72,7 +72,7 @@ bool RSA_PublicKey::check_key(RandomNumberGenerator&, bool) const
return true;
}
-secure_vector<byte> RSA_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> RSA_PrivateKey::private_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -90,7 +90,7 @@ secure_vector<byte> RSA_PrivateKey::private_key_bits() const
}
RSA_PrivateKey::RSA_PrivateKey(const AlgorithmIdentifier&,
- const secure_vector<byte>& key_bits)
+ const secure_vector<uint8_t>& key_bits)
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
@@ -253,7 +253,7 @@ class RSA_Signature_Operation : public PK_Ops::Signature_with_EMSA,
{
}
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator&) override
{
const BigInt m(msg, msg_len);
@@ -277,7 +277,7 @@ class RSA_Decryption_Operation : public PK_Ops::Decryption_with_EME,
{
}
- secure_vector<byte> raw_decrypt(const byte msg[], size_t msg_len) override
+ secure_vector<uint8_t> raw_decrypt(const uint8_t msg[], size_t msg_len) override
{
const BigInt m(msg, msg_len);
const BigInt x = blinded_private_op(m);
@@ -299,8 +299,8 @@ class RSA_KEM_Decryption_Operation : public PK_Ops::KEM_Decryption_with_KDF,
RSA_Private_Operation(key, rng)
{}
- secure_vector<byte>
- raw_kem_decrypt(const byte encap_key[], size_t len) override
+ secure_vector<uint8_t>
+ raw_kem_decrypt(const uint8_t encap_key[], size_t len) override
{
const BigInt m(encap_key, len);
const BigInt x = blinded_private_op(m);
@@ -349,7 +349,7 @@ class RSA_Encryption_Operation : public PK_Ops::Encryption_with_EME,
size_t max_raw_input_bits() const override { return get_max_input_bits(); };
- secure_vector<byte> raw_encrypt(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator&) override
{
BigInt m(msg, msg_len);
@@ -372,7 +372,7 @@ class RSA_Verify_Operation : public PK_Ops::Verification_with_EMSA,
bool with_recovery() const override { return true; }
- secure_vector<byte> verify_mr(const byte msg[], size_t msg_len) override
+ secure_vector<uint8_t> verify_mr(const uint8_t msg[], size_t msg_len) override
{
BigInt m(msg, msg_len);
return BigInt::encode_locked(public_op(m));
@@ -390,8 +390,8 @@ class RSA_KEM_Encryption_Operation : public PK_Ops::KEM_Encryption_with_KDF,
RSA_Public_Operation(key) {}
private:
- void raw_kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& raw_shared_key,
+ void raw_kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& raw_shared_key,
Botan::RandomNumberGenerator& rng) override
{
const BigInt r = BigInt::random_integer(rng, 1, get_n());
diff --git a/src/lib/pubkey/rsa/rsa.h b/src/lib/pubkey/rsa/rsa.h
index 4561aa40f..eb128d413 100644
--- a/src/lib/pubkey/rsa/rsa.h
+++ b/src/lib/pubkey/rsa/rsa.h
@@ -25,7 +25,7 @@ class BOTAN_DLL RSA_PublicKey : public virtual Public_Key
* @param key_bits DER encoded public key bits
*/
RSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Create a public key.
@@ -41,7 +41,7 @@ class BOTAN_DLL RSA_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
/**
* @return public modulus
@@ -88,7 +88,7 @@ class BOTAN_DLL RSA_PrivateKey : public Private_Key, public RSA_PublicKey
* @param key_bits PKCS #8 structure
*/
RSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Construct a private key from the specified parameters.
@@ -138,7 +138,7 @@ class BOTAN_DLL RSA_PrivateKey : public Private_Key, public RSA_PublicKey
const BigInt& get_d1() const { return m_d1; }
const BigInt& get_d2() const { return m_d2; }
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
std::unique_ptr<PK_Ops::Decryption>
create_decryption_op(RandomNumberGenerator& rng,
diff --git a/src/lib/pubkey/x509_key.cpp b/src/lib/pubkey/x509_key.cpp
index 508d41432..700020901 100644
--- a/src/lib/pubkey/x509_key.cpp
+++ b/src/lib/pubkey/x509_key.cpp
@@ -16,7 +16,7 @@ namespace Botan {
namespace X509 {
-std::vector<byte> BER_encode(const Public_Key& key)
+std::vector<uint8_t> BER_encode(const Public_Key& key)
{
// keeping it around for compat
return key.subject_public_key();
@@ -38,7 +38,7 @@ Public_Key* load_key(DataSource& source)
{
try {
AlgorithmIdentifier alg_id;
- std::vector<byte> key_bits;
+ std::vector<uint8_t> key_bits;
if(ASN1::maybe_BER(source) && !PEM_Code::matches(source))
{
@@ -88,7 +88,7 @@ Public_Key* load_key(const std::string& fsname)
/*
* Extract a public key and return it
*/
-Public_Key* load_key(const std::vector<byte>& mem)
+Public_Key* load_key(const std::vector<uint8_t>& mem)
{
DataSource_Memory source(mem);
return X509::load_key(source);
diff --git a/src/lib/pubkey/x509_key.h b/src/lib/pubkey/x509_key.h
index 7162b338e..1844e6568 100644
--- a/src/lib/pubkey/x509_key.h
+++ b/src/lib/pubkey/x509_key.h
@@ -30,7 +30,7 @@ namespace X509 {
* @param key the public key to encode
* @return BER encoding of this key
*/
-BOTAN_DLL std::vector<byte> BER_encode(const Public_Key& key);
+BOTAN_DLL std::vector<uint8_t> BER_encode(const Public_Key& key);
/**
* PEM encode a public key into a string.
@@ -60,7 +60,7 @@ BOTAN_DLL Public_Key* load_key(const std::string& filename);
* @param enc the memory region containing the DER or PEM encoded key
* @return new public key object
*/
-BOTAN_DLL Public_Key* load_key(const std::vector<byte>& enc);
+BOTAN_DLL Public_Key* load_key(const std::vector<uint8_t>& enc);
/**
* Copy a key.
diff --git a/src/lib/pubkey/xmss/xmss_address.h b/src/lib/pubkey/xmss/xmss_address.h
index 07bfd1dbf..4ad30c3d9 100644
--- a/src/lib/pubkey/xmss/xmss_address.h
+++ b/src/lib/pubkey/xmss/xmss_address.h
@@ -112,7 +112,7 @@ class XMSS_Address
**/
void set_type(Type type)
{
- m_data[15] = static_cast<byte>(type);
+ m_data[15] = static_cast<uint8_t>(type);
std::fill(m_data.begin() + 16, m_data.end(), 0);
}
@@ -138,7 +138,7 @@ class XMSS_Address
BOTAN_ASSERT(value != Key_Mask::Mask_LSB_Mode ||
get_type() != Type::OTS_Hash_Address,
"Invalid Key_Mask for current XMSS_Address::Type.");
- m_data[31] = static_cast<byte>(value);
+ m_data[31] = static_cast<uint8_t>(value);
}
/**
@@ -323,12 +323,12 @@ class XMSS_Address
set_hi32(3, value);
}
- const secure_vector<byte>& bytes() const
+ const secure_vector<uint8_t>& bytes() const
{
return m_data;
}
- secure_vector<byte>& bytes()
+ secure_vector<uint8_t>& bytes()
{
return m_data;
}
@@ -353,20 +353,20 @@ class XMSS_Address
set_type(type);
}
- XMSS_Address(const secure_vector<byte>& data) : m_data(data)
+ XMSS_Address(const secure_vector<uint8_t>& data) : m_data(data)
{
BOTAN_ASSERT(m_data.size() == m_address_size,
"XMSS_Address must be of 256 bits size.");
}
- XMSS_Address(secure_vector<byte>&& data) : m_data(std::move(data))
+ XMSS_Address(secure_vector<uint8_t>&& data) : m_data(std::move(data))
{
BOTAN_ASSERT(m_data.size() == m_address_size,
"XMSS_Address must be of 256 bits size.");
}
protected:
- secure_vector<byte> m_data;
+ secure_vector<uint8_t> m_data;
private:
static const size_t m_address_size = 32;
diff --git a/src/lib/pubkey/xmss/xmss_common_ops.cpp b/src/lib/pubkey/xmss/xmss_common_ops.cpp
index aec584201..a66a413bd 100644
--- a/src/lib/pubkey/xmss/xmss_common_ops.cpp
+++ b/src/lib/pubkey/xmss/xmss_common_ops.cpp
@@ -11,26 +11,26 @@
namespace Botan {
void
-XMSS_Common_Ops::randomize_tree_hash(secure_vector<byte>& result,
- const secure_vector<byte>& left,
- const secure_vector<byte>& right,
+XMSS_Common_Ops::randomize_tree_hash(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& left,
+ const secure_vector<uint8_t>& right,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Key_Mode);
- secure_vector<byte> key { m_hash.prf(seed, adrs.bytes()) };
+ secure_vector<uint8_t> key { m_hash.prf(seed, adrs.bytes()) };
adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_MSB_Mode);
- secure_vector<byte> bitmask_l { m_hash.prf(seed, adrs.bytes()) };
+ secure_vector<uint8_t> bitmask_l { m_hash.prf(seed, adrs.bytes()) };
adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_LSB_Mode);
- secure_vector<byte> bitmask_r { m_hash.prf(seed, adrs.bytes()) };
+ secure_vector<uint8_t> bitmask_r { m_hash.prf(seed, adrs.bytes()) };
BOTAN_ASSERT(bitmask_l.size() == left.size() &&
bitmask_r.size() == right.size(),
"Bitmask size doesn't match node size.");
- secure_vector<byte> concat_xor(m_xmss_params.element_size() * 2);
+ secure_vector<uint8_t> concat_xor(m_xmss_params.element_size() * 2);
for(size_t i = 0; i < left.size(); i++)
{
concat_xor[i] = left[i] ^ bitmask_l[i];
@@ -42,10 +42,10 @@ XMSS_Common_Ops::randomize_tree_hash(secure_vector<byte>& result,
void
-XMSS_Common_Ops::create_l_tree(secure_vector<byte>& result,
+XMSS_Common_Ops::create_l_tree(secure_vector<uint8_t>& result,
wots_keysig_t pk,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
size_t l = m_xmss_params.len();
adrs.set_tree_height(0);
diff --git a/src/lib/pubkey/xmss/xmss_common_ops.h b/src/lib/pubkey/xmss/xmss_common_ops.h
index bcf036f5c..26cb27d26 100644
--- a/src/lib/pubkey/xmss/xmss_common_ops.h
+++ b/src/lib/pubkey/xmss/xmss_common_ops.h
@@ -17,7 +17,7 @@
namespace Botan {
-typedef std::vector<secure_vector<byte>> wots_keysig_t;
+typedef std::vector<secure_vector<uint8_t>> wots_keysig_t;
/**
* Operations shared by XMSS signature generation and verification operations.
@@ -41,11 +41,11 @@ class XMSS_Common_Ops
* @param[in] seed The seed for G.
**/
void randomize_tree_hash(
- secure_vector<byte>& result,
- const secure_vector<byte>& left,
- const secure_vector<byte>& right,
+ secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& left,
+ const secure_vector<uint8_t>& right,
XMSS_Address& adrs,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
/**
* Algorithm 8: "ltree"
@@ -59,10 +59,10 @@ class XMSS_Common_Ops
* @param[in] seed The seed generated during the public key generation.
**/
void create_l_tree(
- secure_vector<byte>& result,
+ secure_vector<uint8_t>& result,
wots_keysig_t pk,
XMSS_Address& adrs,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
protected:
XMSS_Parameters m_xmss_params;
diff --git a/src/lib/pubkey/xmss/xmss_hash.cpp b/src/lib/pubkey/xmss/xmss_hash.cpp
index 3731f7751..27352b0e1 100644
--- a/src/lib/pubkey/xmss/xmss_hash.cpp
+++ b/src/lib/pubkey/xmss/xmss_hash.cpp
@@ -33,9 +33,9 @@ XMSS_Hash::XMSS_Hash(const std::string& h_func_name) :
}
void
-XMSS_Hash::h(secure_vector<byte>& result,
- const secure_vector<byte>& key,
- const secure_vector<byte>& data)
+XMSS_Hash::h(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data)
{
m_hash->update(m_zero_padding);
m_hash->update(m_id_h);
@@ -44,9 +44,9 @@ XMSS_Hash::h(secure_vector<byte>& result,
m_hash->final(result);
}
-void XMSS_Hash::h_msg_init(const secure_vector<byte>& randomness,
- const secure_vector<byte>& root,
- const secure_vector<byte>& index_bytes)
+void XMSS_Hash::h_msg_init(const secure_vector<uint8_t>& randomness,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& index_bytes)
{
m_msg_hash->clear();
m_msg_hash->update(m_zero_padding);
@@ -56,26 +56,26 @@ void XMSS_Hash::h_msg_init(const secure_vector<byte>& randomness,
m_msg_hash->update(index_bytes);
}
-void XMSS_Hash::h_msg_update(const secure_vector<byte>& data)
+void XMSS_Hash::h_msg_update(const secure_vector<uint8_t>& data)
{
m_msg_hash->update(data);
}
-void XMSS_Hash::h_msg_update(const byte data[], size_t size)
+void XMSS_Hash::h_msg_update(const uint8_t data[], size_t size)
{
m_msg_hash->update(data, size);
}
-secure_vector<byte> XMSS_Hash::h_msg_final()
+secure_vector<uint8_t> XMSS_Hash::h_msg_final()
{
return m_msg_hash->final();
}
-secure_vector<byte>
-XMSS_Hash::h_msg(const secure_vector<byte>& randomness,
- const secure_vector<byte>& root,
- const secure_vector<byte>& index_bytes,
- const secure_vector<byte>& data)
+secure_vector<uint8_t>
+XMSS_Hash::h_msg(const secure_vector<uint8_t>& randomness,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& index_bytes,
+ const secure_vector<uint8_t>& data)
{
h_msg_init(randomness, root, index_bytes);
m_msg_hash->update(data);
diff --git a/src/lib/pubkey/xmss/xmss_hash.h b/src/lib/pubkey/xmss/xmss_hash.h
index 2cca26658..29a6ff90e 100644
--- a/src/lib/pubkey/xmss/xmss_hash.h
+++ b/src/lib/pubkey/xmss/xmss_hash.h
@@ -35,9 +35,9 @@ class XMSS_Hash
* @param[in] key An n-byte key value.
* @param[in] data A 32-byte XMSS_Address data value
**/
- inline void prf(secure_vector<byte>& result,
- const secure_vector<byte>& key,
- const secure_vector<byte>& data)
+ inline void prf(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data)
{
m_hash->update(m_zero_padding);
m_hash->update(m_id_prf);
@@ -54,8 +54,8 @@ class XMSS_Hash
* @param[in] data A 32-byte XMSS_Address data value
* @return result The hash calculated using key and data.
**/
- inline secure_vector<byte> prf(const secure_vector<byte>& key,
- const secure_vector<byte>& data)
+ inline secure_vector<uint8_t> prf(const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data)
{
m_hash->update(m_zero_padding);
m_hash->update(m_id_prf);
@@ -71,9 +71,9 @@ class XMSS_Hash
* @param[in] key key of length n bytes.
* @param[in] data string of arbitrary length.
**/
- void f(secure_vector<byte>& result,
- const secure_vector<byte>& key,
- const secure_vector<byte>& data)
+ void f(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data)
{
m_hash->update(m_zero_padding);
m_hash->update(m_id_f);
@@ -90,9 +90,9 @@ class XMSS_Hash
* @param[in] key key of length n bytes.
* @param[in] data string of 2n bytes length.
**/
- void h(secure_vector<byte>& result,
- const secure_vector<byte>& key,
- const secure_vector<byte>& data);
+ void h(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data);
/**
* Cryptographic hash function h accepting 3n byte keys and data
@@ -105,10 +105,10 @@ class XMSS_Hash
*
* @return hash value of n-bytes length.
**/
- secure_vector<byte> h_msg(const secure_vector<byte>& randomness,
- const secure_vector<byte>& root,
- const secure_vector<byte>& index_bytes,
- const secure_vector<byte>& data);
+ secure_vector<uint8_t> h_msg(const secure_vector<uint8_t>& randomness,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& index_bytes,
+ const secure_vector<uint8_t>& data);
/**
* Initializes buffered h_msg computation with prefix data.
@@ -117,16 +117,16 @@ class XMSS_Hash
* @param root n-byte root node.
* @param index_bytes Index value padded with leading zeros.
**/
- void h_msg_init(const secure_vector<byte>& randomness,
- const secure_vector<byte>& root,
- const secure_vector<byte>& index_bytes);
+ void h_msg_init(const secure_vector<uint8_t>& randomness,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& index_bytes);
/**
* Adds a message block to buffered h_msg computation.
*
* @param data A message block
**/
- void h_msg_update(const secure_vector<byte>& data);
+ void h_msg_update(const secure_vector<uint8_t>& data);
/**
* Adds a message block to buffered h_msg computation.
@@ -134,7 +134,7 @@ class XMSS_Hash
* @param data A message block
* @param size Length of the message block in bytes.
**/
- void h_msg_update(const byte data[], size_t size);
+ void h_msg_update(const uint8_t data[], size_t size);
/**
* Finalizes buffered h_msg computation and retrieves the result.
@@ -142,15 +142,15 @@ class XMSS_Hash
* @return Hash calculated using the prefix set by h_msg_init() and
* message blocks provided through calls to h_msg_update().
**/
- secure_vector<byte> h_msg_final();
+ secure_vector<uint8_t> h_msg_final();
size_t output_length() const { return m_output_length; };
private:
- static const byte m_id_f = 0x00;
- static const byte m_id_h = 0x01;
- static const byte m_id_hmsg = 0x02;
- static const byte m_id_prf = 0x03;
+ static const uint8_t m_id_f = 0x00;
+ static const uint8_t m_id_h = 0x01;
+ static const uint8_t m_id_hmsg = 0x02;
+ static const uint8_t m_id_prf = 0x03;
const std::string m_hash_func_name;
std::unique_ptr<HashFunction> m_hash;
@@ -158,7 +158,7 @@ class XMSS_Hash
size_t m_output_length;
//32 byte id prefixes prepended to the hash input.
- std::vector<byte> m_zero_padding;
+ std::vector<uint8_t> m_zero_padding;
};
}
diff --git a/src/lib/pubkey/xmss/xmss_index_registry.cpp b/src/lib/pubkey/xmss/xmss_index_registry.cpp
index e26cfdad4..73f962820 100644
--- a/src/lib/pubkey/xmss/xmss_index_registry.cpp
+++ b/src/lib/pubkey/xmss/xmss_index_registry.cpp
@@ -14,15 +14,15 @@ namespace Botan {
const std::string XMSS_Index_Registry::m_index_hash_function = "SHA-256";
uint64_t XMSS_Index_Registry::make_key_id(
- const secure_vector<byte>& private_seed,
- const secure_vector<byte>& prf) const
+ const secure_vector<uint8_t>& private_seed,
+ const secure_vector<uint8_t>& prf) const
{
std::unique_ptr<HashFunction> hash =
HashFunction::create(m_index_hash_function);
BOTAN_ASSERT(hash != nullptr, "XMSS_Index_Registry requires SHA-256");
hash->update(private_seed);
hash->update(prf);
- secure_vector<byte> result = hash->final();
+ secure_vector<uint8_t> result = hash->final();
uint64_t key_id = 0;
for(size_t i = 0; i < sizeof(key_id); i++)
{
@@ -33,8 +33,8 @@ uint64_t XMSS_Index_Registry::make_key_id(
}
std::shared_ptr<Atomic<size_t>>
-XMSS_Index_Registry::get(const secure_vector<byte>& private_seed,
- const secure_vector<byte>& prf)
+XMSS_Index_Registry::get(const secure_vector<uint8_t>& private_seed,
+ const secure_vector<uint8_t>& prf)
{
size_t pos = get(make_key_id(private_seed, prf));
diff --git a/src/lib/pubkey/xmss/xmss_index_registry.h b/src/lib/pubkey/xmss/xmss_index_registry.h
index 77842e4f3..decd50a8a 100644
--- a/src/lib/pubkey/xmss/xmss_index_registry.h
+++ b/src/lib/pubkey/xmss/xmss_index_registry.h
@@ -54,8 +54,8 @@ class XMSS_Index_Registry
* @return last unused leaf index for private_key.
**/
std::shared_ptr<Atomic<size_t>>
- get(const secure_vector<byte>& private_seed,
- const secure_vector<byte>& prf);
+ get(const secure_vector<uint8_t>& private_seed,
+ const secure_vector<uint8_t>& prf);
private:
XMSS_Index_Registry()
@@ -70,8 +70,8 @@ class XMSS_Index_Registry
*
* @return unique integral identifier for an XMSS private key.
**/
- uint64_t make_key_id(const secure_vector<byte>& private_seed,
- const secure_vector<byte>& prf) const;
+ uint64_t make_key_id(const secure_vector<uint8_t>& private_seed,
+ const secure_vector<uint8_t>& prf) const;
/**
* Retrieves the index position of a key within the registry or
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.cpp b/src/lib/pubkey/xmss/xmss_privatekey.cpp
index b409789bf..3f2f949ca 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.cpp
+++ b/src/lib/pubkey/xmss/xmss_privatekey.cpp
@@ -20,7 +20,7 @@
namespace Botan {
-XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<byte>& raw_key)
+XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<uint8_t>& raw_key)
: XMSS_PublicKey(unlock(raw_key)),
XMSS_Common_Ops(XMSS_PublicKey::m_xmss_params.oid()),
m_wots_priv_key(m_wots_params.oid(), m_public_seed),
@@ -58,7 +58,7 @@ XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<byte>& raw_key)
begin = end;
end = begin + m_wots_params.element_size();
- m_wots_priv_key.set_private_seed(secure_vector<byte>(begin, end));
+ m_wots_priv_key.set_private_seed(secure_vector<uint8_t>(begin, end));
set_unused_leaf_index(static_cast<size_t>(unused_leaf));
}
@@ -79,27 +79,27 @@ XMSS_PrivateKey::XMSS_PrivateKey(
adrs));
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_PrivateKey::tree_hash(size_t start_idx,
size_t target_node_height,
XMSS_Address& adrs)
{
- const secure_vector<byte>& seed = this->public_seed();
+ const secure_vector<uint8_t>& seed = this->public_seed();
BOTAN_ASSERT((start_idx % (1 << target_node_height)) == 0,
"Start index must be divisible by 2^{target node height}.");
- std::vector<secure_vector<byte>> nodes(
+ std::vector<secure_vector<uint8_t>> nodes(
XMSS_PublicKey::m_xmss_params.tree_height() + 1,
- secure_vector<byte>(XMSS_PublicKey::m_xmss_params.element_size()));
+ secure_vector<uint8_t>(XMSS_PublicKey::m_xmss_params.element_size()));
// node stack, holds all nodes on stack and one extra "pending" node. This
// temporary node referred to as "node" in the XMSS standard document stays
// a pending element, meaning it is not regarded as element on the stack
// until level is increased.
- std::vector<byte> node_levels(XMSS_PublicKey::m_xmss_params.tree_height() + 1);
+ std::vector<uint8_t> node_levels(XMSS_PublicKey::m_xmss_params.tree_height() + 1);
- byte level = 0;
+ uint8_t level = 0;
XMSS_WOTS_PublicKey pk(m_wots_priv_key.wots_parameters().oid(), seed);
size_t last_idx = static_cast<size_t>(1 << target_node_height) + start_idx;
@@ -152,16 +152,16 @@ XMSS_PrivateKey::recover_global_leaf_index() const
m_prf);
}
-secure_vector<byte> XMSS_PrivateKey::raw_private_key() const
+secure_vector<uint8_t> XMSS_PrivateKey::raw_private_key() const
{
- std::vector<byte> pk { raw_public_key() };
- secure_vector<byte> result(pk.begin(), pk.end());
+ std::vector<uint8_t> pk { raw_public_key() };
+ secure_vector<uint8_t> result(pk.begin(), pk.end());
result.reserve(size());
for(int i = 7; i >= 0; i--)
{
result.push_back(
- static_cast<byte>(
+ static_cast<uint8_t>(
static_cast<uint64_t>(unused_leaf_index()) >> 8 * i));
}
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.h b/src/lib/pubkey/xmss/xmss_privatekey.h
index 79959c247..c8db2d7b8 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_privatekey.h
@@ -60,7 +60,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
*
* @param raw_key An XMSS private key serialized using raw_private_key().
**/
- XMSS_PrivateKey(const secure_vector<byte>& raw_key);
+ XMSS_PrivateKey(const secure_vector<uint8_t>& raw_key);
/**
* Creates a new XMSS private key for the chosen XMSS signature method
@@ -79,10 +79,10 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
**/
XMSS_PrivateKey(XMSS_Parameters::xmss_algorithm_t xmss_algo_id,
size_t idx_leaf,
- const secure_vector<byte>& wots_priv_seed,
- const secure_vector<byte>& prf,
- const secure_vector<byte>& root,
- const secure_vector<byte>& public_seed)
+ const secure_vector<uint8_t>& wots_priv_seed,
+ const secure_vector<uint8_t>& prf,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& public_seed)
: XMSS_PublicKey(xmss_algo_id, root, public_seed),
XMSS_Common_Ops(xmss_algo_id),
m_wots_priv_key(XMSS_PublicKey::m_xmss_params.ots_oid(),
@@ -170,30 +170,30 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
return m_wots_priv_key;
}
- const secure_vector<byte>& prf() const
+ const secure_vector<uint8_t>& prf() const
{
return m_prf;
}
- secure_vector<byte>& prf()
+ secure_vector<uint8_t>& prf()
{
return m_prf;
}
virtual void set_public_seed(
- const secure_vector<byte>& public_seed) override
+ const secure_vector<uint8_t>& public_seed) override
{
m_public_seed = public_seed;
m_wots_priv_key.set_public_seed(public_seed);
}
- virtual void set_public_seed(secure_vector<byte>&& public_seed) override
+ virtual void set_public_seed(secure_vector<uint8_t>&& public_seed) override
{
m_public_seed = std::move(public_seed);
m_wots_priv_key.set_public_seed(m_public_seed);
}
- virtual const secure_vector<byte>& public_seed() const override
+ virtual const secure_vector<uint8_t>& public_seed() const override
{
return m_public_seed;
}
@@ -203,7 +203,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
const std::string&,
const std::string& provider) const override;
- virtual secure_vector<byte> private_key_bits() const override
+ virtual secure_vector<uint8_t> private_key_bits() const override
{
return raw_private_key();
}
@@ -223,7 +223,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
* 4-byte OID, n-byte root node, n-byte public seed,
* 8-byte unused leaf index, n-byte prf seed, n-byte private seed.
**/
- virtual secure_vector<byte> raw_private_key() const;
+ virtual secure_vector<uint8_t> raw_private_key() const;
/**
* Algorithm 9: "treeHash"
* Computes the internal n-byte nodes of a Merkle tree.
@@ -236,7 +236,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
* leftmost leaf being the hash of the WOTS+ pk with index
* start_idx.
**/
- secure_vector<byte> tree_hash(
+ secure_vector<uint8_t> tree_hash(
size_t start_idx,
size_t target_node_height,
XMSS_Address& adrs);
@@ -248,7 +248,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
std::shared_ptr<Atomic<size_t>> recover_global_leaf_index() const;
XMSS_WOTS_PrivateKey m_wots_priv_key;
- secure_vector<byte> m_prf;
+ secure_vector<uint8_t> m_prf;
XMSS_Index_Registry& m_index_reg;
};
diff --git a/src/lib/pubkey/xmss/xmss_publickey.cpp b/src/lib/pubkey/xmss/xmss_publickey.cpp
index 73bcdb1cf..801388253 100644
--- a/src/lib/pubkey/xmss/xmss_publickey.cpp
+++ b/src/lib/pubkey/xmss/xmss_publickey.cpp
@@ -20,7 +20,7 @@
namespace Botan {
-XMSS_PublicKey::XMSS_PublicKey(const std::vector<byte>& raw_key)
+XMSS_PublicKey::XMSS_PublicKey(const std::vector<uint8_t>& raw_key)
: m_xmss_params(XMSS_PublicKey::deserialize_xmss_oid(raw_key)),
m_wots_params(m_xmss_params.ots_oid())
{
@@ -45,7 +45,7 @@ XMSS_PublicKey::XMSS_PublicKey(const std::vector<byte>& raw_key)
}
XMSS_Parameters::xmss_algorithm_t
-XMSS_PublicKey::deserialize_xmss_oid(const std::vector<byte>& raw_key)
+XMSS_PublicKey::deserialize_xmss_oid(const std::vector<uint8_t>& raw_key)
{
if(raw_key.size() < 4)
{
@@ -72,14 +72,14 @@ XMSS_PublicKey::create_verification_op(const std::string&,
throw Provider_Not_Found(algo_name(), provider);
}
-std::vector<byte> XMSS_PublicKey::raw_public_key() const
+std::vector<uint8_t> XMSS_PublicKey::raw_public_key() const
{
- std::vector<byte> result
+ std::vector<uint8_t> result
{
- static_cast<byte>(m_xmss_params.oid() >> 24),
- static_cast<byte>(m_xmss_params.oid() >> 16),
- static_cast<byte>(m_xmss_params.oid() >> 8),
- static_cast<byte>(m_xmss_params.oid())
+ static_cast<uint8_t>(m_xmss_params.oid() >> 24),
+ static_cast<uint8_t>(m_xmss_params.oid() >> 16),
+ static_cast<uint8_t>(m_xmss_params.oid() >> 8),
+ static_cast<uint8_t>(m_xmss_params.oid())
};
std::copy(m_root.begin(), m_root.end(), std::back_inserter(result));
diff --git a/src/lib/pubkey/xmss/xmss_publickey.h b/src/lib/pubkey/xmss/xmss_publickey.h
index 3cc98ff77..9186b16a4 100644
--- a/src/lib/pubkey/xmss/xmss_publickey.h
+++ b/src/lib/pubkey/xmss/xmss_publickey.h
@@ -62,7 +62,7 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
* Creates an XMSS public key from a byte sequence produced by
* raw_private_key().
**/
- XMSS_PublicKey(const std::vector<byte>& raw_key);
+ XMSS_PublicKey(const std::vector<uint8_t>& raw_key);
/**
* Creates a new XMSS public key for a chosen XMSS signature method as
@@ -73,8 +73,8 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
* @param public_seed Public seed value.
**/
XMSS_PublicKey(XMSS_Parameters::xmss_algorithm_t xmss_oid,
- const secure_vector<byte>& root,
- const secure_vector<byte>& public_seed)
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& public_seed)
: m_xmss_params(xmss_oid), m_wots_params(m_xmss_params.ots_oid()),
m_root(root), m_public_seed(public_seed) {}
@@ -87,8 +87,8 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
* @param public_seed Public seed value.
**/
XMSS_PublicKey(XMSS_Parameters::xmss_algorithm_t xmss_oid,
- secure_vector<byte>&& root,
- secure_vector<byte>&& public_seed)
+ secure_vector<uint8_t>&& root,
+ secure_vector<uint8_t>&& public_seed)
: m_xmss_params(xmss_oid), m_wots_params(m_xmss_params.ots_oid()),
m_root(std::move(root)), m_public_seed(std::move(public_seed)) {}
@@ -146,42 +146,42 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
return m_wots_params;
}
- secure_vector<byte>& root()
+ secure_vector<uint8_t>& root()
{
return m_root;
}
- void set_root(const secure_vector<byte>& root)
+ void set_root(const secure_vector<uint8_t>& root)
{
m_root = root;
}
- void set_root(secure_vector<byte>&& root)
+ void set_root(secure_vector<uint8_t>&& root)
{
m_root = std::move(root);
}
- const secure_vector<byte>& root() const
+ const secure_vector<uint8_t>& root() const
{
return m_root;
}
- virtual secure_vector<byte>& public_seed()
+ virtual secure_vector<uint8_t>& public_seed()
{
return m_public_seed;
}
- virtual void set_public_seed(const secure_vector<byte>& public_seed)
+ virtual void set_public_seed(const secure_vector<uint8_t>& public_seed)
{
m_public_seed = public_seed;
}
- virtual void set_public_seed(secure_vector<byte>&& public_seed)
+ virtual void set_public_seed(secure_vector<uint8_t>&& public_seed)
{
m_public_seed = std::move(public_seed);
}
- virtual const secure_vector<byte>& public_seed() const
+ virtual const secure_vector<uint8_t>& public_seed() const
{
return m_public_seed;
}
@@ -221,7 +221,7 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
*
* @return raw public key bits.
**/
- virtual std::vector<byte> public_key_bits() const override
+ virtual std::vector<uint8_t> public_key_bits() const override
{
return raw_public_key();
}
@@ -238,23 +238,23 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
}
/**
- * Generates a non standartized byte sequence representing the XMSS
+ * Generates a non standardized byte sequence representing the XMSS
* public key, as defined in [1] (p. 23, "XMSS Public Key")
*
* @return 4-byte OID, followed by n-byte root node, followed by
* public seed.
**/
- virtual std::vector<byte> raw_public_key() const;
+ virtual std::vector<uint8_t> raw_public_key() const;
protected:
XMSS_Parameters m_xmss_params;
XMSS_WOTS_Parameters m_wots_params;
- secure_vector<byte> m_root;
- secure_vector<byte> m_public_seed;
+ secure_vector<uint8_t> m_root;
+ secure_vector<uint8_t> m_public_seed;
private:
XMSS_Parameters::xmss_algorithm_t deserialize_xmss_oid(
- const std::vector<byte>& raw_key);
+ const std::vector<uint8_t>& raw_key);
};
}
diff --git a/src/lib/pubkey/xmss/xmss_signature.cpp b/src/lib/pubkey/xmss/xmss_signature.cpp
index a54d8d9cd..497a25f2b 100644
--- a/src/lib/pubkey/xmss/xmss_signature.cpp
+++ b/src/lib/pubkey/xmss/xmss_signature.cpp
@@ -10,7 +10,7 @@
namespace Botan {
XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
- const secure_vector<byte>& raw_sig)
+ const secure_vector<uint8_t>& raw_sig)
: m_leaf_idx(0), m_randomness(0, 0x00), m_tree_sig()
{
BOTAN_ASSERT(sizeof(size_t) >= ceil(static_cast<float>(
@@ -38,7 +38,7 @@ XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
{
begin = end;
end = begin + xmss_params.element_size();
- m_tree_sig.ots_signature().push_back(secure_vector<byte>(0));
+ m_tree_sig.ots_signature().push_back(secure_vector<uint8_t>(0));
m_tree_sig.ots_signature().back().reserve(
xmss_params.element_size());
std::copy(begin,
@@ -50,7 +50,7 @@ XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
{
begin = end;
end = begin + xmss_params.element_size();
- m_tree_sig.authentication_path().push_back(secure_vector<byte>(0));
+ m_tree_sig.authentication_path().push_back(secure_vector<uint8_t>(0));
m_tree_sig.authentication_path().back().reserve(
xmss_params.element_size());
std::copy(begin,
@@ -59,18 +59,18 @@ XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
}
}
-secure_vector<byte> XMSS_Signature::bytes() const
+secure_vector<uint8_t> XMSS_Signature::bytes() const
{
- secure_vector<byte> result
+ secure_vector<uint8_t> result
{
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 56U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 48U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 40U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 32U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 24U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 16U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 8U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) )
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 56U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 48U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 40U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 32U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 24U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 16U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 8U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) )
};
std::copy(m_randomness.begin(),
diff --git a/src/lib/pubkey/xmss/xmss_signature.h b/src/lib/pubkey/xmss/xmss_signature.h
index 662aa8988..cbeb8c514 100644
--- a/src/lib/pubkey/xmss/xmss_signature.h
+++ b/src/lib/pubkey/xmss/xmss_signature.h
@@ -22,7 +22,7 @@ class BOTAN_DLL XMSS_Signature
{
public:
/**
- * Creates a signature from an XMSS signature method and a byte sequence
+ * Creates a signature from an XMSS signature method and a uint8_t sequence
* representing a raw signature.
*
* @param oid XMSS signature method
@@ -30,7 +30,7 @@ class BOTAN_DLL XMSS_Signature
* XMSS_Signature::bytes().
**/
XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
- const secure_vector<byte>& raw_sig);
+ const secure_vector<uint8_t>& raw_sig);
/**
* Creates an XMSS Signature from a leaf index used for signature
@@ -41,7 +41,7 @@ class BOTAN_DLL XMSS_Signature
* @param tree_sig A tree signature.
**/
XMSS_Signature(size_t leaf_idx,
- const secure_vector<byte>& randomness,
+ const secure_vector<uint8_t>& randomness,
const XMSS_WOTS_PublicKey::TreeSignature& tree_sig)
: m_leaf_idx(leaf_idx), m_randomness(randomness),
m_tree_sig(tree_sig) {};
@@ -55,7 +55,7 @@ class BOTAN_DLL XMSS_Signature
* @param tree_sig A tree signature.
**/
XMSS_Signature(size_t leaf_idx,
- secure_vector<byte>&& randomness,
+ secure_vector<uint8_t>&& randomness,
XMSS_WOTS_PublicKey::TreeSignature&& tree_sig)
: m_leaf_idx(leaf_idx), m_randomness(std::move(randomness)),
m_tree_sig(std::move(tree_sig)) {};
@@ -63,22 +63,22 @@ class BOTAN_DLL XMSS_Signature
size_t unused_leaf_index() const { return m_leaf_idx; }
void set_unused_leaf_idx(size_t idx) { m_leaf_idx = idx; }
- const secure_vector<byte> randomness() const
+ const secure_vector<uint8_t> randomness() const
{
return m_randomness;
}
- secure_vector<byte>& randomness()
+ secure_vector<uint8_t>& randomness()
{
return m_randomness;
}
- void set_randomness(const secure_vector<byte>& randomness)
+ void set_randomness(const secure_vector<uint8_t>& randomness)
{
m_randomness = randomness;
}
- void set_randomness(secure_vector<byte>&& randomness)
+ void set_randomness(secure_vector<uint8_t>&& randomness)
{
m_randomness = std::move(randomness);
}
@@ -115,11 +115,11 @@ class BOTAN_DLL XMSS_Signature
* @return serialized signature, a sequence of
* (len + h + 1)n bytes.
**/
- secure_vector<byte> bytes() const;
+ secure_vector<uint8_t> bytes() const;
private:
size_t m_leaf_idx;
- secure_vector<byte> m_randomness;
+ secure_vector<uint8_t> m_randomness;
XMSS_WOTS_PublicKey::TreeSignature m_tree_sig;
};
diff --git a/src/lib/pubkey/xmss/xmss_signature_operation.cpp b/src/lib/pubkey/xmss/xmss_signature_operation.cpp
index 80b9c4746..bf7588abe 100644
--- a/src/lib/pubkey/xmss/xmss_signature_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_signature_operation.cpp
@@ -28,7 +28,7 @@ XMSS_Signature_Operation::XMSS_Signature_Operation(
{}
XMSS_WOTS_PublicKey::TreeSignature
-XMSS_Signature_Operation::generate_tree_signature(const secure_vector<byte>& msg,
+XMSS_Signature_Operation::generate_tree_signature(const secure_vector<uint8_t>& msg,
XMSS_PrivateKey& xmss_priv_key,
XMSS_Address& adrs)
{
@@ -42,7 +42,7 @@ XMSS_Signature_Operation::generate_tree_signature(const secure_vector<byte>& msg
}
XMSS_Signature
-XMSS_Signature_Operation::sign(const secure_vector<byte>& msg_hash,
+XMSS_Signature_Operation::sign(const secure_vector<uint8_t>& msg_hash,
XMSS_PrivateKey& xmss_priv_key)
{
XMSS_Address adrs;
@@ -68,18 +68,18 @@ XMSS_Signature_Operation::build_auth_path(XMSS_PrivateKey& priv_key,
return auth_path;
}
-void XMSS_Signature_Operation::update(const byte msg[], size_t msg_len)
+void XMSS_Signature_Operation::update(const uint8_t msg[], size_t msg_len)
{
initialize();
m_hash.h_msg_update(msg, msg_len);
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_Signature_Operation::sign(RandomNumberGenerator&)
{
initialize();
- secure_vector<byte> signature(sign(m_hash.h_msg_final(),
+ secure_vector<uint8_t> signature(sign(m_hash.h_msg_final(),
m_priv_key).bytes());
m_is_initialized = false;
return signature;
@@ -91,7 +91,7 @@ void XMSS_Signature_Operation::initialize()
if(m_is_initialized)
return;
- secure_vector<byte> index_bytes;
+ secure_vector<uint8_t> index_bytes;
// reserve leaf index so it can not be reused in by another signature
// operation using the same private key.
m_leaf_idx = m_priv_key.reserve_unused_leaf_index();
diff --git a/src/lib/pubkey/xmss/xmss_signature_operation.h b/src/lib/pubkey/xmss/xmss_signature_operation.h
index bd22f3428..8b6c87401 100644
--- a/src/lib/pubkey/xmss/xmss_signature_operation.h
+++ b/src/lib/pubkey/xmss/xmss_signature_operation.h
@@ -46,9 +46,9 @@ class BOTAN_DLL XMSS_Signature_Operation : public virtual PK_Ops::Signature,
*
* @return serialized XMSS signature.
**/
- secure_vector<byte> sign(RandomNumberGenerator&) override;
+ secure_vector<uint8_t> sign(RandomNumberGenerator&) override;
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
private:
/**
@@ -60,7 +60,7 @@ class BOTAN_DLL XMSS_Signature_Operation : public virtual PK_Ops::Signature,
* @param adrs A XMSS Address.
**/
XMSS_WOTS_PublicKey::TreeSignature generate_tree_signature(
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_PrivateKey& xmss_priv_key,
XMSS_Address& adrs);
@@ -75,7 +75,7 @@ class BOTAN_DLL XMSS_Signature_Operation : public virtual PK_Ops::Signature,
* @return The signature of msg signed using xmss_priv_key.
**/
XMSS_Signature sign(
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_PrivateKey& xmss_priv_key);
wots_keysig_t build_auth_path(XMSS_PrivateKey& priv_key,
@@ -84,7 +84,7 @@ class BOTAN_DLL XMSS_Signature_Operation : public virtual PK_Ops::Signature,
void initialize();
XMSS_PrivateKey m_priv_key;
- secure_vector<byte> m_randomness;
+ secure_vector<uint8_t> m_randomness;
size_t m_leaf_idx;
bool m_is_initialized;
};
diff --git a/src/lib/pubkey/xmss/xmss_tools.h b/src/lib/pubkey/xmss/xmss_tools.h
index 66eaf28e2..109ab91bd 100644
--- a/src/lib/pubkey/xmss/xmss_tools.h
+++ b/src/lib/pubkey/xmss/xmss_tools.h
@@ -38,7 +38,7 @@ namespace Botan {
template<typename T,
typename U = typename std::enable_if<std::is_integral<T>::value,
void>::type>
- static void concat(secure_vector<byte>& target, const T& src);
+ static void concat(secure_vector<uint8_t>& target, const T& src);
/**
* Concatenates the last n bytes of the byte representation in big-endian
@@ -53,16 +53,16 @@ namespace Botan {
template <typename T,
typename U = typename std::enable_if<std::is_integral<T>::value,
void>::type>
- static void concat(secure_vector<byte>& target, const T& src, size_t len);
+ static void concat(secure_vector<uint8_t>& target, const T& src, size_t len);
private:
XMSS_Tools();
};
template <typename T, typename U>
-void XMSS_Tools::concat(secure_vector<byte>& target, const T& src)
+void XMSS_Tools::concat(secure_vector<uint8_t>& target, const T& src)
{
- const byte* src_bytes = reinterpret_cast<const byte*>(&src);
+ const uint8_t* src_bytes = reinterpret_cast<const uint8_t*>(&src);
if(CPUID::is_little_endian())
{
std::reverse_copy(src_bytes,
@@ -79,7 +79,7 @@ void XMSS_Tools::concat(secure_vector<byte>& target, const T& src)
template <typename T, typename U>
-void XMSS_Tools::concat(secure_vector<byte>& target,
+void XMSS_Tools::concat(secure_vector<uint8_t>& target,
const T& src,
size_t len)
{
@@ -89,7 +89,7 @@ void XMSS_Tools::concat(secure_vector<byte>& target,
target.resize(target.size() + len - sizeof(src), 0);
}
- const byte* src_bytes = reinterpret_cast<const byte*>(&src);
+ const uint8_t* src_bytes = reinterpret_cast<const uint8_t*>(&src);
if(CPUID::is_little_endian())
{
std::reverse_copy(src_bytes,
diff --git a/src/lib/pubkey/xmss/xmss_verification_operation.cpp b/src/lib/pubkey/xmss/xmss_verification_operation.cpp
index 34d7ee647..fe712d4c8 100644
--- a/src/lib/pubkey/xmss/xmss_verification_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_verification_operation.cpp
@@ -20,11 +20,11 @@ XMSS_Verification_Operation::XMSS_Verification_Operation(
{
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_Verification_Operation::root_from_signature(const XMSS_Signature& sig,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
adrs.set_type(XMSS_Address::Type::OTS_Hash_Address);
adrs.set_ots_address(sig.unused_leaf_index());
@@ -38,7 +38,7 @@ XMSS_Verification_Operation::root_from_signature(const XMSS_Signature& sig,
adrs.set_type(XMSS_Address::Type::LTree_Address);
adrs.set_ltree_address(sig.unused_leaf_index());
- std::array<secure_vector<byte>, 2> node;
+ std::array<secure_vector<uint8_t>, 2> node;
create_l_tree(node[0], pub_key_ots, adrs, seed);
adrs.set_type(XMSS_Address::Type::Hash_Tree_Address);
@@ -72,21 +72,21 @@ XMSS_Verification_Operation::root_from_signature(const XMSS_Signature& sig,
bool
XMSS_Verification_Operation::verify(const XMSS_Signature& sig,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
const XMSS_PublicKey& public_key)
{
XMSS_Address adrs;
- secure_vector<byte> index_bytes;
+ secure_vector<uint8_t> index_bytes;
XMSS_Tools::concat(index_bytes,
sig.unused_leaf_index(),
m_xmss_params.element_size());
- secure_vector<byte> msg_digest =
+ secure_vector<uint8_t> msg_digest =
m_hash.h_msg(sig.randomness(),
public_key.root(),
index_bytes,
msg);
- secure_vector<byte> node = root_from_signature(sig,
+ secure_vector<uint8_t> node = root_from_signature(sig,
msg_digest,
adrs,
public_key.public_seed());
@@ -101,18 +101,18 @@ XMSS_Verification_Operation::verify(const XMSS_Signature& sig,
// impossible.
// Possible solution: Change PK_Ops::Verification interface to take the
// signature as constructor argument, make sign a parameterless member call.
-void XMSS_Verification_Operation::update(const byte msg[], size_t msg_len)
+void XMSS_Verification_Operation::update(const uint8_t msg[], size_t msg_len)
{
std::copy(msg, msg + msg_len, std::back_inserter(m_msg_buf));
}
-bool XMSS_Verification_Operation::is_valid_signature(const byte sig[],
+bool XMSS_Verification_Operation::is_valid_signature(const uint8_t sig[],
size_t sig_len)
{
try
{
XMSS_Signature signature(m_pub_key.xmss_parameters().oid(),
- secure_vector<byte>(sig, sig + sig_len));
+ secure_vector<uint8_t>(sig, sig + sig_len));
bool result = verify(signature, m_msg_buf, m_pub_key);
m_msg_buf.clear();
return result;
diff --git a/src/lib/pubkey/xmss/xmss_verification_operation.h b/src/lib/pubkey/xmss/xmss_verification_operation.h
index 35720f73d..1ef836fec 100644
--- a/src/lib/pubkey/xmss/xmss_verification_operation.h
+++ b/src/lib/pubkey/xmss/xmss_verification_operation.h
@@ -35,10 +35,10 @@ namespace Botan {
virtual ~XMSS_Verification_Operation() {}
- virtual bool is_valid_signature(const byte sig[],
+ virtual bool is_valid_signature(const uint8_t sig[],
size_t sig_len) override;
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
private:
/**
@@ -53,11 +53,11 @@ namespace Botan {
* @return An n-byte string holding the value of the root of a tree
* defined by the input parameters.
**/
- secure_vector<byte> root_from_signature(
+ secure_vector<uint8_t> root_from_signature(
const XMSS_Signature& sig,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_Address& ards,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
/**
* Algorithm 14: "XMSS_verify"
@@ -70,11 +70,11 @@ namespace Botan {
* @return true if signature sig is valid for msg, false otherwise.
**/
bool verify(const XMSS_Signature& sig,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
const XMSS_PublicKey& pub_key);
XMSS_PublicKey m_pub_key;
- secure_vector<byte> m_msg_buf;
+ secure_vector<uint8_t> m_msg_buf;
};
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h b/src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h
index deb5d7f87..66941fbfd 100644
--- a/src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h
@@ -54,7 +54,7 @@ class XMSS_WOTS_Addressed_PrivateKey
return m_priv_key.pkcs8_algorithm_identifier();
}
- virtual secure_vector<byte> private_key_bits() const override
+ virtual secure_vector<uint8_t> private_key_bits() const override
{
return m_priv_key.private_key_bits();
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h b/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h
index 74e686f9f..144be4efd 100644
--- a/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h
@@ -82,7 +82,7 @@ class XMSS_WOTS_Addressed_PublicKey : public virtual Public_Key
return m_pub_key.estimated_strength();
}
- virtual std::vector<byte> public_key_bits() const override
+ virtual std::vector<uint8_t> public_key_bits() const override
{
return m_pub_key.public_key_bits();
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp b/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp
index 5d0349677..4472b3881 100644
--- a/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp
@@ -13,11 +13,11 @@
namespace Botan {
void
-XMSS_WOTS_Common_Ops::chain(secure_vector<byte>& result,
+XMSS_WOTS_Common_Ops::chain(secure_vector<uint8_t>& result,
size_t start_idx,
size_t steps,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
for(size_t i = start_idx;
i < (start_idx + steps) && i < m_wots_params.wots_parameter();
diff --git a/src/lib/pubkey/xmss/xmss_wots_common_ops.h b/src/lib/pubkey/xmss/xmss_wots_common_ops.h
index f3153515c..471b67c77 100644
--- a/src/lib/pubkey/xmss/xmss_wots_common_ops.h
+++ b/src/lib/pubkey/xmss/xmss_wots_common_ops.h
@@ -40,11 +40,11 @@ class XMSS_WOTS_Common_Ops
* @param[in] adrs An OTS Hash Address.
* @param[in] seed A Seed.
**/
- void chain(secure_vector<byte>& result,
+ void chain(secure_vector<uint8_t>& result,
size_t start_idx,
size_t steps,
XMSS_Address& adrs,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
XMSS_WOTS_Parameters m_wots_params;
XMSS_Hash m_hash;
diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
index 3a1c1902d..704bcab36 100644
--- a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
@@ -87,10 +87,10 @@ XMSS_WOTS_Parameters::XMSS_WOTS_Parameters(ots_algorithm_t oid)
"\"len\" detedted.");
}
-secure_vector<byte>
-XMSS_WOTS_Parameters::base_w(const secure_vector<byte>& msg, size_t out_size) const
+secure_vector<uint8_t>
+XMSS_WOTS_Parameters::base_w(const secure_vector<uint8_t>& msg, size_t out_size) const
{
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
size_t in = 0;
size_t total = 0;
size_t bits = 0;
@@ -104,24 +104,24 @@ XMSS_WOTS_Parameters::base_w(const secure_vector<byte>& msg, size_t out_size) co
bits += 8;
}
bits -= m_lg_w;
- result.push_back(static_cast<byte>((total >> bits) & (m_w - 1)));
+ result.push_back(static_cast<uint8_t>((total >> bits) & (m_w - 1)));
}
return result;
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_WOTS_Parameters::base_w(size_t value) const
{
value <<= (8 - ((m_len_2 * m_lg_w) % 8));
size_t len_2_bytes = static_cast<size_t>(
ceil(static_cast<float>(m_len_2 * m_lg_w) / 8.f));
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
XMSS_Tools::concat(result, value, len_2_bytes);
return base_w(result, m_len_2);
}
void
-XMSS_WOTS_Parameters::append_checksum(secure_vector<byte>& data)
+XMSS_WOTS_Parameters::append_checksum(secure_vector<uint8_t>& data)
{
size_t csum = 0;
@@ -130,7 +130,7 @@ XMSS_WOTS_Parameters::append_checksum(secure_vector<byte>& data)
csum += wots_parameter() - 1 - data[i];
}
- secure_vector<byte> csum_bytes = base_w(csum);
+ secure_vector<uint8_t> csum_bytes = base_w(csum);
std::move(csum_bytes.begin(), csum_bytes.end(), std::back_inserter(data));
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.h b/src/lib/pubkey/xmss/xmss_wots_parameters.h
index cc89c3d4a..d48348316 100644
--- a/src/lib/pubkey/xmss/xmss_wots_parameters.h
+++ b/src/lib/pubkey/xmss/xmss_wots_parameters.h
@@ -55,11 +55,11 @@ class XMSS_WOTS_Parameters
*
* @return Input string converted to the given base.
**/
- secure_vector<byte> base_w(const secure_vector<byte>& msg, size_t out_size) const;
+ secure_vector<uint8_t> base_w(const secure_vector<uint8_t>& msg, size_t out_size) const;
- secure_vector<byte> base_w(size_t value) const;
+ secure_vector<uint8_t> base_w(size_t value) const;
- void append_checksum(secure_vector<byte>& data);
+ void append_checksum(secure_vector<uint8_t>& data);
/**
* @return XMSS WOTS registry name for the chosen parameter set.
diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp b/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp
index e3f4cab94..d7cd3479c 100644
--- a/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp
@@ -14,10 +14,10 @@
namespace Botan {
wots_keysig_t
-XMSS_WOTS_PrivateKey::generate(const secure_vector<byte>& priv_seed)
+XMSS_WOTS_PrivateKey::generate(const secure_vector<uint8_t>& priv_seed)
{
wots_keysig_t priv_key(m_wots_params.len(),
- secure_vector<byte>(0));
+ secure_vector<uint8_t>(0));
for(size_t i = 0; i < m_wots_params.len(); i++)
{
@@ -57,11 +57,11 @@ XMSS_WOTS_PrivateKey::generate_public_key(XMSS_WOTS_PublicKey& pub_key,
wots_keysig_t
XMSS_WOTS_PrivateKey::sign(
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_Address& adrs)
{
- secure_vector<byte> msg_digest
+ secure_vector<uint8_t> msg_digest
{
m_wots_params.base_w(msg, m_wots_params.len_1())
};
diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.h b/src/lib/pubkey/xmss/xmss_wots_privatekey.h
index cf84fd076..445105640 100644
--- a/src/lib/pubkey/xmss/xmss_wots_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.h
@@ -65,7 +65,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
* @param rng A random number generator to use for key generation.
**/
XMSS_WOTS_PrivateKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& public_seed,
+ const secure_vector<uint8_t>& public_seed,
RandomNumberGenerator &rng)
: XMSS_WOTS_PublicKey(oid, public_seed),
m_private_seed(rng.random_vec(m_wots_params.element_size()))
@@ -85,7 +85,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
* of public keys derived from this private key.
**/
XMSS_WOTS_PrivateKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& public_seed)
+ const secure_vector<uint8_t>& public_seed)
: XMSS_WOTS_PublicKey(oid, public_seed)
{}
@@ -100,8 +100,8 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
* @param private_seed A secret uniformly random n-byte value.
**/
XMSS_WOTS_PrivateKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& public_seed,
- const secure_vector<byte>& private_seed)
+ const secure_vector<uint8_t>& public_seed,
+ const secure_vector<uint8_t>& private_seed)
: XMSS_WOTS_PublicKey(oid, public_seed),
m_private_seed(private_seed)
{
@@ -118,7 +118,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
**/
wots_keysig_t operator[](size_t i)
{
- secure_vector<byte> idx_bytes;
+ secure_vector<uint8_t> idx_bytes;
XMSS_Tools::concat(idx_bytes, i, m_wots_params.element_size());
m_hash.h(idx_bytes, m_private_seed, idx_bytes);
return generate(idx_bytes);
@@ -134,12 +134,12 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
**/
wots_keysig_t operator[](const XMSS_Address& adrs)
{
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
m_hash.prf(result, m_private_seed, adrs.bytes());
return generate(result);
}
- wots_keysig_t generate_private_key(const secure_vector<byte>& priv_seed);
+ wots_keysig_t generate_private_key(const secure_vector<uint8_t>& priv_seed);
/**
* Algorithm 4: "WOTS_genPK"
@@ -179,7 +179,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
*
* @return signature for msg.
**/
- wots_keysig_t sign(const secure_vector<byte>& msg,
+ wots_keysig_t sign(const secure_vector<uint8_t>& msg,
XMSS_Address& adrs);
/**
@@ -188,7 +188,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
*
* @return secret seed.
**/
- const secure_vector<byte>& private_seed() const
+ const secure_vector<uint8_t>& private_seed() const
{
return m_private_seed;
}
@@ -199,7 +199,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
*
* @param private_seed Uniformly random n-byte value.
**/
- void set_private_seed(const secure_vector<byte>& private_seed)
+ void set_private_seed(const secure_vector<uint8_t>& private_seed)
{
m_private_seed = private_seed;
}
@@ -210,7 +210,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
*
* @param private_seed Uniformly random n-byte value.
**/
- void set_private_seed(secure_vector<byte>&& private_seed)
+ void set_private_seed(secure_vector<uint8_t>&& private_seed)
{
m_private_seed = std::move(private_seed);
}
@@ -226,7 +226,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
const std::string&,
const std::string& provider) const override;
- virtual secure_vector<byte> private_key_bits() const override
+ virtual secure_vector<uint8_t> private_key_bits() const override
{
throw Not_Implemented("No PKCS8 key format defined for XMSS-WOTS.");
}
@@ -241,9 +241,9 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
* @returns a vector of length key_size() of vectors of n bytes length
* containing uniformly random data.
**/
- wots_keysig_t generate(const secure_vector<byte>& private_seed);
+ wots_keysig_t generate(const secure_vector<uint8_t>& private_seed);
- secure_vector<byte> m_private_seed;
+ secure_vector<uint8_t> m_private_seed;
};
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.cpp b/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
index 0eea59ea3..5ae04e71f 100644
--- a/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
@@ -14,11 +14,11 @@
namespace Botan {
void
-XMSS_WOTS_PublicKey::chain(secure_vector<byte>& result,
+XMSS_WOTS_PublicKey::chain(secure_vector<uint8_t>& result,
size_t start_idx,
size_t steps,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
for(size_t i = start_idx;
i < (start_idx + steps) && i < m_wots_params.wots_parameter();
@@ -39,12 +39,12 @@ XMSS_WOTS_PublicKey::chain(secure_vector<byte>& result,
}
wots_keysig_t
-XMSS_WOTS_PublicKey::pub_key_from_signature(const secure_vector<byte>& msg,
+XMSS_WOTS_PublicKey::pub_key_from_signature(const secure_vector<uint8_t>& msg,
const wots_keysig_t& sig,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
- secure_vector<byte> msg_digest
+ secure_vector<uint8_t> msg_digest
{
m_wots_params.base_w(msg, m_wots_params.len_1())
};
diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.h b/src/lib/pubkey/xmss/xmss_wots_publickey.h
index 4f414de27..5d973fd6a 100644
--- a/src/lib/pubkey/xmss/xmss_wots_publickey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_publickey.h
@@ -23,7 +23,7 @@
namespace Botan {
-typedef std::vector<secure_vector<byte>> wots_keysig_t;
+typedef std::vector<secure_vector<uint8_t>> wots_keysig_t;
/**
* A Winternitz One Time Signature public key for use with Extended Hash-Based
@@ -109,7 +109,7 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param public_seed A precomputed public seed of n-bytes length.
**/
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- secure_vector<byte> public_seed)
+ secure_vector<uint8_t> public_seed)
: m_wots_params(oid),
m_hash(m_wots_params.hash_function_name()),
m_public_seed(public_seed) {}
@@ -125,7 +125,7 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param key Precomputed raw key data of the XMSS_WOTS_PublicKey.
**/
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- secure_vector<byte>&& public_seed,
+ secure_vector<uint8_t>&& public_seed,
wots_keysig_t&& key)
: m_wots_params(oid),
m_hash(m_wots_params.hash_function_name()),
@@ -144,7 +144,7 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param key Precomputed raw key data of the XMSS_WOTS_PublicKey.
**/
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& public_seed,
+ const secure_vector<uint8_t>& public_seed,
const wots_keysig_t& key)
: m_wots_params(oid),
m_hash(m_wots_params.hash_function_name()),
@@ -164,10 +164,10 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param public_seed The public public_seed.
**/
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
const wots_keysig_t& sig,
XMSS_Address& adrs,
- const secure_vector<byte>& public_seed)
+ const secure_vector<uint8_t>& public_seed)
: m_wots_params(oid),
m_hash(m_wots_params.hash_function_name()),
m_key(pub_key_from_signature(msg,
@@ -184,8 +184,8 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param i index of the element.
* @returns n-byte element addressed by i.
**/
- const secure_vector<byte>& operator[](size_t i) const { return m_key[i]; }
- secure_vector<byte>& operator[](size_t i) { return m_key[i]; }
+ const secure_vector<uint8_t>& operator[](size_t i) const { return m_key[i]; }
+ secure_vector<uint8_t>& operator[](size_t i) { return m_key[i]; }
/**
* Convert the key into the raw key data. The key becomes a length
@@ -199,16 +199,16 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
**/
operator wots_keysig_t& () { return m_key; }
- const secure_vector<byte>& public_seed() const { return m_public_seed; }
+ const secure_vector<uint8_t>& public_seed() const { return m_public_seed; }
- secure_vector<byte>& public_seed() { return m_public_seed; }
+ secure_vector<uint8_t>& public_seed() { return m_public_seed; }
- void set_public_seed(const secure_vector<byte>& public_seed)
+ void set_public_seed(const secure_vector<uint8_t>& public_seed)
{
m_public_seed = public_seed;
}
- void set_public_seed(secure_vector<byte>&& public_seed)
+ void set_public_seed(secure_vector<uint8_t>&& public_seed)
{
m_public_seed = std::move(public_seed);
}
@@ -261,7 +261,7 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
return m_wots_params.estimated_strength();
}
- virtual std::vector<byte> public_key_bits() const override
+ virtual std::vector<uint8_t> public_key_bits() const override
{
throw Not_Implemented("No key format defined for XMSS-WOTS");
}
@@ -293,17 +293,17 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param public_seed A public seed.
*
**/
- void chain(secure_vector<byte>& x,
+ void chain(secure_vector<uint8_t>& x,
size_t start_idx,
size_t steps,
XMSS_Address& adrs,
- const secure_vector<byte>& public_seed);
+ const secure_vector<uint8_t>& public_seed);
XMSS_WOTS_Parameters m_wots_params;
XMSS_Hash m_hash;
wots_keysig_t m_key;
- secure_vector<byte> m_public_seed;
+ secure_vector<uint8_t> m_public_seed;
private:
/**
@@ -319,10 +319,10 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @return Temporary WOTS+ public key.
**/
wots_keysig_t pub_key_from_signature(
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
const wots_keysig_t& sig,
XMSS_Address& adrs,
- const secure_vector<byte>& public_seed);
+ const secure_vector<uint8_t>& public_seed);
};
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp b/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp
index 532e4d782..07d43e3bb 100644
--- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp
@@ -26,7 +26,7 @@ XMSS_WOTS_Signature_Operation::XMSS_WOTS_Signature_Operation(
}
void
-XMSS_WOTS_Signature_Operation::update(const byte msg[], size_t msg_len)
+XMSS_WOTS_Signature_Operation::update(const uint8_t msg[], size_t msg_len)
{
BOTAN_ASSERT(msg_len == m_priv_key.private_key().wots_parameters().
element_size() &&
@@ -37,10 +37,10 @@ XMSS_WOTS_Signature_Operation::update(const byte msg[], size_t msg_len)
m_msg_buf.push_back(msg[i]);
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_WOTS_Signature_Operation::sign(RandomNumberGenerator&)
{
- secure_vector<byte> result(0);
+ secure_vector<uint8_t> result(0);
result.reserve(m_wots_params.len() * m_wots_params.element_size());
XMSS_WOTS_PrivateKey& priv_key = m_priv_key.private_key();
for(const auto& node : priv_key.sign(m_msg_buf, m_priv_key.address()))
diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h
index 59de4ea34..f319ac138 100644
--- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h
+++ b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h
@@ -43,17 +43,17 @@ class XMSS_WOTS_Signature_Operation : public virtual PK_Ops::Signature,
*
* @return serialized Winternitz One Time Signature.
**/
- secure_vector<byte> sign(RandomNumberGenerator&) override;
+ secure_vector<uint8_t> sign(RandomNumberGenerator&) override;
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
private:
- wots_keysig_t sign(const secure_vector<byte>& msg,
+ wots_keysig_t sign(const secure_vector<uint8_t>& msg,
const wots_keysig_t& priv_key,
XMSS_Address& adrs,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
XMSS_WOTS_Addressed_PrivateKey m_priv_key;
- secure_vector<byte> m_msg_buf;
+ secure_vector<uint8_t> m_msg_buf;
};
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp b/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp
index d66c508bb..cab33870a 100644
--- a/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp
@@ -26,7 +26,7 @@ XMSS_WOTS_Verification_Operation::XMSS_WOTS_Verification_Operation(
}
void
-XMSS_WOTS_Verification_Operation::update(const byte msg[], size_t msg_len)
+XMSS_WOTS_Verification_Operation::update(const uint8_t msg[], size_t msg_len)
{
BOTAN_ASSERT(msg_len == m_pub_key.public_key().wots_parameters().
element_size() &&
@@ -39,7 +39,7 @@ XMSS_WOTS_Verification_Operation::update(const byte msg[], size_t msg_len)
}
}
-bool XMSS_WOTS_Verification_Operation::is_valid_signature(const byte sig[],
+bool XMSS_WOTS_Verification_Operation::is_valid_signature(const uint8_t sig[],
size_t sig_len)
{
const XMSS_WOTS_Parameters& w = m_pub_key.public_key().wots_parameters();
@@ -56,7 +56,7 @@ bool XMSS_WOTS_Verification_Operation::is_valid_signature(const byte sig[],
{
begin = end;
end = begin + w.element_size();
- signature.push_back(secure_vector<byte>(sig + begin, sig + end));
+ signature.push_back(secure_vector<uint8_t>(sig + begin, sig + end));
}
XMSS_WOTS_PublicKey pubkey_msg(w.oid(),
diff --git a/src/lib/pubkey/xmss/xmss_wots_verification_operation.h b/src/lib/pubkey/xmss/xmss_wots_verification_operation.h
index a0cb0709f..0bc5f0db9 100644
--- a/src/lib/pubkey/xmss/xmss_wots_verification_operation.h
+++ b/src/lib/pubkey/xmss/xmss_wots_verification_operation.h
@@ -34,14 +34,14 @@ class XMSS_WOTS_Verification_Operation
virtual ~XMSS_WOTS_Verification_Operation() {}
- virtual bool is_valid_signature(const byte sig[],
+ virtual bool is_valid_signature(const uint8_t sig[],
size_t sig_len) override;
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
private:
XMSS_WOTS_Addressed_PublicKey m_pub_key;
- secure_vector<byte> m_msg_buf;
+ secure_vector<uint8_t> m_msg_buf;
};
}
diff --git a/src/lib/rng/auto_rng/auto_rng.cpp b/src/lib/rng/auto_rng/auto_rng.cpp
index e631604c9..ec439e7cf 100644
--- a/src/lib/rng/auto_rng/auto_rng.cpp
+++ b/src/lib/rng/auto_rng/auto_rng.cpp
@@ -86,7 +86,7 @@ std::string AutoSeeded_RNG::name() const
return m_rng->name();
}
-void AutoSeeded_RNG::add_entropy(const byte in[], size_t len)
+void AutoSeeded_RNG::add_entropy(const uint8_t in[], size_t len)
{
m_rng->add_entropy(in, len);
}
@@ -98,13 +98,13 @@ size_t AutoSeeded_RNG::reseed(Entropy_Sources& srcs,
return m_rng->reseed(srcs, poll_bits, poll_timeout);
}
-void AutoSeeded_RNG::randomize(byte output[], size_t output_len)
+void AutoSeeded_RNG::randomize(uint8_t output[], size_t output_len)
{
randomize_with_ts_input(output, output_len);
}
-void AutoSeeded_RNG::randomize_with_input(byte output[], size_t output_len,
- const byte ad[], size_t ad_len)
+void AutoSeeded_RNG::randomize_with_input(uint8_t output[], size_t output_len,
+ const uint8_t ad[], size_t ad_len)
{
m_rng->randomize_with_input(output, output_len, ad, ad_len);
}
diff --git a/src/lib/rng/auto_rng/auto_rng.h b/src/lib/rng/auto_rng/auto_rng.h
index 9ae9b9c38..f634b8ff2 100644
--- a/src/lib/rng/auto_rng/auto_rng.h
+++ b/src/lib/rng/auto_rng/auto_rng.h
@@ -20,10 +20,10 @@ class Stateful_RNG;
class BOTAN_DLL AutoSeeded_RNG final : public RandomNumberGenerator
{
public:
- void randomize(byte out[], size_t len) override;
+ void randomize(uint8_t out[], size_t len) override;
- void randomize_with_input(byte output[], size_t output_len,
- const byte input[], size_t input_len) override;
+ void randomize_with_input(uint8_t output[], size_t output_len,
+ const uint8_t input[], size_t input_len) override;
bool is_seeded() const override;
@@ -36,7 +36,7 @@ class BOTAN_DLL AutoSeeded_RNG final : public RandomNumberGenerator
size_t poll_bits = BOTAN_RNG_RESEED_POLL_BITS,
std::chrono::milliseconds poll_timeout = BOTAN_RNG_RESEED_DEFAULT_TIMEOUT) override;
- void add_entropy(const byte in[], size_t len) override;
+ void add_entropy(const uint8_t in[], size_t len) override;
std::string name() const override;
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.cpp b/src/lib/rng/hmac_drbg/hmac_drbg.cpp
index 2e056e726..e47d49628 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.cpp
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.cpp
@@ -81,7 +81,7 @@ void HMAC_DRBG::clear()
m_V.resize(m_mac->output_length());
for(size_t i = 0; i != m_V.size(); ++i)
m_V[i] = 0x01;
- m_mac->set_key(std::vector<byte>(m_mac->output_length(), 0x00));
+ m_mac->set_key(std::vector<uint8_t>(m_mac->output_length(), 0x00));
}
std::string HMAC_DRBG::name() const
@@ -89,7 +89,7 @@ std::string HMAC_DRBG::name() const
return "HMAC_DRBG(" + m_mac->name() + ")";
}
-void HMAC_DRBG::randomize(byte output[], size_t output_len)
+void HMAC_DRBG::randomize(uint8_t output[], size_t output_len)
{
randomize_with_input(output, output_len, nullptr, 0);
}
@@ -98,8 +98,8 @@ void HMAC_DRBG::randomize(byte output[], size_t output_len)
* HMAC_DRBG generation
* See NIST SP800-90A section 10.1.2.5
*/
-void HMAC_DRBG::randomize_with_input(byte output[], size_t output_len,
- const byte input[], size_t input_len)
+void HMAC_DRBG::randomize_with_input(uint8_t output[], size_t output_len,
+ const uint8_t input[], size_t input_len)
{
while(output_len > 0)
{
@@ -133,7 +133,7 @@ void HMAC_DRBG::randomize_with_input(byte output[], size_t output_len,
* Reset V and the mac key with new values
* See NIST SP800-90A section 10.1.2.2
*/
-void HMAC_DRBG::update(const byte input[], size_t input_len)
+void HMAC_DRBG::update(const uint8_t input[], size_t input_len)
{
m_mac->update(m_V);
m_mac->update(0x00);
@@ -155,7 +155,7 @@ void HMAC_DRBG::update(const byte input[], size_t input_len)
}
}
-void HMAC_DRBG::add_entropy(const byte input[], size_t input_len)
+void HMAC_DRBG::add_entropy(const uint8_t input[], size_t input_len)
{
update(input, input_len);
}
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.h b/src/lib/rng/hmac_drbg/hmac_drbg.h
index 189edbcdf..1c95cb304 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.h
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.h
@@ -134,20 +134,20 @@ class BOTAN_DLL HMAC_DRBG final : public Stateful_RNG
void clear() override;
- void randomize(byte output[], size_t output_len) override;
+ void randomize(uint8_t output[], size_t output_len) override;
- void randomize_with_input(byte output[], size_t output_len,
- const byte input[], size_t input_len) override;
+ void randomize_with_input(uint8_t output[], size_t output_len,
+ const uint8_t input[], size_t input_len) override;
- void add_entropy(const byte input[], size_t input_len) override;
+ void add_entropy(const uint8_t input[], size_t input_len) override;
size_t security_level() const override;
private:
- void update(const byte input[], size_t input_len);
+ void update(const uint8_t input[], size_t input_len);
std::unique_ptr<MessageAuthenticationCode> m_mac;
- secure_vector<byte> m_V;
+ secure_vector<uint8_t> m_V;
const size_t m_max_number_of_bytes_per_request;
};
diff --git a/src/lib/rng/rng.cpp b/src/lib/rng/rng.cpp
index a2dd3d3a4..4551ffe83 100644
--- a/src/lib/rng/rng.cpp
+++ b/src/lib/rng/rng.cpp
@@ -14,21 +14,21 @@
namespace Botan {
-void RandomNumberGenerator::randomize_with_ts_input(byte output[], size_t output_len)
+void RandomNumberGenerator::randomize_with_ts_input(uint8_t output[], size_t output_len)
{
/*
Form additional input which is provided to the PRNG implementation
to paramaterize the KDF output.
*/
- byte additional_input[16] = { 0 };
+ uint8_t additional_input[16] = { 0 };
store_le(OS::get_system_timestamp_ns(), additional_input);
store_le(OS::get_processor_timestamp(), additional_input + 8);
randomize_with_input(output, output_len, additional_input, sizeof(additional_input));
}
-void RandomNumberGenerator::randomize_with_input(byte output[], size_t output_len,
- const byte input[], size_t input_len)
+void RandomNumberGenerator::randomize_with_input(uint8_t output[], size_t output_len,
+ const uint8_t input[], size_t input_len)
{
this->add_entropy(input, input_len);
this->randomize(output, output_len);
@@ -43,7 +43,7 @@ size_t RandomNumberGenerator::reseed(Entropy_Sources& srcs,
void RandomNumberGenerator::reseed_from_rng(RandomNumberGenerator& rng, size_t poll_bits)
{
- secure_vector<byte> buf(poll_bits / 8);
+ secure_vector<uint8_t> buf(poll_bits / 8);
rng.randomize(buf.data(), buf.size());
this->add_entropy(buf.data(), buf.size());
}
diff --git a/src/lib/rng/rng.h b/src/lib/rng/rng.h
index acd131b18..d8d3c855f 100644
--- a/src/lib/rng/rng.h
+++ b/src/lib/rng/rng.h
@@ -40,7 +40,7 @@ class BOTAN_DLL RandomNumberGenerator
* @param output the byte array to hold the random output.
* @param length the length of the byte array output in bytes.
*/
- virtual void randomize(byte output[], size_t length) = 0;
+ virtual void randomize(uint8_t output[], size_t length) = 0;
/**
* Incorporate some additional data into the RNG state. For
@@ -52,7 +52,7 @@ class BOTAN_DLL RandomNumberGenerator
* @param input a byte array containg the entropy to be added
* @param length the length of the byte array in
*/
- virtual void add_entropy(const byte input[], size_t length) = 0;
+ virtual void add_entropy(const uint8_t input[], size_t length) = 0;
/**
* Incorporate some additional data into the RNG state.
@@ -77,8 +77,8 @@ class BOTAN_DLL RandomNumberGenerator
* @param input entropy buffer to incorporate
* @param input_len size of the input buffer in bytes
*/
- virtual void randomize_with_input(byte output[], size_t output_len,
- const byte input[], size_t input_len);
+ virtual void randomize_with_input(uint8_t output[], size_t output_len,
+ const uint8_t input[], size_t input_len);
/**
* This calls `randomize_with_input` using some timestamps as extra input.
@@ -89,7 +89,7 @@ class BOTAN_DLL RandomNumberGenerator
* both of the duplicated RNG states later incorporate a timestamp (and the
* timestamps don't themselves repeat), their outputs will diverge.
*/
- virtual void randomize_with_ts_input(byte output[], size_t output_len);
+ virtual void randomize_with_ts_input(uint8_t output[], size_t output_len);
/**
* @return the name of this RNG type
@@ -130,9 +130,9 @@ class BOTAN_DLL RandomNumberGenerator
* @param bytes number of bytes in the result
* @return randomized vector of length bytes
*/
- secure_vector<byte> random_vec(size_t bytes)
+ secure_vector<uint8_t> random_vec(size_t bytes)
{
- secure_vector<byte> output(bytes);
+ secure_vector<uint8_t> output(bytes);
this->randomize(output.data(), output.size());
return output;
}
@@ -141,19 +141,19 @@ class BOTAN_DLL RandomNumberGenerator
* Return a random byte
* @return random byte
*/
- byte next_byte()
+ uint8_t next_byte()
{
- byte b;
+ uint8_t b;
this->randomize(&b, 1);
return b;
}
/**
- * @return a random byte that is not the zero byte
+ * @return a random byte that is greater than zero
*/
- byte next_nonzero_byte()
+ uint8_t next_nonzero_byte()
{
- byte b = this->next_byte();
+ uint8_t b = this->next_byte();
while(b == 0)
b = this->next_byte();
return b;
@@ -191,12 +191,12 @@ class BOTAN_DLL Null_RNG final : public RandomNumberGenerator
void clear() override {}
- void randomize(byte[], size_t) override
+ void randomize(uint8_t[], size_t) override
{
throw PRNG_Unseeded("Null_RNG called");
}
- void add_entropy(const byte[], size_t) override {}
+ void add_entropy(const uint8_t[], size_t) override {}
std::string name() const override { return "Null_RNG"; }
};
@@ -210,7 +210,7 @@ class BOTAN_DLL Null_RNG final : public RandomNumberGenerator
class BOTAN_DLL Serialized_RNG final : public RandomNumberGenerator
{
public:
- void randomize(byte out[], size_t len) override
+ void randomize(uint8_t out[], size_t len) override
{
lock_guard_type<mutex_type> lock(m_mutex);
m_rng->randomize(out, len);
@@ -242,7 +242,7 @@ class BOTAN_DLL Serialized_RNG final : public RandomNumberGenerator
return m_rng->reseed(src, poll_bits, poll_timeout);
}
- void add_entropy(const byte in[], size_t len) override
+ void add_entropy(const uint8_t in[], size_t len) override
{
lock_guard_type<mutex_type> lock(m_mutex);
m_rng->add_entropy(in, len);
diff --git a/src/lib/rng/stateful_rng/stateful_rng.cpp b/src/lib/rng/stateful_rng/stateful_rng.cpp
index 1349c1208..81fe89cca 100644
--- a/src/lib/rng/stateful_rng/stateful_rng.cpp
+++ b/src/lib/rng/stateful_rng/stateful_rng.cpp
@@ -26,7 +26,7 @@ bool Stateful_RNG::is_seeded() const
return m_reseed_counter > 0;
}
-void Stateful_RNG::initialize_with(const byte input[], size_t len)
+void Stateful_RNG::initialize_with(const uint8_t input[], size_t len)
{
add_entropy(input, len);
@@ -36,9 +36,9 @@ void Stateful_RNG::initialize_with(const byte input[], size_t len)
}
}
-void Stateful_RNG::randomize_with_ts_input(byte output[], size_t output_len)
+void Stateful_RNG::randomize_with_ts_input(uint8_t output[], size_t output_len)
{
- byte additional_input[24] = { 0 };
+ uint8_t additional_input[24] = { 0 };
store_le(OS::get_system_timestamp_ns(), additional_input);
store_le(OS::get_processor_timestamp(), additional_input + 8);
store_le(m_last_pid, additional_input + 16);
diff --git a/src/lib/rng/stateful_rng/stateful_rng.h b/src/lib/rng/stateful_rng/stateful_rng.h
index e2b45f8fa..982747e01 100644
--- a/src/lib/rng/stateful_rng/stateful_rng.h
+++ b/src/lib/rng/stateful_rng/stateful_rng.h
@@ -71,7 +71,7 @@ class BOTAN_DLL Stateful_RNG : public RandomNumberGenerator
* of the length of the input or the current seeded state of
* the RNG.
*/
- void initialize_with(const byte input[], size_t length);
+ void initialize_with(const uint8_t input[], size_t length);
bool is_seeded() const override final;
@@ -87,7 +87,7 @@ class BOTAN_DLL Stateful_RNG : public RandomNumberGenerator
* Overrides default implementation and also includes the current
* process ID and the reseed counter.
*/
- void randomize_with_ts_input(byte output[], size_t output_len) override final;
+ void randomize_with_ts_input(uint8_t output[], size_t output_len) override final;
/**
* Poll provided sources for up to poll_bits bits of entropy
diff --git a/src/lib/stream/chacha/chacha.cpp b/src/lib/stream/chacha/chacha.cpp
index c74f60f2d..4befe1981 100644
--- a/src/lib/stream/chacha/chacha.cpp
+++ b/src/lib/stream/chacha/chacha.cpp
@@ -30,7 +30,7 @@ std::string ChaCha::provider() const
}
//static
-void ChaCha::chacha_x4(byte output[64*4], u32bit input[16], size_t rounds)
+void ChaCha::chacha_x4(uint8_t output[64*4], uint32_t input[16], size_t rounds)
{
BOTAN_ASSERT(rounds % 2 == 0, "Valid rounds");
@@ -44,7 +44,7 @@ void ChaCha::chacha_x4(byte output[64*4], u32bit input[16], size_t rounds)
// TODO interleave rounds
for(size_t i = 0; i != 4; ++i)
{
- u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
+ uint32_t x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
x04 = input[ 4], x05 = input[ 5], x06 = input[ 6], x07 = input[ 7],
x08 = input[ 8], x09 = input[ 9], x10 = input[10], x11 = input[11],
x12 = input[12], x13 = input[13], x14 = input[14], x15 = input[15];
@@ -114,7 +114,7 @@ void ChaCha::chacha_x4(byte output[64*4], u32bit input[16], size_t rounds)
/*
* Combine cipher stream with message
*/
-void ChaCha::cipher(const byte in[], byte out[], size_t length)
+void ChaCha::cipher(const uint8_t in[], uint8_t out[], size_t length)
{
while(length >= m_buffer.size() - m_position)
{
@@ -134,18 +134,18 @@ void ChaCha::cipher(const byte in[], byte out[], size_t length)
/*
* ChaCha Key Schedule
*/
-void ChaCha::key_schedule(const byte key[], size_t length)
+void ChaCha::key_schedule(const uint8_t key[], size_t length)
{
- static const u32bit TAU[] =
+ static const uint32_t TAU[] =
{ 0x61707865, 0x3120646e, 0x79622d36, 0x6b206574 };
- static const u32bit SIGMA[] =
+ static const uint32_t SIGMA[] =
{ 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 };
- const u32bit* CONSTANTS = (length == 16) ? TAU : SIGMA;
+ const uint32_t* CONSTANTS = (length == 16) ? TAU : SIGMA;
// Repeat the key if 128 bits
- const byte* key2 = (length == 32) ? key + 16 : key;
+ const uint8_t* key2 = (length == 32) ? key + 16 : key;
m_position = 0;
m_state.resize(16);
@@ -156,22 +156,22 @@ void ChaCha::key_schedule(const byte key[], size_t length)
m_state[2] = CONSTANTS[2];
m_state[3] = CONSTANTS[3];
- m_state[4] = load_le<u32bit>(key, 0);
- m_state[5] = load_le<u32bit>(key, 1);
- m_state[6] = load_le<u32bit>(key, 2);
- m_state[7] = load_le<u32bit>(key, 3);
+ m_state[4] = load_le<uint32_t>(key, 0);
+ m_state[5] = load_le<uint32_t>(key, 1);
+ m_state[6] = load_le<uint32_t>(key, 2);
+ m_state[7] = load_le<uint32_t>(key, 3);
- m_state[8] = load_le<u32bit>(key2, 0);
- m_state[9] = load_le<u32bit>(key2, 1);
- m_state[10] = load_le<u32bit>(key2, 2);
- m_state[11] = load_le<u32bit>(key2, 3);
+ m_state[8] = load_le<uint32_t>(key2, 0);
+ m_state[9] = load_le<uint32_t>(key2, 1);
+ m_state[10] = load_le<uint32_t>(key2, 2);
+ m_state[11] = load_le<uint32_t>(key2, 3);
// Default all-zero IV
- const byte ZERO[8] = { 0 };
+ const uint8_t ZERO[8] = { 0 };
set_iv(ZERO, sizeof(ZERO));
}
-void ChaCha::set_iv(const byte iv[], size_t length)
+void ChaCha::set_iv(const uint8_t iv[], size_t length)
{
if(!valid_iv_length(length))
throw Invalid_IV_Length(name(), length);
@@ -181,14 +181,14 @@ void ChaCha::set_iv(const byte iv[], size_t length)
if(length == 8)
{
- m_state[14] = load_le<u32bit>(iv, 0);
- m_state[15] = load_le<u32bit>(iv, 1);
+ m_state[14] = load_le<uint32_t>(iv, 0);
+ m_state[15] = load_le<uint32_t>(iv, 1);
}
else if(length == 12)
{
- m_state[13] = load_le<u32bit>(iv, 0);
- m_state[14] = load_le<u32bit>(iv, 1);
- m_state[15] = load_le<u32bit>(iv, 2);
+ m_state[13] = load_le<uint32_t>(iv, 0);
+ m_state[14] = load_le<uint32_t>(iv, 1);
+ m_state[15] = load_le<uint32_t>(iv, 2);
}
chacha_x4(m_buffer.data(), m_state.data(), m_rounds);
@@ -207,7 +207,7 @@ std::string ChaCha::name() const
return "ChaCha(" + std::to_string(m_rounds) + ")";
}
-void ChaCha::seek(u64bit offset)
+void ChaCha::seek(uint64_t offset)
{
if (m_state.size() == 0 && m_buffer.size() == 0)
{
@@ -215,14 +215,14 @@ void ChaCha::seek(u64bit offset)
}
// Find the block offset
- u64bit counter = offset / 64;
+ uint64_t counter = offset / 64;
- byte out[8];
+ uint8_t out[8];
store_le(counter, out);
- m_state[12] = load_le<u32bit>(out, 0);
- m_state[13] += load_le<u32bit>(out, 1);
+ m_state[12] = load_le<uint32_t>(out, 0);
+ m_state[13] += load_le<uint32_t>(out, 1);
chacha_x4(m_buffer.data(), m_state.data(), m_rounds);
m_position = offset % 64;
diff --git a/src/lib/stream/chacha/chacha.h b/src/lib/stream/chacha/chacha.h
index 6b1c989e2..876b9ca33 100644
--- a/src/lib/stream/chacha/chacha.h
+++ b/src/lib/stream/chacha/chacha.h
@@ -29,9 +29,9 @@ class BOTAN_DLL ChaCha final : public StreamCipher
std::string provider() const override;
- void cipher(const byte in[], byte out[], size_t length) override;
+ void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
- void set_iv(const byte iv[], size_t iv_len) override;
+ void set_iv(const uint8_t iv[], size_t iv_len) override;
bool valid_iv_length(size_t iv_len) const override
{ return (iv_len == 8 || iv_len == 12); }
@@ -45,20 +45,20 @@ class BOTAN_DLL ChaCha final : public StreamCipher
std::string name() const override;
- void seek(u64bit offset) override;
+ void seek(uint64_t offset) override;
private:
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
- void chacha_x4(byte output[64*4], u32bit state[16], size_t rounds);
+ void chacha_x4(uint8_t output[64*4], uint32_t state[16], size_t rounds);
#if defined(BOTAN_HAS_CHACHA_SSE2)
- void chacha_sse2_x4(byte output[64*4], u32bit state[16], size_t rounds);
+ void chacha_sse2_x4(uint8_t output[64*4], uint32_t state[16], size_t rounds);
#endif
size_t m_rounds;
- secure_vector<u32bit> m_state;
- secure_vector<byte> m_buffer;
+ secure_vector<uint32_t> m_state;
+ secure_vector<uint8_t> m_buffer;
size_t m_position = 0;
};
diff --git a/src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp b/src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp
index f28257fb8..9641be67b 100644
--- a/src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp
+++ b/src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp
@@ -12,7 +12,7 @@ namespace Botan {
//static
BOTAN_FUNC_ISA("sse2")
-void ChaCha::chacha_sse2_x4(byte output[64*4], u32bit input[16], size_t rounds)
+void ChaCha::chacha_sse2_x4(uint8_t output[64*4], uint32_t input[16], size_t rounds)
{
BOTAN_ASSERT(rounds % 2 == 0, "Valid rounds");
diff --git a/src/lib/stream/ctr/ctr.cpp b/src/lib/stream/ctr/ctr.cpp
index c4552d459..728da3567 100644
--- a/src/lib/stream/ctr/ctr.cpp
+++ b/src/lib/stream/ctr/ctr.cpp
@@ -38,7 +38,7 @@ void CTR_BE::clear()
m_pad_pos = 0;
}
-void CTR_BE::key_schedule(const byte key[], size_t key_len)
+void CTR_BE::key_schedule(const uint8_t key[], size_t key_len)
{
m_cipher->set_key(key, key_len);
@@ -51,7 +51,7 @@ std::string CTR_BE::name() const
return ("CTR-BE(" + m_cipher->name() + ")");
}
-void CTR_BE::cipher(const byte in[], byte out[], size_t length)
+void CTR_BE::cipher(const uint8_t in[], uint8_t out[], size_t length)
{
while(length >= m_pad.size() - m_pad_pos)
{
@@ -65,7 +65,7 @@ void CTR_BE::cipher(const byte in[], byte out[], size_t length)
m_pad_pos += length;
}
-void CTR_BE::set_iv(const byte iv[], size_t iv_len)
+void CTR_BE::set_iv(const uint8_t iv[], size_t iv_len)
{
if(!valid_iv_length(iv_len))
throw Invalid_IV_Length(name(), iv_len);
@@ -106,7 +106,7 @@ void CTR_BE::increment_counter()
{
const size_t off = i*bs + (bs-1-j);
const uint16_t cnt = static_cast<uint16_t>(m_counter[off]) + carry;
- m_counter[off] = static_cast<byte>(cnt);
+ m_counter[off] = static_cast<uint8_t>(cnt);
carry = (cnt >> 8);
}
}
@@ -115,7 +115,7 @@ void CTR_BE::increment_counter()
m_pad_pos = 0;
}
-void CTR_BE::seek(u64bit)
+void CTR_BE::seek(uint64_t)
{
throw Not_Implemented("CTR_BE::seek");
}
diff --git a/src/lib/stream/ctr/ctr.h b/src/lib/stream/ctr/ctr.h
index c4a28bd2b..345c4f6e8 100644
--- a/src/lib/stream/ctr/ctr.h
+++ b/src/lib/stream/ctr/ctr.h
@@ -19,9 +19,9 @@ namespace Botan {
class BOTAN_DLL CTR_BE final : public StreamCipher
{
public:
- void cipher(const byte in[], byte out[], size_t length) override;
+ void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
- void set_iv(const byte iv[], size_t iv_len) override;
+ void set_iv(const uint8_t iv[], size_t iv_len) override;
bool valid_iv_length(size_t iv_len) const override
{ return (iv_len <= m_cipher->block_size()); }
@@ -45,13 +45,13 @@ class BOTAN_DLL CTR_BE final : public StreamCipher
CTR_BE(BlockCipher* cipher, size_t ctr_size);
- void seek(u64bit offset) override;
+ void seek(uint64_t offset) override;
private:
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
void increment_counter();
std::unique_ptr<BlockCipher> m_cipher;
- secure_vector<byte> m_counter, m_pad;
+ secure_vector<uint8_t> m_counter, m_pad;
size_t m_ctr_size;
size_t m_pad_pos;
};
diff --git a/src/lib/stream/ofb/ofb.cpp b/src/lib/stream/ofb/ofb.cpp
index 0c23188d5..5a2d63dd4 100644
--- a/src/lib/stream/ofb/ofb.cpp
+++ b/src/lib/stream/ofb/ofb.cpp
@@ -23,7 +23,7 @@ void OFB::clear()
m_buf_pos = 0;
}
-void OFB::key_schedule(const byte key[], size_t key_len)
+void OFB::key_schedule(const uint8_t key[], size_t key_len)
{
m_cipher->set_key(key, key_len);
@@ -36,7 +36,7 @@ std::string OFB::name() const
return "OFB(" + m_cipher->name() + ")";
}
-void OFB::cipher(const byte in[], byte out[], size_t length)
+void OFB::cipher(const uint8_t in[], uint8_t out[], size_t length)
{
while(length >= m_buffer.size() - m_buf_pos)
{
@@ -51,7 +51,7 @@ void OFB::cipher(const byte in[], byte out[], size_t length)
m_buf_pos += length;
}
-void OFB::set_iv(const byte iv[], size_t iv_len)
+void OFB::set_iv(const uint8_t iv[], size_t iv_len)
{
if(!valid_iv_length(iv_len))
throw Invalid_IV_Length(name(), iv_len);
@@ -64,7 +64,7 @@ void OFB::set_iv(const byte iv[], size_t iv_len)
}
-void OFB::seek(u64bit)
+void OFB::seek(uint64_t)
{
throw Exception("OFB does not support seeking");
}
diff --git a/src/lib/stream/ofb/ofb.h b/src/lib/stream/ofb/ofb.h
index f8beb4956..29e015227 100644
--- a/src/lib/stream/ofb/ofb.h
+++ b/src/lib/stream/ofb/ofb.h
@@ -19,9 +19,9 @@ namespace Botan {
class BOTAN_DLL OFB final : public StreamCipher
{
public:
- void cipher(const byte in[], byte out[], size_t length) override;
+ void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
- void set_iv(const byte iv[], size_t iv_len) override;
+ void set_iv(const uint8_t iv[], size_t iv_len) override;
bool valid_iv_length(size_t iv_len) const override
{ return (iv_len <= m_cipher->block_size()); }
@@ -43,12 +43,12 @@ class BOTAN_DLL OFB final : public StreamCipher
*/
explicit OFB(BlockCipher* cipher);
- void seek(u64bit offset) override;
+ void seek(uint64_t offset) override;
private:
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
std::unique_ptr<BlockCipher> m_cipher;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
size_t m_buf_pos;
};
diff --git a/src/lib/stream/rc4/rc4.cpp b/src/lib/stream/rc4/rc4.cpp
index 47dc1ce29..208b2f560 100644
--- a/src/lib/stream/rc4/rc4.cpp
+++ b/src/lib/stream/rc4/rc4.cpp
@@ -13,7 +13,7 @@ namespace Botan {
/*
* Combine cipher stream with message
*/
-void RC4::cipher(const byte in[], byte out[], size_t length)
+void RC4::cipher(const uint8_t in[], uint8_t out[], size_t length)
{
while(length >= m_buffer.size() - m_position)
{
@@ -27,7 +27,7 @@ void RC4::cipher(const byte in[], byte out[], size_t length)
m_position += length;
}
-void RC4::set_iv(const byte*, size_t length)
+void RC4::set_iv(const uint8_t*, size_t length)
{
if(length > 0)
throw Exception("RC4 does not support an IV");
@@ -38,7 +38,7 @@ void RC4::set_iv(const byte*, size_t length)
*/
void RC4::generate()
{
- byte SX, SY;
+ uint8_t SX, SY;
for(size_t i = 0; i != m_buffer.size(); i += 4)
{
SX = m_state[m_X+1]; m_Y = (m_Y + SX) % 256; SY = m_state[m_Y];
@@ -64,7 +64,7 @@ void RC4::generate()
/*
* RC4 Key Schedule
*/
-void RC4::key_schedule(const byte key[], size_t length)
+void RC4::key_schedule(const uint8_t key[], size_t length)
{
m_state.resize(256);
m_buffer.resize(256);
@@ -72,7 +72,7 @@ void RC4::key_schedule(const byte key[], size_t length)
m_position = m_X = m_Y = 0;
for(size_t i = 0; i != 256; ++i)
- m_state[i] = static_cast<byte>(i);
+ m_state[i] = static_cast<uint8_t>(i);
for(size_t i = 0, state_index = 0; i != 256; ++i)
{
@@ -111,7 +111,7 @@ void RC4::clear()
*/
RC4::RC4(size_t s) : m_SKIP(s) {}
-void RC4::seek(u64bit)
+void RC4::seek(uint64_t)
{
throw Exception("RC4 does not support seeking");
}
diff --git a/src/lib/stream/rc4/rc4.h b/src/lib/stream/rc4/rc4.h
index 46715f7d2..938ab59cc 100644
--- a/src/lib/stream/rc4/rc4.h
+++ b/src/lib/stream/rc4/rc4.h
@@ -19,9 +19,9 @@ namespace Botan {
class BOTAN_DLL RC4 final : public StreamCipher
{
public:
- void cipher(const byte in[], byte out[], size_t length) override;
+ void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
- void set_iv(const byte iv[], size_t iv_len) override;
+ void set_iv(const uint8_t iv[], size_t iv_len) override;
void clear() override;
std::string name() const override;
@@ -40,16 +40,16 @@ class BOTAN_DLL RC4 final : public StreamCipher
~RC4() { clear(); }
- void seek(u64bit offset) override;
+ void seek(uint64_t offset) override;
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
void generate();
const size_t m_SKIP;
- byte m_X = 0;
- byte m_Y = 0;
- secure_vector<byte> m_state;
- secure_vector<byte> m_buffer;
+ uint8_t m_X = 0;
+ uint8_t m_Y = 0;
+ secure_vector<uint8_t> m_state;
+ secure_vector<uint8_t> m_buffer;
size_t m_position = 0;
};
diff --git a/src/lib/stream/salsa20/salsa20.cpp b/src/lib/stream/salsa20/salsa20.cpp
index 60bf19285..1c8846183 100644
--- a/src/lib/stream/salsa20/salsa20.cpp
+++ b/src/lib/stream/salsa20/salsa20.cpp
@@ -23,9 +23,9 @@ namespace {
/*
* Generate HSalsa20 cipher stream (for XSalsa20 IV setup)
*/
-void hsalsa20(u32bit output[8], const u32bit input[16])
+void hsalsa20(uint32_t output[8], const uint32_t input[16])
{
- u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
+ uint32_t x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
x04 = input[ 4], x05 = input[ 5], x06 = input[ 6], x07 = input[ 7],
x08 = input[ 8], x09 = input[ 9], x10 = input[10], x11 = input[11],
x12 = input[12], x13 = input[13], x14 = input[14], x15 = input[15];
@@ -56,9 +56,9 @@ void hsalsa20(u32bit output[8], const u32bit input[16])
/*
* Generate Salsa20 cipher stream
*/
-void salsa20(byte output[64], const u32bit input[16])
+void salsa20(uint8_t output[64], const uint32_t input[16])
{
- u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
+ uint32_t x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
x04 = input[ 4], x05 = input[ 5], x06 = input[ 6], x07 = input[ 7],
x08 = input[ 8], x09 = input[ 9], x10 = input[10], x11 = input[11],
x12 = input[12], x13 = input[13], x14 = input[14], x15 = input[15];
@@ -101,7 +101,7 @@ void salsa20(byte output[64], const u32bit input[16])
/*
* Combine cipher stream with message
*/
-void Salsa20::cipher(const byte in[], byte out[], size_t length)
+void Salsa20::cipher(const uint8_t in[], uint8_t out[], size_t length)
{
while(length >= m_buffer.size() - m_position)
{
@@ -125,15 +125,15 @@ void Salsa20::cipher(const byte in[], byte out[], size_t length)
/*
* Salsa20 Key Schedule
*/
-void Salsa20::key_schedule(const byte key[], size_t length)
+void Salsa20::key_schedule(const uint8_t key[], size_t length)
{
- static const u32bit TAU[] =
+ static const uint32_t TAU[] =
{ 0x61707865, 0x3120646e, 0x79622d36, 0x6b206574 };
- static const u32bit SIGMA[] =
+ static const uint32_t SIGMA[] =
{ 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 };
- const u32bit* CONSTANTS = (length == 16) ? TAU : SIGMA;
+ const uint32_t* CONSTANTS = (length == 16) ? TAU : SIGMA;
m_state.resize(16);
m_buffer.resize(64);
@@ -143,18 +143,18 @@ void Salsa20::key_schedule(const byte key[], size_t length)
m_state[10] = CONSTANTS[2];
m_state[15] = CONSTANTS[3];
- m_state[1] = load_le<u32bit>(key, 0);
- m_state[2] = load_le<u32bit>(key, 1);
- m_state[3] = load_le<u32bit>(key, 2);
- m_state[4] = load_le<u32bit>(key, 3);
+ m_state[1] = load_le<uint32_t>(key, 0);
+ m_state[2] = load_le<uint32_t>(key, 1);
+ m_state[3] = load_le<uint32_t>(key, 2);
+ m_state[4] = load_le<uint32_t>(key, 3);
if(length == 32)
key += 16;
- m_state[11] = load_le<u32bit>(key, 0);
- m_state[12] = load_le<u32bit>(key, 1);
- m_state[13] = load_le<u32bit>(key, 2);
- m_state[14] = load_le<u32bit>(key, 3);
+ m_state[11] = load_le<uint32_t>(key, 0);
+ m_state[12] = load_le<uint32_t>(key, 1);
+ m_state[13] = load_le<uint32_t>(key, 2);
+ m_state[14] = load_le<uint32_t>(key, 3);
m_position = 0;
@@ -164,7 +164,7 @@ void Salsa20::key_schedule(const byte key[], size_t length)
/*
* Set the Salsa IV
*/
-void Salsa20::set_iv(const byte iv[], size_t length)
+void Salsa20::set_iv(const uint8_t iv[], size_t length)
{
if(!valid_iv_length(length))
throw Invalid_IV_Length(name(), length);
@@ -178,26 +178,26 @@ void Salsa20::set_iv(const byte iv[], size_t length)
else if(length == 8)
{
// Salsa20
- m_state[6] = load_le<u32bit>(iv, 0);
- m_state[7] = load_le<u32bit>(iv, 1);
+ m_state[6] = load_le<uint32_t>(iv, 0);
+ m_state[7] = load_le<uint32_t>(iv, 1);
}
else
{
// XSalsa20
- m_state[6] = load_le<u32bit>(iv, 0);
- m_state[7] = load_le<u32bit>(iv, 1);
- m_state[8] = load_le<u32bit>(iv, 2);
- m_state[9] = load_le<u32bit>(iv, 3);
+ m_state[6] = load_le<uint32_t>(iv, 0);
+ m_state[7] = load_le<uint32_t>(iv, 1);
+ m_state[8] = load_le<uint32_t>(iv, 2);
+ m_state[9] = load_le<uint32_t>(iv, 3);
- secure_vector<u32bit> hsalsa(8);
+ secure_vector<uint32_t> hsalsa(8);
hsalsa20(hsalsa.data(), m_state.data());
m_state[ 1] = hsalsa[0];
m_state[ 2] = hsalsa[1];
m_state[ 3] = hsalsa[2];
m_state[ 4] = hsalsa[3];
- m_state[ 6] = load_le<u32bit>(iv, 4);
- m_state[ 7] = load_le<u32bit>(iv, 5);
+ m_state[ 6] = load_le<uint32_t>(iv, 4);
+ m_state[ 7] = load_le<uint32_t>(iv, 5);
m_state[11] = hsalsa[4];
m_state[12] = hsalsa[5];
m_state[13] = hsalsa[6];
@@ -232,7 +232,7 @@ void Salsa20::clear()
m_position = 0;
}
-void Salsa20::seek(u64bit)
+void Salsa20::seek(uint64_t)
{
throw Not_Implemented("Salsa20::seek");
}
diff --git a/src/lib/stream/salsa20/salsa20.h b/src/lib/stream/salsa20/salsa20.h
index a128c5a98..935f5cf85 100644
--- a/src/lib/stream/salsa20/salsa20.h
+++ b/src/lib/stream/salsa20/salsa20.h
@@ -18,9 +18,9 @@ namespace Botan {
class BOTAN_DLL Salsa20 final : public StreamCipher
{
public:
- void cipher(const byte in[], byte out[], size_t length) override;
+ void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
- void set_iv(const byte iv[], size_t iv_len) override;
+ void set_iv(const uint8_t iv[], size_t iv_len) override;
bool valid_iv_length(size_t iv_len) const override
{ return (iv_len == 0 || iv_len == 8 || iv_len == 24); }
@@ -34,12 +34,12 @@ class BOTAN_DLL Salsa20 final : public StreamCipher
std::string name() const override;
StreamCipher* clone() const override { return new Salsa20; }
- void seek(u64bit offset) override;
+ void seek(uint64_t offset) override;
private:
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
- secure_vector<u32bit> m_state;
- secure_vector<byte> m_buffer;
+ secure_vector<uint32_t> m_state;
+ secure_vector<uint8_t> m_buffer;
size_t m_position = 0;
};
diff --git a/src/lib/stream/shake_cipher/shake_cipher.cpp b/src/lib/stream/shake_cipher/shake_cipher.cpp
index dc3c73299..4f79777f4 100644
--- a/src/lib/stream/shake_cipher/shake_cipher.cpp
+++ b/src/lib/stream/shake_cipher/shake_cipher.cpp
@@ -17,7 +17,7 @@ SHAKE_128_Cipher::SHAKE_128_Cipher() :
m_buf_pos(0)
{}
-void SHAKE_128_Cipher::cipher(const byte in[], byte out[], size_t length)
+void SHAKE_128_Cipher::cipher(const uint8_t in[], uint8_t out[], size_t length)
{
while(length >= m_buffer.size() - m_buf_pos)
{
@@ -35,7 +35,7 @@ void SHAKE_128_Cipher::cipher(const byte in[], byte out[], size_t length)
m_buf_pos += length;
}
-void SHAKE_128_Cipher::key_schedule(const byte key[], size_t length)
+void SHAKE_128_Cipher::key_schedule(const uint8_t key[], size_t length)
{
zeroise(m_state);
@@ -58,7 +58,7 @@ void SHAKE_128_Cipher::clear()
m_buf_pos = 0;
}
-void SHAKE_128_Cipher::set_iv(const byte[], size_t length)
+void SHAKE_128_Cipher::set_iv(const uint8_t[], size_t length)
{
/*
* This could be supported in some way (say, by treating iv as
@@ -68,7 +68,7 @@ void SHAKE_128_Cipher::set_iv(const byte[], size_t length)
throw Invalid_IV_Length(name(), length);
}
-void SHAKE_128_Cipher::seek(u64bit)
+void SHAKE_128_Cipher::seek(uint64_t)
{
throw Not_Implemented("SHAKE_128_Cipher::seek");
}
diff --git a/src/lib/stream/shake_cipher/shake_cipher.h b/src/lib/stream/shake_cipher/shake_cipher.h
index 40915ecea..e15669f24 100644
--- a/src/lib/stream/shake_cipher/shake_cipher.h
+++ b/src/lib/stream/shake_cipher/shake_cipher.h
@@ -24,17 +24,17 @@ class BOTAN_DLL SHAKE_128_Cipher final : public StreamCipher
/**
* Produce more XOF output
*/
- void cipher(const byte in[], byte out[], size_t length) override;
+ void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
/**
* Seeking is not supported, this function will throw
*/
- void seek(u64bit offset) override;
+ void seek(uint64_t offset) override;
/**
* IV not supported, this function will throw unless iv_len == 0
*/
- void set_iv(const byte iv[], size_t iv_len) override;
+ void set_iv(const uint8_t iv[], size_t iv_len) override;
bool valid_iv_length(size_t iv_len) const override { return (iv_len == 0); }
@@ -52,10 +52,10 @@ class BOTAN_DLL SHAKE_128_Cipher final : public StreamCipher
StreamCipher* clone() const override { return new SHAKE_128_Cipher; }
private:
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
secure_vector<uint64_t> m_state; // internal state
- secure_vector<byte> m_buffer; // ciphertext buffer
+ secure_vector<uint8_t> m_buffer; // ciphertext buffer
size_t m_buf_pos; // position in m_buffer
};
diff --git a/src/lib/stream/stream_cipher.h b/src/lib/stream/stream_cipher.h
index 7654bf427..3c843cb87 100644
--- a/src/lib/stream/stream_cipher.h
+++ b/src/lib/stream/stream_cipher.h
@@ -54,7 +54,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param out the byte array to hold the output, i.e. the ciphertext
* @param len the length of both in and out in bytes
*/
- virtual void cipher(const byte in[], byte out[], size_t len) = 0;
+ virtual void cipher(const uint8_t in[], uint8_t out[], size_t len) = 0;
/**
* Encrypt or decrypt a message
@@ -62,7 +62,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param buf the plaintext / ciphertext
* @param len the length of buf in bytes
*/
- void cipher1(byte buf[], size_t len)
+ void cipher1(uint8_t buf[], size_t len)
{ cipher(buf, buf, len); }
/**
@@ -71,7 +71,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param inout the plaintext / ciphertext
*/
template<typename Alloc>
- void encipher(std::vector<byte, Alloc>& inout)
+ void encipher(std::vector<uint8_t, Alloc>& inout)
{ cipher(inout.data(), inout.data(), inout.size()); }
/**
@@ -80,7 +80,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param inout the plaintext / ciphertext
*/
template<typename Alloc>
- void encrypt(std::vector<byte, Alloc>& inout)
+ void encrypt(std::vector<uint8_t, Alloc>& inout)
{ cipher(inout.data(), inout.data(), inout.size()); }
/**
@@ -89,7 +89,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param inout the plaintext / ciphertext
*/
template<typename Alloc>
- void decrypt(std::vector<byte, Alloc>& inout)
+ void decrypt(std::vector<uint8_t, Alloc>& inout)
{ cipher(inout.data(), inout.data(), inout.size()); }
/**
@@ -97,7 +97,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param iv the initialization vector
* @param iv_len the length of the IV in bytes
*/
- virtual void set_iv(const byte iv[], size_t iv_len) = 0;
+ virtual void set_iv(const uint8_t iv[], size_t iv_len) = 0;
/**
* @param iv_len the length of the IV in bytes
@@ -114,7 +114,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* Set the offset and the state used later to generate the keystream
* @param offset the offset where we begin to generate the keystream
*/
- virtual void seek(u64bit offset) = 0;
+ virtual void seek(uint64_t offset) = 0;
/**
* @return provider information about this implementation. Default is "base",
diff --git a/src/lib/tls/credentials_manager.cpp b/src/lib/tls/credentials_manager.cpp
index a42fb5789..c59933762 100644
--- a/src/lib/tls/credentials_manager.cpp
+++ b/src/lib/tls/credentials_manager.cpp
@@ -54,7 +54,7 @@ bool Credentials_Manager::srp_verifier(const std::string&,
const std::string&,
std::string&,
BigInt&,
- std::vector<byte>&,
+ std::vector<uint8_t>&,
bool)
{
return false;
diff --git a/src/lib/tls/credentials_manager.h b/src/lib/tls/credentials_manager.h
index 0e2fe0dea..e39c81c36 100644
--- a/src/lib/tls/credentials_manager.h
+++ b/src/lib/tls/credentials_manager.h
@@ -131,7 +131,7 @@ class BOTAN_DLL Credentials_Manager
const std::string& identifier,
std::string& group_name,
BigInt& verifier,
- std::vector<byte>& salt,
+ std::vector<uint8_t>& salt,
bool generate_fake_on_unknown);
/**
diff --git a/src/lib/tls/msg_cert_req.cpp b/src/lib/tls/msg_cert_req.cpp
index 4fd528148..484693fcc 100644
--- a/src/lib/tls/msg_cert_req.cpp
+++ b/src/lib/tls/msg_cert_req.cpp
@@ -19,7 +19,7 @@ namespace TLS {
namespace {
-std::string cert_type_code_to_name(byte code)
+std::string cert_type_code_to_name(uint8_t code)
{
switch(code)
{
@@ -34,7 +34,7 @@ std::string cert_type_code_to_name(byte code)
}
}
-byte cert_type_name_to_code(const std::string& name)
+uint8_t cert_type_name_to_code(const std::string& name)
{
if(name == "RSA")
return 1;
@@ -75,7 +75,7 @@ Certificate_Req::Certificate_Req(Handshake_IO& io,
/**
* Deserialize a Certificate Request message
*/
-Certificate_Req::Certificate_Req(const std::vector<byte>& buf,
+Certificate_Req::Certificate_Req(const std::vector<uint8_t>& buf,
Protocol_Version version)
{
if(buf.size() < 4)
@@ -83,7 +83,7 @@ Certificate_Req::Certificate_Req(const std::vector<byte>& buf,
TLS_Data_Reader reader("CertificateRequest", buf);
- std::vector<byte> cert_type_codes = reader.get_range_vector<byte>(1, 1, 255);
+ std::vector<uint8_t> cert_type_codes = reader.get_range_vector<uint8_t>(1, 1, 255);
for(size_t i = 0; i != cert_type_codes.size(); ++i)
{
@@ -97,7 +97,7 @@ Certificate_Req::Certificate_Req(const std::vector<byte>& buf,
if(version.supports_negotiable_signature_algorithms())
{
- std::vector<byte> sig_hash_algs = reader.get_range_vector<byte>(2, 2, 65534);
+ std::vector<uint8_t> sig_hash_algs = reader.get_range_vector<uint8_t>(2, 2, 65534);
if(sig_hash_algs.size() % 2 != 0)
throw Decoding_Error("Bad length for signature IDs in certificate request");
@@ -110,14 +110,14 @@ Certificate_Req::Certificate_Req(const std::vector<byte>& buf,
}
}
- const u16bit purported_size = reader.get_u16bit();
+ const uint16_t purported_size = reader.get_uint16_t();
if(reader.remaining_bytes() != purported_size)
throw Decoding_Error("Inconsistent length in certificate request");
while(reader.has_remaining())
{
- std::vector<byte> name_bits = reader.get_range_vector<byte>(2, 0, 65535);
+ std::vector<uint8_t> name_bits = reader.get_range_vector<uint8_t>(2, 0, 65535);
BER_Decoder decoder(name_bits.data(), name_bits.size());
X509_DN name;
@@ -129,11 +129,11 @@ Certificate_Req::Certificate_Req(const std::vector<byte>& buf,
/**
* Serialize a Certificate Request message
*/
-std::vector<byte> Certificate_Req::serialize() const
+std::vector<uint8_t> Certificate_Req::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
- std::vector<byte> cert_types;
+ std::vector<uint8_t> cert_types;
for(size_t i = 0; i != m_cert_key_types.size(); ++i)
cert_types.push_back(cert_type_name_to_code(m_cert_key_types[i]));
@@ -143,7 +143,7 @@ std::vector<byte> Certificate_Req::serialize() const
if(!m_supported_algos.empty())
buf += Signature_Algorithms(m_supported_algos).serialize();
- std::vector<byte> encoded_names;
+ std::vector<uint8_t> encoded_names;
for(size_t i = 0; i != m_names.size(); ++i)
{
diff --git a/src/lib/tls/msg_cert_status.cpp b/src/lib/tls/msg_cert_status.cpp
index f28fe10d2..bd982f506 100644
--- a/src/lib/tls/msg_cert_status.cpp
+++ b/src/lib/tls/msg_cert_status.cpp
@@ -16,7 +16,7 @@ namespace Botan {
namespace TLS {
-Certificate_Status::Certificate_Status(const std::vector<byte>& buf)
+Certificate_Status::Certificate_Status(const std::vector<uint8_t>& buf)
{
if(buf.size() < 5)
throw Decoding_Error("Invalid Certificate_Status message: too small");
@@ -24,7 +24,7 @@ Certificate_Status::Certificate_Status(const std::vector<byte>& buf)
if(buf[0] != 1)
throw Decoding_Error("Unexpected Certificate_Status message: unexpected message type");
- size_t len = make_u32bit(0, buf[1], buf[2], buf[3]);
+ size_t len = make_uint32(0, buf[1], buf[2], buf[3]);
// Verify the redundant length field...
if(buf.size() != len + 4)
@@ -41,17 +41,17 @@ Certificate_Status::Certificate_Status(Handshake_IO& io,
hash.update(io.send(*this));
}
-std::vector<byte> Certificate_Status::serialize() const
+std::vector<uint8_t> Certificate_Status::serialize() const
{
BOTAN_ASSERT_NONNULL(m_response);
- const std::vector<byte>& m_resp_bits = m_response->raw_bits();
+ const std::vector<uint8_t>& m_resp_bits = m_response->raw_bits();
if(m_resp_bits.size() > 0xFFFFFF) // unlikely
throw Encoding_Error("OCSP response too long to encode in TLS");
- const uint32_t m_resp_bits_len = static_cast<u32bit>(m_resp_bits.size());
+ const uint32_t m_resp_bits_len = static_cast<uint32_t>(m_resp_bits.size());
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
buf.push_back(1); // type OCSP
for(size_t i = 1; i < 4; ++i)
buf[i] = get_byte(i, m_resp_bits_len);
diff --git a/src/lib/tls/msg_cert_verify.cpp b/src/lib/tls/msg_cert_verify.cpp
index 2f8e8230e..4f936b380 100644
--- a/src/lib/tls/msg_cert_verify.cpp
+++ b/src/lib/tls/msg_cert_verify.cpp
@@ -38,7 +38,7 @@ Certificate_Verify::Certificate_Verify(Handshake_IO& io,
/*
* Deserialize a Certificate Verify message
*/
-Certificate_Verify::Certificate_Verify(const std::vector<byte>& buf,
+Certificate_Verify::Certificate_Verify(const std::vector<uint8_t>& buf,
Protocol_Version version)
{
TLS_Data_Reader reader("CertificateVerify", buf);
@@ -49,15 +49,15 @@ Certificate_Verify::Certificate_Verify(const std::vector<byte>& buf,
m_sig_algo = Signature_Algorithms::sig_algo_name(reader.get_byte());
}
- m_signature = reader.get_range<byte>(2, 0, 65535);
+ m_signature = reader.get_range<uint8_t>(2, 0, 65535);
}
/*
* Serialize a Certificate Verify message
*/
-std::vector<byte> Certificate_Verify::serialize() const
+std::vector<uint8_t> Certificate_Verify::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
if(!m_hash_algo.empty() && !m_sig_algo.empty())
{
@@ -65,7 +65,7 @@ std::vector<byte> Certificate_Verify::serialize() const
buf.push_back(Signature_Algorithms::sig_algo_code(m_sig_algo));
}
- const u16bit sig_len = static_cast<u16bit>(m_signature.size());
+ const uint16_t sig_len = static_cast<uint16_t>(m_signature.size());
buf.push_back(get_byte(0, sig_len));
buf.push_back(get_byte(1, sig_len));
buf += m_signature;
diff --git a/src/lib/tls/msg_certificate.cpp b/src/lib/tls/msg_certificate.cpp
index 10ee7c95f..1fc6bf959 100644
--- a/src/lib/tls/msg_certificate.cpp
+++ b/src/lib/tls/msg_certificate.cpp
@@ -31,24 +31,24 @@ Certificate::Certificate(Handshake_IO& io,
/**
* Deserialize a Certificate message
*/
-Certificate::Certificate(const std::vector<byte>& buf, const Policy& /*policy_currently_unused*/)
+Certificate::Certificate(const std::vector<uint8_t>& buf, const Policy& /*policy_currently_unused*/)
{
if(buf.size() < 3)
throw Decoding_Error("Certificate: Message malformed");
- const size_t total_size = make_u32bit(0, buf[0], buf[1], buf[2]);
+ const size_t total_size = make_uint32(0, buf[0], buf[1], buf[2]);
if(total_size != buf.size() - 3)
throw Decoding_Error("Certificate: Message malformed");
- const byte* certs = buf.data() + 3;
+ const uint8_t* certs = buf.data() + 3;
while(size_t remaining_bytes = buf.data() + buf.size() - certs)
{
if(remaining_bytes < 3)
throw Decoding_Error("Certificate: Message malformed");
- const size_t cert_size = make_u32bit(0, certs[0], certs[1], certs[2]);
+ const size_t cert_size = make_uint32(0, certs[0], certs[1], certs[2]);
if(remaining_bytes < (3 + cert_size))
throw Decoding_Error("Certificate: Message malformed");
@@ -63,24 +63,24 @@ Certificate::Certificate(const std::vector<byte>& buf, const Policy& /*policy_cu
/**
* Serialize a Certificate message
*/
-std::vector<byte> Certificate::serialize() const
+std::vector<uint8_t> Certificate::serialize() const
{
- std::vector<byte> buf(3);
+ std::vector<uint8_t> buf(3);
for(size_t i = 0; i != m_certs.size(); ++i)
{
- std::vector<byte> raw_cert = m_certs[i].BER_encode();
+ std::vector<uint8_t> raw_cert = m_certs[i].BER_encode();
const size_t cert_size = raw_cert.size();
for(size_t j = 0; j != 3; ++j)
{
- buf.push_back(get_byte(j+1, static_cast<u32bit>(cert_size)));
+ buf.push_back(get_byte(j+1, static_cast<uint32_t>(cert_size)));
}
buf += raw_cert;
}
const size_t buf_size = buf.size() - 3;
for(size_t i = 0; i != 3; ++i)
- buf[i] = get_byte(i+1, static_cast<u32bit>(buf_size));
+ buf[i] = get_byte(i+1, static_cast<uint32_t>(buf_size));
return buf;
}
diff --git a/src/lib/tls/msg_client_hello.cpp b/src/lib/tls/msg_client_hello.cpp
index 870307217..99c7b6e2e 100644
--- a/src/lib/tls/msg_client_hello.cpp
+++ b/src/lib/tls/msg_client_hello.cpp
@@ -22,15 +22,15 @@ enum {
TLS_FALLBACK_SCSV = 0x5600
};
-std::vector<byte> make_hello_random(RandomNumberGenerator& rng,
+std::vector<uint8_t> make_hello_random(RandomNumberGenerator& rng,
const Policy& policy)
{
- std::vector<byte> buf(32);
+ std::vector<uint8_t> buf(32);
rng.randomize(buf.data(), buf.size());
if(policy.include_time_in_hello_random())
{
- const u32bit time32 = static_cast<u32bit>(
+ const uint32_t time32 = static_cast<uint32_t>(
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
store_be(time32, buf.data());
@@ -50,7 +50,7 @@ Hello_Request::Hello_Request(Handshake_IO& io)
/*
* Deserialize a Hello Request message
*/
-Hello_Request::Hello_Request(const std::vector<byte>& buf)
+Hello_Request::Hello_Request(const std::vector<uint8_t>& buf)
{
if(buf.size())
throw Decoding_Error("Bad Hello_Request, has non-zero size");
@@ -59,9 +59,9 @@ Hello_Request::Hello_Request(const std::vector<byte>& buf)
/*
* Serialize a Hello Request message
*/
-std::vector<byte> Hello_Request::serialize() const
+std::vector<uint8_t> Hello_Request::serialize() const
{
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
/*
@@ -71,7 +71,7 @@ Client_Hello::Client_Hello(Handshake_IO& io,
Handshake_Hash& hash,
const Policy& policy,
RandomNumberGenerator& rng,
- const std::vector<byte>& reneg_info,
+ const std::vector<uint8_t>& reneg_info,
const Client_Hello::Settings& client_settings,
const std::vector<std::string>& next_protocols) :
m_version(client_settings.protocol_version()),
@@ -141,7 +141,7 @@ Client_Hello::Client_Hello(Handshake_IO& io,
Handshake_Hash& hash,
const Policy& policy,
RandomNumberGenerator& rng,
- const std::vector<byte>& reneg_info,
+ const std::vector<uint8_t>& reneg_info,
const Session& session,
const std::vector<std::string>& next_protocols) :
m_version(session.version()),
@@ -207,9 +207,9 @@ void Client_Hello::update_hello_cookie(const Hello_Verify_Request& hello_verify)
/*
* Serialize a Client Hello message
*/
-std::vector<byte> Client_Hello::serialize() const
+std::vector<uint8_t> Client_Hello::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
buf.push_back(m_version.major_version());
buf.push_back(m_version.minor_version());
@@ -237,32 +237,32 @@ std::vector<byte> Client_Hello::serialize() const
/*
* Read a counterparty client hello
*/
-Client_Hello::Client_Hello(const std::vector<byte>& buf)
+Client_Hello::Client_Hello(const std::vector<uint8_t>& buf)
{
if(buf.size() < 41)
throw Decoding_Error("Client_Hello: Packet corrupted");
TLS_Data_Reader reader("ClientHello", buf);
- const byte major_version = reader.get_byte();
- const byte minor_version = reader.get_byte();
+ const uint8_t major_version = reader.get_byte();
+ const uint8_t minor_version = reader.get_byte();
m_version = Protocol_Version(major_version, minor_version);
- m_random = reader.get_fixed<byte>(32);
+ m_random = reader.get_fixed<uint8_t>(32);
- m_session_id = reader.get_range<byte>(1, 0, 32);
+ m_session_id = reader.get_range<uint8_t>(1, 0, 32);
if(m_version.is_datagram_protocol())
- m_hello_cookie = reader.get_range<byte>(1, 0, 255);
+ m_hello_cookie = reader.get_range<uint8_t>(1, 0, 255);
- m_suites = reader.get_range_vector<u16bit>(2, 1, 32767);
+ m_suites = reader.get_range_vector<uint16_t>(2, 1, 32767);
- m_comp_methods = reader.get_range_vector<byte>(1, 1, 255);
+ m_comp_methods = reader.get_range_vector<uint8_t>(1, 1, 255);
m_extensions.deserialize(reader);
- if(offered_suite(static_cast<u16bit>(TLS_EMPTY_RENEGOTIATION_INFO_SCSV)))
+ if(offered_suite(static_cast<uint16_t>(TLS_EMPTY_RENEGOTIATION_INFO_SCSV)))
{
if(Renegotiation_Extension* reneg = m_extensions.get<Renegotiation_Extension>())
{
@@ -289,13 +289,13 @@ Client_Hello::Client_Hello(const std::vector<byte>& buf)
bool Client_Hello::sent_fallback_scsv() const
{
- return offered_suite(static_cast<u16bit>(TLS_FALLBACK_SCSV));
+ return offered_suite(static_cast<uint16_t>(TLS_FALLBACK_SCSV));
}
/*
* Check if we offered this ciphersuite
*/
-bool Client_Hello::offered_suite(u16bit ciphersuite) const
+bool Client_Hello::offered_suite(uint16_t ciphersuite) const
{
for(size_t i = 0; i != m_suites.size(); ++i)
if(m_suites[i] == ciphersuite)
diff --git a/src/lib/tls/msg_client_kex.cpp b/src/lib/tls/msg_client_kex.cpp
index 05926ac2d..c9c63c673 100644
--- a/src/lib/tls/msg_client_kex.cpp
+++ b/src/lib/tls/msg_client_kex.cpp
@@ -66,7 +66,7 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
SymmetricKey psk = creds.psk("tls-client", hostname, psk_identity);
- std::vector<byte> zeros(psk.length());
+ std::vector<uint8_t> zeros(psk.length());
append_tls_length_value(m_pre_master, zeros, 2);
append_tls_length_value(m_pre_master, psk.bits_of(), 2);
@@ -91,9 +91,9 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
if(kex_algo == "DH" || kex_algo == "DHE_PSK")
{
- BigInt p = BigInt::decode(reader.get_range<byte>(2, 1, 65535));
- BigInt g = BigInt::decode(reader.get_range<byte>(2, 1, 65535));
- BigInt Y = BigInt::decode(reader.get_range<byte>(2, 1, 65535));
+ BigInt p = BigInt::decode(reader.get_range<uint8_t>(2, 1, 65535));
+ BigInt g = BigInt::decode(reader.get_range<uint8_t>(2, 1, 65535));
+ BigInt Y = BigInt::decode(reader.get_range<uint8_t>(2, 1, 65535));
if(reader.remaining_bytes())
throw Decoding_Error("Bad params size for DH key exchange");
@@ -122,7 +122,7 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
PK_Key_Agreement ka(priv_key, rng, "Raw");
- secure_vector<byte> dh_secret = CT::strip_leading_zeros(
+ secure_vector<uint8_t> dh_secret = CT::strip_leading_zeros(
ka.derive_key(0, counterparty_key.public_value()).bits_of());
if(kex_algo == "DH")
@@ -137,12 +137,12 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
}
else if(kex_algo == "ECDH" || kex_algo == "ECDHE_PSK")
{
- const byte curve_type = reader.get_byte();
+ const uint8_t curve_type = reader.get_byte();
if(curve_type != 3)
throw Decoding_Error("Server sent non-named ECC curve");
- const u16bit curve_id = reader.get_u16bit();
+ const uint16_t curve_id = reader.get_uint16_t();
const std::string curve_name = Supported_Elliptic_Curves::curve_id_to_name(curve_id);
@@ -155,9 +155,9 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
"Server sent ECC curve prohibited by policy");
}
- const std::vector<byte> ecdh_key = reader.get_range<byte>(1, 1, 255);
- std::vector<byte> our_ecdh_public;
- secure_vector<byte> ecdh_secret;
+ const std::vector<uint8_t> ecdh_key = reader.get_range<uint8_t>(1, 1, 255);
+ std::vector<uint8_t> our_ecdh_public;
+ secure_vector<uint8_t> ecdh_secret;
if(curve_name == "x25519")
{
@@ -204,10 +204,10 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
#if defined(BOTAN_HAS_SRP6)
else if(kex_algo == "SRP_SHA")
{
- const BigInt N = BigInt::decode(reader.get_range<byte>(2, 1, 65535));
- const BigInt g = BigInt::decode(reader.get_range<byte>(2, 1, 65535));
- std::vector<byte> salt = reader.get_range<byte>(1, 1, 255);
- const BigInt B = BigInt::decode(reader.get_range<byte>(2, 1, 65535));
+ const BigInt N = BigInt::decode(reader.get_range<uint8_t>(2, 1, 65535));
+ const BigInt g = BigInt::decode(reader.get_range<uint8_t>(2, 1, 65535));
+ std::vector<uint8_t> salt = reader.get_range<uint8_t>(1, 1, 255);
+ const BigInt B = BigInt::decode(reader.get_range<uint8_t>(2, 1, 65535));
const std::string srp_group = srp6_group_identifier(N, g);
@@ -234,7 +234,7 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
#if defined(BOTAN_HAS_CECPQ1)
else if(kex_algo == "CECPQ1")
{
- const std::vector<byte> cecpq1_offer = reader.get_range<byte>(2, 1, 65535);
+ const std::vector<uint8_t> cecpq1_offer = reader.get_range<uint8_t>(2, 1, 65535);
if(cecpq1_offer.size() != CECPQ1_OFFER_BYTES)
throw TLS_Exception(Alert::HANDSHAKE_FAILURE, "Invalid CECPQ1 key size");
@@ -273,7 +273,7 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
PK_Encryptor_EME encryptor(*rsa_pub, rng, "PKCS1v15");
- const std::vector<byte> encrypted_key = encryptor.encrypt(m_pre_master, rng);
+ const std::vector<uint8_t> encrypted_key = encryptor.encrypt(m_pre_master, rng);
append_tls_length_value(m_key_material, encrypted_key, 2);
}
@@ -289,7 +289,7 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
/*
* Read a Client Key Exchange message
*/
-Client_Key_Exchange::Client_Key_Exchange(const std::vector<byte>& contents,
+Client_Key_Exchange::Client_Key_Exchange(const std::vector<uint8_t>& contents,
const Handshake_State& state,
const Private_Key* server_rsa_kex_key,
Credentials_Manager& creds,
@@ -310,12 +310,12 @@ Client_Key_Exchange::Client_Key_Exchange(const std::vector<byte>& contents,
throw Internal_Error("Expected RSA key but got " + server_rsa_kex_key->algo_name());
TLS_Data_Reader reader("ClientKeyExchange", contents);
- const std::vector<byte> encrypted_pre_master = reader.get_range<byte>(2, 0, 65535);
+ const std::vector<uint8_t> encrypted_pre_master = reader.get_range<uint8_t>(2, 0, 65535);
PK_Decryptor_EME decryptor(*server_rsa_kex_key, rng, "PKCS1v15");
- const byte client_major = state.client_hello()->version().major_version();
- const byte client_minor = state.client_hello()->version().minor_version();
+ const uint8_t client_major = state.client_hello()->version().major_version();
+ const uint8_t client_minor = state.client_hello()->version().minor_version();
/*
* PK_Decryptor::decrypt_or_random will return a random value if
@@ -325,8 +325,8 @@ Client_Key_Exchange::Client_Key_Exchange(const std::vector<byte>& contents,
*/
const size_t expected_plaintext_size = 48;
const size_t expected_content_size = 2;
- const byte expected_content_bytes[expected_content_size] = { client_major, client_minor };
- const byte expected_content_pos[expected_content_size] = { 0, 1 };
+ const uint8_t expected_content_bytes[expected_content_size] = { client_major, client_minor };
+ const uint8_t expected_content_pos[expected_content_size] = { 0, 1 };
m_pre_master =
decryptor.decrypt_or_random(encrypted_pre_master.data(),
@@ -363,7 +363,7 @@ Client_Key_Exchange::Client_Key_Exchange(const std::vector<byte>& contents,
if(kex_algo == "PSK")
{
- std::vector<byte> zeros(psk.length());
+ std::vector<uint8_t> zeros(psk.length());
append_tls_length_value(m_pre_master, zeros, 2);
append_tls_length_value(m_pre_master, psk.bits_of(), 2);
}
@@ -372,7 +372,7 @@ Client_Key_Exchange::Client_Key_Exchange(const std::vector<byte>& contents,
{
SRP6_Server_Session& srp = state.server_kex()->server_srp_params();
- m_pre_master = srp.step2(BigInt::decode(reader.get_range<byte>(2, 0, 65535))).bits_of();
+ m_pre_master = srp.step2(BigInt::decode(reader.get_range<uint8_t>(2, 0, 65535))).bits_of();
}
#endif
#if defined(BOTAN_HAS_CECPQ1)
@@ -380,7 +380,7 @@ Client_Key_Exchange::Client_Key_Exchange(const std::vector<byte>& contents,
{
const CECPQ1_key& cecpq1_offer = state.server_kex()->cecpq1_key();
- const std::vector<byte> cecpq1_accept = reader.get_range<byte>(2, 0, 65535);
+ const std::vector<uint8_t> cecpq1_accept = reader.get_range<uint8_t>(2, 0, 65535);
if(cecpq1_accept.size() != CECPQ1_ACCEPT_BYTES)
throw Decoding_Error("Invalid size for CECPQ1 accept message");
@@ -404,14 +404,14 @@ Client_Key_Exchange::Client_Key_Exchange(const std::vector<byte>& contents,
{
PK_Key_Agreement ka(*ka_key, rng, "Raw");
- std::vector<byte> client_pubkey;
+ std::vector<uint8_t> client_pubkey;
if(ka_key->algo_name() == "DH")
- client_pubkey = reader.get_range<byte>(2, 0, 65535);
+ client_pubkey = reader.get_range<uint8_t>(2, 0, 65535);
else
- client_pubkey = reader.get_range<byte>(1, 0, 255);
+ client_pubkey = reader.get_range<uint8_t>(1, 0, 255);
- secure_vector<byte> shared_secret = ka.derive_key(0, client_pubkey).bits_of();
+ secure_vector<uint8_t> shared_secret = ka.derive_key(0, client_pubkey).bits_of();
if(ka_key->algo_name() == "DH")
shared_secret = CT::strip_leading_zeros(shared_secret);
diff --git a/src/lib/tls/msg_finished.cpp b/src/lib/tls/msg_finished.cpp
index 7d5eea77a..18398e48b 100644
--- a/src/lib/tls/msg_finished.cpp
+++ b/src/lib/tls/msg_finished.cpp
@@ -17,21 +17,21 @@ namespace {
/*
* Compute the verify_data
*/
-std::vector<byte> finished_compute_verify(const Handshake_State& state,
+std::vector<uint8_t> finished_compute_verify(const Handshake_State& state,
Connection_Side side)
{
- const byte TLS_CLIENT_LABEL[] = {
+ const uint8_t TLS_CLIENT_LABEL[] = {
0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x20, 0x66, 0x69, 0x6E, 0x69,
0x73, 0x68, 0x65, 0x64 };
- const byte TLS_SERVER_LABEL[] = {
+ const uint8_t TLS_SERVER_LABEL[] = {
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x66, 0x69, 0x6E, 0x69,
0x73, 0x68, 0x65, 0x64 };
std::unique_ptr<KDF> prf(state.protocol_specific_prf());
- std::vector<byte> input;
- std::vector<byte> label;
+ std::vector<uint8_t> input;
+ std::vector<uint8_t> label;
if(side == CLIENT)
label += std::make_pair(TLS_CLIENT_LABEL, sizeof(TLS_CLIENT_LABEL));
else
@@ -57,7 +57,7 @@ Finished::Finished(Handshake_IO& io,
/*
* Serialize a Finished message
*/
-std::vector<byte> Finished::serialize() const
+std::vector<uint8_t> Finished::serialize() const
{
return m_verification_data;
}
@@ -65,7 +65,7 @@ std::vector<byte> Finished::serialize() const
/*
* Deserialize a Finished message
*/
-Finished::Finished(const std::vector<byte>& buf) : m_verification_data(buf)
+Finished::Finished(const std::vector<uint8_t>& buf) : m_verification_data(buf)
{}
/*
diff --git a/src/lib/tls/msg_hello_verify.cpp b/src/lib/tls/msg_hello_verify.cpp
index 059d9d4fd..34b7bb3d5 100644
--- a/src/lib/tls/msg_hello_verify.cpp
+++ b/src/lib/tls/msg_hello_verify.cpp
@@ -12,7 +12,7 @@ namespace Botan {
namespace TLS {
-Hello_Verify_Request::Hello_Verify_Request(const std::vector<byte>& buf)
+Hello_Verify_Request::Hello_Verify_Request(const std::vector<uint8_t>& buf)
{
if(buf.size() < 3)
throw Decoding_Error("Hello verify request too small");
@@ -31,7 +31,7 @@ Hello_Verify_Request::Hello_Verify_Request(const std::vector<byte>& buf)
m_cookie.assign(buf.begin() + 3, buf.end());
}
-Hello_Verify_Request::Hello_Verify_Request(const std::vector<byte>& client_hello_bits,
+Hello_Verify_Request::Hello_Verify_Request(const std::vector<uint8_t>& client_hello_bits,
const std::string& client_identity,
const SymmetricKey& secret_key)
{
@@ -46,7 +46,7 @@ Hello_Verify_Request::Hello_Verify_Request(const std::vector<byte>& client_hello
m_cookie = unlock(hmac->final());
}
-std::vector<byte> Hello_Verify_Request::serialize() const
+std::vector<uint8_t> Hello_Verify_Request::serialize() const
{
/* DTLS 1.2 server implementations SHOULD use DTLS version 1.0
regardless of the version of TLS that is expected to be
@@ -55,10 +55,10 @@ std::vector<byte> Hello_Verify_Request::serialize() const
Protocol_Version format_version(Protocol_Version::DTLS_V10);
- std::vector<byte> bits;
+ std::vector<uint8_t> bits;
bits.push_back(format_version.major_version());
bits.push_back(format_version.minor_version());
- bits.push_back(static_cast<byte>(m_cookie.size()));
+ bits.push_back(static_cast<uint8_t>(m_cookie.size()));
bits += m_cookie;
return bits;
}
diff --git a/src/lib/tls/msg_server_hello.cpp b/src/lib/tls/msg_server_hello.cpp
index 37e521403..9d84a29e0 100644
--- a/src/lib/tls/msg_server_hello.cpp
+++ b/src/lib/tls/msg_server_hello.cpp
@@ -22,7 +22,7 @@ Server_Hello::Server_Hello(Handshake_IO& io,
Handshake_Hash& hash,
const Policy& policy,
RandomNumberGenerator& rng,
- const std::vector<byte>& reneg_info,
+ const std::vector<uint8_t>& reneg_info,
const Client_Hello& client_hello,
const Server_Hello::Settings& server_settings,
const std::string next_protocol) :
@@ -62,12 +62,12 @@ Server_Hello::Server_Hello(Handshake_IO& io,
if(m_version.is_datagram_protocol())
{
- const std::vector<u16bit> server_srtp = policy.srtp_profiles();
- const std::vector<u16bit> client_srtp = client_hello.srtp_profiles();
+ const std::vector<uint16_t> server_srtp = policy.srtp_profiles();
+ const std::vector<uint16_t> client_srtp = client_hello.srtp_profiles();
if(!server_srtp.empty() && !client_srtp.empty())
{
- u16bit shared = 0;
+ uint16_t shared = 0;
// always using server preferences for now
for(auto s_srtp : server_srtp)
for(auto c_srtp : client_srtp)
@@ -89,7 +89,7 @@ Server_Hello::Server_Hello(Handshake_IO& io,
Handshake_Hash& hash,
const Policy& policy,
RandomNumberGenerator& rng,
- const std::vector<byte>& reneg_info,
+ const std::vector<uint8_t>& reneg_info,
const Client_Hello& client_hello,
Session& resumed_session,
bool offer_session_ticket,
@@ -139,23 +139,23 @@ Server_Hello::Server_Hello(Handshake_IO& io,
/*
* Deserialize a Server Hello message
*/
-Server_Hello::Server_Hello(const std::vector<byte>& buf)
+Server_Hello::Server_Hello(const std::vector<uint8_t>& buf)
{
if(buf.size() < 38)
throw Decoding_Error("Server_Hello: Packet corrupted");
TLS_Data_Reader reader("ServerHello", buf);
- const byte major_version = reader.get_byte();
- const byte minor_version = reader.get_byte();
+ const uint8_t major_version = reader.get_byte();
+ const uint8_t minor_version = reader.get_byte();
m_version = Protocol_Version(major_version, minor_version);
- m_random = reader.get_fixed<byte>(32);
+ m_random = reader.get_fixed<uint8_t>(32);
- m_session_id = reader.get_range<byte>(1, 0, 32);
+ m_session_id = reader.get_range<uint8_t>(1, 0, 32);
- m_ciphersuite = reader.get_u16bit();
+ m_ciphersuite = reader.get_uint16_t();
m_comp_method = reader.get_byte();
@@ -165,9 +165,9 @@ Server_Hello::Server_Hello(const std::vector<byte>& buf)
/*
* Serialize a Server Hello message
*/
-std::vector<byte> Server_Hello::serialize() const
+std::vector<uint8_t> Server_Hello::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
buf.push_back(m_version.major_version());
buf.push_back(m_version.minor_version());
@@ -197,7 +197,7 @@ Server_Hello_Done::Server_Hello_Done(Handshake_IO& io,
/*
* Deserialize a Server Hello Done message
*/
-Server_Hello_Done::Server_Hello_Done(const std::vector<byte>& buf)
+Server_Hello_Done::Server_Hello_Done(const std::vector<uint8_t>& buf)
{
if(buf.size())
throw Decoding_Error("Server_Hello_Done: Must be empty, and is not");
@@ -206,9 +206,9 @@ Server_Hello_Done::Server_Hello_Done(const std::vector<byte>& buf)
/*
* Serialize a Server Hello Done message
*/
-std::vector<byte> Server_Hello_Done::serialize() const
+std::vector<uint8_t> Server_Hello_Done::serialize() const
{
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
}
diff --git a/src/lib/tls/msg_server_kex.cpp b/src/lib/tls/msg_server_kex.cpp
index 72b90a31c..244d97611 100644
--- a/src/lib/tls/msg_server_kex.cpp
+++ b/src/lib/tls/msg_server_kex.cpp
@@ -81,7 +81,7 @@ Server_Key_Exchange::Server_Key_Exchange(Handshake_IO& io,
if(named_curve_id == 0)
throw Internal_Error("TLS does not support ECC with " + curve_name);
- std::vector<byte> ecdh_public_val;
+ std::vector<uint8_t> ecdh_public_val;
if(curve_name == "x25519")
{
@@ -119,7 +119,7 @@ Server_Key_Exchange::Server_Key_Exchange(Handshake_IO& io,
std::string group_id;
BigInt v;
- std::vector<byte> salt;
+ std::vector<uint8_t> salt;
const bool found = creds.srp_verifier("tls-server", hostname,
srp_identifier,
@@ -178,7 +178,7 @@ Server_Key_Exchange::Server_Key_Exchange(Handshake_IO& io,
/**
* Deserialize a Server Key Exchange message
*/
-Server_Key_Exchange::Server_Key_Exchange(const std::vector<byte>& buf,
+Server_Key_Exchange::Server_Key_Exchange(const std::vector<uint8_t>& buf,
const std::string& kex_algo,
const std::string& sig_algo,
Protocol_Version version)
@@ -202,28 +202,28 @@ Server_Key_Exchange::Server_Key_Exchange(const std::vector<byte>& buf,
for(size_t i = 0; i != 3; ++i)
{
- reader.get_range<byte>(2, 1, 65535);
+ reader.get_range<uint8_t>(2, 1, 65535);
}
}
else if(kex_algo == "ECDH" || kex_algo == "ECDHE_PSK")
{
reader.get_byte(); // curve type
- reader.get_u16bit(); // curve id
- reader.get_range<byte>(1, 1, 255); // public key
+ reader.get_uint16_t(); // curve id
+ reader.get_range<uint8_t>(1, 1, 255); // public key
}
else if(kex_algo == "SRP_SHA")
{
// 2 bigints (N,g) then salt, then server B
- reader.get_range<byte>(2, 1, 65535);
- reader.get_range<byte>(2, 1, 65535);
- reader.get_range<byte>(1, 1, 255);
- reader.get_range<byte>(2, 1, 65535);
+ reader.get_range<uint8_t>(2, 1, 65535);
+ reader.get_range<uint8_t>(2, 1, 65535);
+ reader.get_range<uint8_t>(1, 1, 255);
+ reader.get_range<uint8_t>(2, 1, 65535);
}
else if(kex_algo == "CECPQ1")
{
// u16 blob
- reader.get_range<byte>(2, 1, 65535);
+ reader.get_range<uint8_t>(2, 1, 65535);
}
else if(kex_algo != "PSK")
throw Decoding_Error("Server_Key_Exchange: Unsupported kex type " + kex_algo);
@@ -238,7 +238,7 @@ Server_Key_Exchange::Server_Key_Exchange(const std::vector<byte>& buf,
m_sig_algo = Signature_Algorithms::sig_algo_name(reader.get_byte());
}
- m_signature = reader.get_range<byte>(2, 0, 65535);
+ m_signature = reader.get_range<uint8_t>(2, 0, 65535);
}
reader.assert_done();
@@ -249,9 +249,9 @@ Server_Key_Exchange::~Server_Key_Exchange() {}
/**
* Serialize a Server Key Exchange message
*/
-std::vector<byte> Server_Key_Exchange::serialize() const
+std::vector<uint8_t> Server_Key_Exchange::serialize() const
{
- std::vector<byte> buf = params();
+ std::vector<uint8_t> buf = params();
if(m_signature.size())
{
diff --git a/src/lib/tls/msg_session_ticket.cpp b/src/lib/tls/msg_session_ticket.cpp
index 3fe6e64cf..7a24c9dbd 100644
--- a/src/lib/tls/msg_session_ticket.cpp
+++ b/src/lib/tls/msg_session_ticket.cpp
@@ -17,8 +17,8 @@ namespace TLS {
New_Session_Ticket::New_Session_Ticket(Handshake_IO& io,
Handshake_Hash& hash,
- const std::vector<byte>& ticket,
- u32bit lifetime) :
+ const std::vector<uint8_t>& ticket,
+ uint32_t lifetime) :
m_ticket_lifetime_hint(lifetime),
m_ticket(ticket)
{
@@ -31,20 +31,20 @@ New_Session_Ticket::New_Session_Ticket(Handshake_IO& io,
hash.update(io.send(*this));
}
-New_Session_Ticket::New_Session_Ticket(const std::vector<byte>& buf)
+New_Session_Ticket::New_Session_Ticket(const std::vector<uint8_t>& buf)
{
if(buf.size() < 6)
throw Decoding_Error("Session ticket message too short to be valid");
TLS_Data_Reader reader("SessionTicket", buf);
- m_ticket_lifetime_hint = reader.get_u32bit();
- m_ticket = reader.get_range<byte>(2, 0, 65535);
+ m_ticket_lifetime_hint = reader.get_uint32_t();
+ m_ticket = reader.get_range<uint8_t>(2, 0, 65535);
}
-std::vector<byte> New_Session_Ticket::serialize() const
+std::vector<uint8_t> New_Session_Ticket::serialize() const
{
- std::vector<byte> buf(4);
+ std::vector<uint8_t> buf(4);
store_be(m_ticket_lifetime_hint, buf.data());
append_tls_length_value(buf, m_ticket, 2);
return buf;
diff --git a/src/lib/tls/sessions_sql/tls_session_manager_sql.cpp b/src/lib/tls/sessions_sql/tls_session_manager_sql.cpp
index 049c12df1..594822829 100644
--- a/src/lib/tls/sessions_sql/tls_session_manager_sql.cpp
+++ b/src/lib/tls/sessions_sql/tls_session_manager_sql.cpp
@@ -55,16 +55,16 @@ Session_Manager_SQL::Session_Manager_SQL(std::shared_ptr<SQL_Database> db,
if(stmt->step())
{
- std::pair<const byte*, size_t> salt = stmt->get_blob(0);
+ std::pair<const uint8_t*, size_t> salt = stmt->get_blob(0);
const size_t iterations = stmt->get_size_t(1);
const size_t check_val_db = stmt->get_size_t(2);
- secure_vector<byte> x = pbkdf->pbkdf_iterations(32 + 2,
+ secure_vector<uint8_t> x = pbkdf->pbkdf_iterations(32 + 2,
passphrase,
salt.first, salt.second,
iterations);
- const size_t check_val_created = make_u16bit(x[0], x[1]);
+ const size_t check_val_created = make_uint16(x[0], x[1]);
m_session_key.assign(x.begin() + 2, x.end());
if(check_val_created != check_val_db)
@@ -79,16 +79,16 @@ Session_Manager_SQL::Session_Manager_SQL(std::shared_ptr<SQL_Database> db,
// new database case
- std::vector<byte> salt = unlock(rng.random_vec(16));
+ std::vector<uint8_t> salt = unlock(rng.random_vec(16));
size_t iterations = 0;
- secure_vector<byte> x = pbkdf->pbkdf_timed(32 + 2,
+ secure_vector<uint8_t> x = pbkdf->pbkdf_timed(32 + 2,
passphrase,
salt.data(), salt.size(),
std::chrono::milliseconds(100),
iterations);
- size_t check_val = make_u16bit(x[0], x[1]);
+ size_t check_val = make_uint16(x[0], x[1]);
m_session_key.assign(x.begin() + 2, x.end());
auto stmt = m_db->new_statement("insert into tls_sessions_metadata values(?1, ?2, ?3)");
@@ -101,7 +101,7 @@ Session_Manager_SQL::Session_Manager_SQL(std::shared_ptr<SQL_Database> db,
}
}
-bool Session_Manager_SQL::load_from_session_id(const std::vector<byte>& session_id,
+bool Session_Manager_SQL::load_from_session_id(const std::vector<uint8_t>& session_id,
Session& session)
{
auto stmt = m_db->new_statement("select session from tls_sessions where session_id = ?1");
@@ -110,7 +110,7 @@ bool Session_Manager_SQL::load_from_session_id(const std::vector<byte>& session_
while(stmt->step())
{
- std::pair<const byte*, size_t> blob = stmt->get_blob(0);
+ std::pair<const uint8_t*, size_t> blob = stmt->get_blob(0);
try
{
@@ -137,7 +137,7 @@ bool Session_Manager_SQL::load_from_server_info(const Server_Information& server
while(stmt->step())
{
- std::pair<const byte*, size_t> blob = stmt->get_blob(0);
+ std::pair<const uint8_t*, size_t> blob = stmt->get_blob(0);
try
{
@@ -152,7 +152,7 @@ bool Session_Manager_SQL::load_from_server_info(const Server_Information& server
return false;
}
-void Session_Manager_SQL::remove_entry(const std::vector<byte>& session_id)
+void Session_Manager_SQL::remove_entry(const std::vector<uint8_t>& session_id)
{
auto stmt = m_db->new_statement("delete from tls_sessions where session_id = ?1");
diff --git a/src/lib/tls/sessions_sql/tls_session_manager_sql.h b/src/lib/tls/sessions_sql/tls_session_manager_sql.h
index 24e2be7c3..f22d01172 100644
--- a/src/lib/tls/sessions_sql/tls_session_manager_sql.h
+++ b/src/lib/tls/sessions_sql/tls_session_manager_sql.h
@@ -48,13 +48,13 @@ class BOTAN_DLL Session_Manager_SQL : public Session_Manager
Session_Manager_SQL& operator=(const Session_Manager_SQL&) = delete;
- bool load_from_session_id(const std::vector<byte>& session_id,
+ bool load_from_session_id(const std::vector<uint8_t>& session_id,
Session& session) override;
bool load_from_server_info(const Server_Information& info,
Session& session) override;
- void remove_entry(const std::vector<byte>& session_id) override;
+ void remove_entry(const std::vector<uint8_t>& session_id) override;
size_t remove_all() override;
@@ -67,7 +67,7 @@ class BOTAN_DLL Session_Manager_SQL : public Session_Manager
void prune_session_cache();
std::shared_ptr<SQL_Database> m_db;
- secure_vector<byte> m_session_key;
+ secure_vector<uint8_t> m_session_key;
RandomNumberGenerator& m_rng;
size_t m_max_sessions;
std::chrono::seconds m_session_lifetime;
diff --git a/src/lib/tls/tls_alert.cpp b/src/lib/tls/tls_alert.cpp
index 6cecb3bbe..e1e8c6eb6 100644
--- a/src/lib/tls/tls_alert.cpp
+++ b/src/lib/tls/tls_alert.cpp
@@ -12,7 +12,7 @@ namespace Botan {
namespace TLS {
-Alert::Alert(const secure_vector<byte>& buf)
+Alert::Alert(const secure_vector<uint8_t>& buf)
{
if(buf.size() != 2)
throw Decoding_Error("Alert: Bad size " + std::to_string(buf.size()) +
@@ -23,16 +23,16 @@ Alert::Alert(const secure_vector<byte>& buf)
else
throw Decoding_Error("Alert: Bad code for alert level");
- const byte dc = buf[1];
+ const uint8_t dc = buf[1];
m_type_code = static_cast<Type>(dc);
}
-std::vector<byte> Alert::serialize() const
+std::vector<uint8_t> Alert::serialize() const
{
- return std::vector<byte>({
- static_cast<byte>(is_fatal() ? 2 : 1),
- static_cast<byte>(type())
+ return std::vector<uint8_t>({
+ static_cast<uint8_t>(is_fatal() ? 2 : 1),
+ static_cast<uint8_t>(type())
});
}
diff --git a/src/lib/tls/tls_alert.h b/src/lib/tls/tls_alert.h
index 1184c6260..1cfc95544 100644
--- a/src/lib/tls/tls_alert.h
+++ b/src/lib/tls/tls_alert.h
@@ -86,13 +86,13 @@ class BOTAN_DLL Alert
/**
* Serialize an alert
*/
- std::vector<byte> serialize() const;
+ std::vector<uint8_t> serialize() const;
/**
* Deserialize an Alert message
* @param buf the serialized alert
*/
- explicit Alert(const secure_vector<byte>& buf);
+ explicit Alert(const secure_vector<uint8_t>& buf);
/**
* Create a new Alert
diff --git a/src/lib/tls/tls_blocking.cpp b/src/lib/tls/tls_blocking.cpp
index 9408972fd..83e4a340c 100644
--- a/src/lib/tls/tls_blocking.cpp
+++ b/src/lib/tls/tls_blocking.cpp
@@ -51,14 +51,14 @@ void Blocking_Client::alert_cb(const Alert& alert)
this->alert_notification(alert);
}
-void Blocking_Client::data_cb(const byte data[], size_t data_len)
+void Blocking_Client::data_cb(const uint8_t data[], size_t data_len)
{
m_plaintext.insert(m_plaintext.end(), data, data + data_len);
}
void Blocking_Client::do_handshake()
{
- std::vector<byte> readbuf(4096);
+ std::vector<uint8_t> readbuf(4096);
while(!m_channel.is_closed() && !m_channel.is_active())
{
@@ -67,9 +67,9 @@ void Blocking_Client::do_handshake()
}
}
-size_t Blocking_Client::read(byte buf[], size_t buf_len)
+size_t Blocking_Client::read(uint8_t buf[], size_t buf_len)
{
- std::vector<byte> readbuf(4096);
+ std::vector<uint8_t> readbuf(4096);
while(m_plaintext.empty() && !m_channel.is_closed())
{
diff --git a/src/lib/tls/tls_blocking.h b/src/lib/tls/tls_blocking.h
index 0f2986710..96928f425 100644
--- a/src/lib/tls/tls_blocking.h
+++ b/src/lib/tls/tls_blocking.h
@@ -30,8 +30,8 @@ class BOTAN_DLL Blocking_Client
* These functions are expected to block until completing entirely, or
* fail by throwing an exception.
*/
- typedef std::function<size_t (byte[], size_t)> read_fn;
- typedef std::function<void (const byte[], size_t)> write_fn;
+ typedef std::function<size_t (uint8_t[], size_t)> read_fn;
+ typedef std::function<void (const uint8_t[], size_t)> write_fn;
BOTAN_DEPRECATED("Use the regular TLS::Client interface")
Blocking_Client(read_fn reader,
@@ -56,11 +56,12 @@ class BOTAN_DLL Blocking_Client
size_t pending() const { return m_plaintext.size(); }
/**
- * Blocking read, will return at least 1 byte or 0 on connection close
+ * Blocking read, will return at least 1 byte (eventually) or else 0 if the connection
+ * is closed.
*/
- size_t read(byte buf[], size_t buf_len);
+ size_t read(uint8_t buf[], size_t buf_len);
- void write(const byte buf[], size_t buf_len) { m_channel.send(buf, buf_len); }
+ void write(const uint8_t buf[], size_t buf_len) { m_channel.send(buf, buf_len); }
const TLS::Channel& underlying_channel() const { return m_channel; }
TLS::Channel& underlying_channel() { return m_channel; }
@@ -89,14 +90,14 @@ class BOTAN_DLL Blocking_Client
bool handshake_cb(const Session&);
- void data_cb(const byte data[], size_t data_len);
+ void data_cb(const uint8_t data[], size_t data_len);
void alert_cb(const Alert& alert);
read_fn m_read;
std::unique_ptr<Compat_Callbacks> m_callbacks;
TLS::Client m_channel;
- secure_vector<byte> m_plaintext;
+ secure_vector<uint8_t> m_plaintext;
};
}
diff --git a/src/lib/tls/tls_callbacks.h b/src/lib/tls/tls_callbacks.h
index 89e4aaa5d..a0b8894ad 100644
--- a/src/lib/tls/tls_callbacks.h
+++ b/src/lib/tls/tls_callbacks.h
@@ -61,7 +61,7 @@ class BOTAN_DLL Callbacks
*
* @param size the length of the received record, in bytes
*/
- virtual void tls_record_received(u64bit seq_no, const uint8_t data[], size_t size) = 0;
+ virtual void tls_record_received(uint64_t seq_no, const uint8_t data[], size_t size) = 0;
/**
* Mandatory callback: alert received
@@ -202,9 +202,9 @@ class BOTAN_DLL Callbacks
class BOTAN_DLL Compat_Callbacks final : public Callbacks
{
public:
- typedef std::function<void (const byte[], size_t)> output_fn;
- typedef std::function<void (const byte[], size_t)> data_cb;
- typedef std::function<void (Alert, const byte[], size_t)> alert_cb;
+ typedef std::function<void (const uint8_t[], size_t)> output_fn;
+ typedef std::function<void (const uint8_t[], size_t)> data_cb;
+ typedef std::function<void (Alert, const uint8_t[], size_t)> alert_cb;
typedef std::function<bool (const Session&)> handshake_cb;
typedef std::function<void (const Handshake_Message&)> handshake_msg_cb;
typedef std::function<std::string (std::vector<std::string>)> next_protocol_fn;
@@ -240,14 +240,14 @@ class BOTAN_DLL Compat_Callbacks final : public Callbacks
m_alert_cb(alert_cb),
m_hs_cb(hs_cb), m_hs_msg_cb(hs_msg_cb), m_next_proto(next_proto) {}
- void tls_emit_data(const byte data[], size_t size) override
+ void tls_emit_data(const uint8_t data[], size_t size) override
{
BOTAN_ASSERT(m_output_function != nullptr,
"Invalid TLS output function callback.");
m_output_function(data, size);
}
- void tls_record_received(u64bit /*seq_no*/, const byte data[], size_t size) override
+ void tls_record_received(uint64_t /*seq_no*/, const uint8_t data[], size_t size) override
{
BOTAN_ASSERT(m_app_data_cb != nullptr,
"Invalid TLS app data callback.");
diff --git a/src/lib/tls/tls_cbc/tls_cbc.cpp b/src/lib/tls/tls_cbc/tls_cbc.cpp
index bd9ce2528..9b6f511f5 100644
--- a/src/lib/tls/tls_cbc/tls_cbc.cpp
+++ b/src/lib/tls/tls_cbc/tls_cbc.cpp
@@ -79,7 +79,7 @@ Key_Length_Specification TLS_CBC_HMAC_AEAD_Mode::key_spec() const
return Key_Length_Specification(m_cipher_keylen + m_mac_keylen);
}
-void TLS_CBC_HMAC_AEAD_Mode::key_schedule(const byte key[], size_t keylen)
+void TLS_CBC_HMAC_AEAD_Mode::key_schedule(const uint8_t key[], size_t keylen)
{
// Both keys are of fixed length specified by the ciphersuite
@@ -90,7 +90,7 @@ void TLS_CBC_HMAC_AEAD_Mode::key_schedule(const byte key[], size_t keylen)
mac().set_key(&key[m_cipher_keylen], m_mac_keylen);
}
-void TLS_CBC_HMAC_AEAD_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void TLS_CBC_HMAC_AEAD_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
{
@@ -105,43 +105,43 @@ void TLS_CBC_HMAC_AEAD_Mode::start_msg(const byte nonce[], size_t nonce_len)
}
}
-size_t TLS_CBC_HMAC_AEAD_Mode::process(byte buf[], size_t sz)
+size_t TLS_CBC_HMAC_AEAD_Mode::process(uint8_t buf[], size_t sz)
{
m_msg.insert(m_msg.end(), buf, buf + sz);
return 0;
}
-std::vector<byte> TLS_CBC_HMAC_AEAD_Mode::assoc_data_with_len(uint16_t len)
+std::vector<uint8_t> TLS_CBC_HMAC_AEAD_Mode::assoc_data_with_len(uint16_t len)
{
- std::vector<byte> ad = m_ad;
+ std::vector<uint8_t> ad = m_ad;
BOTAN_ASSERT(ad.size() == 13, "Expected AAD size");
ad[11] = get_byte(0, len);
ad[12] = get_byte(1, len);
return ad;
}
-void TLS_CBC_HMAC_AEAD_Mode::set_associated_data(const byte ad[], size_t ad_len)
+void TLS_CBC_HMAC_AEAD_Mode::set_associated_data(const uint8_t ad[], size_t ad_len)
{
if(ad_len != 13)
throw Exception("Invalid TLS AEAD associated data length");
m_ad.assign(ad, ad + ad_len);
}
-void TLS_CBC_HMAC_AEAD_Encryption::set_associated_data(const byte ad[], size_t ad_len)
+void TLS_CBC_HMAC_AEAD_Encryption::set_associated_data(const uint8_t ad[], size_t ad_len)
{
TLS_CBC_HMAC_AEAD_Mode::set_associated_data(ad, ad_len);
if(use_encrypt_then_mac())
{
// AAD hack for EtM
- size_t pt_size = make_u16bit(assoc_data()[11], assoc_data()[12]);
+ size_t pt_size = make_uint16(assoc_data()[11], assoc_data()[12]);
size_t enc_size = round_up(iv_size() + pt_size + 1, block_size());
assoc_data()[11] = get_byte<uint16_t>(0, enc_size);
assoc_data()[12] = get_byte<uint16_t>(1, enc_size);
}
}
-void TLS_CBC_HMAC_AEAD_Encryption::cbc_encrypt_record(byte buf[], size_t buf_size)
+void TLS_CBC_HMAC_AEAD_Encryption::cbc_encrypt_record(uint8_t buf[], size_t buf_size)
{
const size_t blocks = buf_size / block_size();
BOTAN_ASSERT(buf_size % block_size() == 0, "Valid CBC input");
@@ -165,7 +165,7 @@ size_t TLS_CBC_HMAC_AEAD_Encryption::output_length(size_t input_length) const
(use_encrypt_then_mac() ? tag_size() : 0);
}
-void TLS_CBC_HMAC_AEAD_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void TLS_CBC_HMAC_AEAD_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
update(buffer, offset);
buffer.resize(offset); // truncate, leaving just header
@@ -191,12 +191,12 @@ void TLS_CBC_HMAC_AEAD_Encryption::finish(secure_vector<byte>& buffer, size_t of
}
for(size_t i = 0; i != pad_val + 1; ++i)
- buffer.push_back(static_cast<byte>(pad_val));
+ buffer.push_back(static_cast<uint8_t>(pad_val));
cbc_encrypt_record(&buffer[header_size], enc_size);
}
// EtM also uses ciphertext size instead of plaintext size for AEAD input
- const byte* mac_input = (use_encrypt_then_mac() ? &buffer[header_size] : msg().data());
+ const uint8_t* mac_input = (use_encrypt_then_mac() ? &buffer[header_size] : msg().data());
const size_t mac_input_len = (use_encrypt_then_mac() ? enc_size : msg().size());
mac().update(mac_input, mac_input_len);
@@ -207,7 +207,7 @@ void TLS_CBC_HMAC_AEAD_Encryption::finish(secure_vector<byte>& buffer, size_t of
if(use_encrypt_then_mac() == false)
{
for(size_t i = 0; i != pad_val + 1; ++i)
- buffer.push_back(static_cast<byte>(pad_val));
+ buffer.push_back(static_cast<uint8_t>(pad_val));
cbc_encrypt_record(&buffer[header_size], buf_size);
}
}
@@ -226,30 +226,30 @@ namespace {
* Returning 0 in the error case should ensure the MAC check will fail.
* This approach is suggested in section 6.2.3.2 of RFC 5246.
*/
-u16bit check_tls_padding(const byte record[], size_t record_len)
+uint16_t check_tls_padding(const uint8_t record[], size_t record_len)
{
/*
* TLS v1.0 and up require all the padding bytes be the same value
* and allows up to 255 bytes.
*/
- const byte pad_byte = record[(record_len-1)];
+ const uint8_t pad_byte = record[(record_len-1)];
- byte pad_invalid = 0;
+ uint8_t pad_invalid = 0;
for(size_t i = 0; i != record_len; ++i)
{
const size_t left = record_len - i - 2;
- const byte delim_mask = CT::is_less<u16bit>(static_cast<u16bit>(left), pad_byte) & 0xFF;
+ const uint8_t delim_mask = CT::is_less<uint16_t>(static_cast<uint16_t>(left), pad_byte) & 0xFF;
pad_invalid |= (delim_mask & (record[i] ^ pad_byte));
}
- u16bit pad_invalid_mask = CT::expand_mask<u16bit>(pad_invalid);
- return CT::select<u16bit>(pad_invalid_mask, 0, pad_byte + 1);
+ uint16_t pad_invalid_mask = CT::expand_mask<uint16_t>(pad_invalid);
+ return CT::select<uint16_t>(pad_invalid_mask, 0, pad_byte + 1);
}
}
-void TLS_CBC_HMAC_AEAD_Decryption::cbc_decrypt_record(byte record_contents[], size_t record_len)
+void TLS_CBC_HMAC_AEAD_Decryption::cbc_decrypt_record(uint8_t record_contents[], size_t record_len)
{
BOTAN_ASSERT(record_len % block_size() == 0,
"Buffer is an even multiple of block size");
@@ -258,15 +258,15 @@ void TLS_CBC_HMAC_AEAD_Decryption::cbc_decrypt_record(byte record_contents[], si
BOTAN_ASSERT(blocks >= 1, "At least one ciphertext block");
- byte* buf = record_contents;
+ uint8_t* buf = record_contents;
- secure_vector<byte> last_ciphertext(block_size());
+ secure_vector<uint8_t> last_ciphertext(block_size());
copy_mem(last_ciphertext.data(), buf, block_size());
cipher().decrypt(buf);
xor_buf(buf, cbc_state().data(), block_size());
- secure_vector<byte> last_ciphertext2;
+ secure_vector<uint8_t> last_ciphertext2;
for(size_t i = 1; i < blocks; ++i)
{
@@ -361,18 +361,18 @@ void TLS_CBC_HMAC_AEAD_Decryption::perform_additional_compressions(size_t plen,
// If there are no compressions, we just add 55/111 dummy bytes so that no
// compression is performed.
const uint16_t data_len = block_size * add_compressions + equal * max_bytes_in_first_block;
- secure_vector<byte> data(data_len);
+ secure_vector<uint8_t> data(data_len);
mac().update(unlock(data));
// we do not need to clear the MAC since the connection is broken anyway
}
-void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
update(buffer, offset);
buffer.resize(offset);
const size_t record_len = msg().size();
- byte* record_contents = msg().data();
+ uint8_t* record_contents = msg().data();
// This early exit does not leak info because all the values compared are public
if(record_len < tag_size() ||
@@ -392,7 +392,7 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<byte>& buffer, size_t of
}
mac().update(record_contents, enc_size);
- std::vector<byte> mac_buf(tag_size());
+ std::vector<uint8_t> mac_buf(tag_size());
mac().final(mac_buf.data());
const size_t mac_offset = enc_size;
@@ -407,7 +407,7 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<byte>& buffer, size_t of
cbc_decrypt_record(record_contents, enc_size);
// 0 if padding was invalid, otherwise 1 + padding_bytes
- u16bit pad_size = check_tls_padding(record_contents, enc_size);
+ uint16_t pad_size = check_tls_padding(record_contents, enc_size);
// No oracle here, whoever sent us this had the key since MAC check passed
if(pad_size == 0)
@@ -415,8 +415,8 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<byte>& buffer, size_t of
throw TLS_Exception(Alert::BAD_RECORD_MAC, "Message authentication failure");
}
- const byte* plaintext_block = &record_contents[0];
- const u16bit plaintext_length = enc_size - pad_size;
+ const uint8_t* plaintext_block = &record_contents[0];
+ const uint16_t plaintext_length = enc_size - pad_size;
buffer.insert(buffer.end(), plaintext_block, plaintext_block + plaintext_length);
}
@@ -427,7 +427,7 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<byte>& buffer, size_t of
cbc_decrypt_record(record_contents, record_len);
// 0 if padding was invalid, otherwise 1 + padding_bytes
- u16bit pad_size = check_tls_padding(record_contents, record_len);
+ uint16_t pad_size = check_tls_padding(record_contents, record_len);
/*
This mask is zero if there is not enough room in the packet to get a valid MAC.
@@ -437,7 +437,7 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<byte>& buffer, size_t of
(sending empty records, instead of 1/(n-1) splitting)
*/
- const u16bit size_ok_mask = CT::is_lte<u16bit>(static_cast<u16bit>(tag_size() + pad_size), static_cast<u16bit>(record_len + 1));
+ const uint16_t size_ok_mask = CT::is_lte<uint16_t>(static_cast<uint16_t>(tag_size() + pad_size), static_cast<uint16_t>(record_len + 1));
pad_size &= size_ok_mask;
CT::unpoison(record_contents, record_len);
@@ -448,20 +448,20 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<byte>& buffer, size_t of
*/
CT::unpoison(pad_size);
- const byte* plaintext_block = &record_contents[0];
- const u16bit plaintext_length = static_cast<u16bit>(record_len - tag_size() - pad_size);
+ const uint8_t* plaintext_block = &record_contents[0];
+ const uint16_t plaintext_length = static_cast<uint16_t>(record_len - tag_size() - pad_size);
mac().update(assoc_data_with_len(plaintext_length));
mac().update(plaintext_block, plaintext_length);
- std::vector<byte> mac_buf(tag_size());
+ std::vector<uint8_t> mac_buf(tag_size());
mac().final(mac_buf.data());
const size_t mac_offset = record_len - (tag_size() + pad_size);
const bool mac_ok = same_mem(&record_contents[mac_offset], mac_buf.data(), tag_size());
- const u16bit ok_mask = size_ok_mask & CT::expand_mask<u16bit>(mac_ok) & CT::expand_mask<u16bit>(pad_size);
+ const uint16_t ok_mask = size_ok_mask & CT::expand_mask<uint16_t>(mac_ok) & CT::expand_mask<uint16_t>(pad_size);
CT::unpoison(ok_mask);
diff --git a/src/lib/tls/tls_cbc/tls_cbc.h b/src/lib/tls/tls_cbc/tls_cbc.h
index 97c3387e8..d281c36f3 100644
--- a/src/lib/tls/tls_cbc/tls_cbc.h
+++ b/src/lib/tls/tls_cbc/tls_cbc.h
@@ -28,7 +28,7 @@ class BOTAN_DLL TLS_CBC_HMAC_AEAD_Mode : public AEAD_Mode
std::string name() const override final;
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
size_t update_granularity() const override final;
@@ -71,16 +71,16 @@ class BOTAN_DLL TLS_CBC_HMAC_AEAD_Mode : public AEAD_Mode
return *m_mac;
}
- secure_vector<byte>& cbc_state() { return m_cbc_state; }
- std::vector<byte>& assoc_data() { return m_ad; }
- secure_vector<byte>& msg() { return m_msg; }
+ secure_vector<uint8_t>& cbc_state() { return m_cbc_state; }
+ std::vector<uint8_t>& assoc_data() { return m_ad; }
+ secure_vector<uint8_t>& msg() { return m_msg; }
- std::vector<byte> assoc_data_with_len(uint16_t len);
+ std::vector<uint8_t> assoc_data_with_len(uint16_t len);
private:
- void start_msg(const byte nonce[], size_t nonce_len) override final;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override final;
- void key_schedule(const byte key[], size_t length) override final;
+ void key_schedule(const uint8_t key[], size_t length) override final;
const std::string m_cipher_name;
const std::string m_mac_name;
@@ -94,9 +94,9 @@ class BOTAN_DLL TLS_CBC_HMAC_AEAD_Mode : public AEAD_Mode
std::unique_ptr<BlockCipher> m_cipher;
std::unique_ptr<MessageAuthenticationCode> m_mac;
- secure_vector<byte> m_cbc_state;
- std::vector<byte> m_ad;
- secure_vector<byte> m_msg;
+ secure_vector<uint8_t> m_cbc_state;
+ std::vector<uint8_t> m_ad;
+ secure_vector<uint8_t> m_msg;
};
/**
@@ -121,15 +121,15 @@ class BOTAN_DLL TLS_CBC_HMAC_AEAD_Encryption final : public TLS_CBC_HMAC_AEAD_Mo
use_encrypt_then_mac)
{}
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
size_t output_length(size_t input_length) const override;
size_t minimum_final_size() const override { return 0; }
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
private:
- void cbc_encrypt_record(byte record_contents[], size_t record_len);
+ void cbc_encrypt_record(uint8_t record_contents[], size_t record_len);
};
/**
@@ -158,10 +158,10 @@ class BOTAN_DLL TLS_CBC_HMAC_AEAD_Decryption final : public TLS_CBC_HMAC_AEAD_Mo
size_t minimum_final_size() const override { return tag_size(); }
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
private:
- void cbc_decrypt_record(byte record_contents[], size_t record_len);
+ void cbc_decrypt_record(uint8_t record_contents[], size_t record_len);
void perform_additional_compressions(size_t plen, size_t padlen);
};
diff --git a/src/lib/tls/tls_channel.cpp b/src/lib/tls/tls_channel.cpp
index c8fe407e2..cc7b7df6b 100644
--- a/src/lib/tls/tls_channel.cpp
+++ b/src/lib/tls/tls_channel.cpp
@@ -86,7 +86,7 @@ Connection_Sequence_Numbers& Channel::sequence_numbers() const
return *m_sequence_numbers;
}
-std::shared_ptr<Connection_Cipher_State> Channel::read_cipher_state_epoch(u16bit epoch) const
+std::shared_ptr<Connection_Cipher_State> Channel::read_cipher_state_epoch(uint16_t epoch) const
{
auto i = m_read_cipher_states.find(epoch);
if(i == m_read_cipher_states.end())
@@ -94,7 +94,7 @@ std::shared_ptr<Connection_Cipher_State> Channel::read_cipher_state_epoch(u16bit
return i->second;
}
-std::shared_ptr<Connection_Cipher_State> Channel::write_cipher_state_epoch(u16bit epoch) const
+std::shared_ptr<Connection_Cipher_State> Channel::write_cipher_state_epoch(uint16_t epoch) const
{
auto i = m_write_cipher_states.find(epoch);
if(i == m_write_cipher_states.end())
@@ -142,7 +142,7 @@ Handshake_State& Channel::create_handshake_state(Protocol_Version version)
io.reset(new Datagram_Handshake_IO(
std::bind(&Channel::send_record_under_epoch, this, _1, _2, _3),
sequence_numbers(),
- static_cast<u16bit>(m_policy.dtls_default_mtu()),
+ static_cast<uint16_t>(m_policy.dtls_default_mtu()),
m_policy.dtls_initial_timeout(),
m_policy.dtls_maximum_timeout()));
}
@@ -192,7 +192,7 @@ void Channel::change_cipher_spec_reader(Connection_Side side)
sequence_numbers().new_read_cipher_state();
- const u16bit epoch = sequence_numbers().current_read_epoch();
+ const uint16_t epoch = sequence_numbers().current_read_epoch();
BOTAN_ASSERT(m_read_cipher_states.count(epoch) == 0,
"No read cipher state currently set for next epoch");
@@ -221,7 +221,7 @@ void Channel::change_cipher_spec_writer(Connection_Side side)
sequence_numbers().new_write_cipher_state();
- const u16bit epoch = sequence_numbers().current_write_epoch();
+ const uint16_t epoch = sequence_numbers().current_write_epoch();
BOTAN_ASSERT(m_write_cipher_states.count(epoch) == 0,
"No write cipher state currently set for next epoch");
@@ -264,10 +264,10 @@ void Channel::activate_session()
if(!m_active_state->version().is_datagram_protocol())
{
// TLS is easy just remove all but the current state
- const u16bit current_epoch = sequence_numbers().current_write_epoch();
+ const uint16_t current_epoch = sequence_numbers().current_write_epoch();
const auto not_current_epoch =
- [current_epoch](u16bit epoch) { return (epoch != current_epoch); };
+ [current_epoch](uint16_t epoch) { return (epoch != current_epoch); };
map_remove_if(not_current_epoch, m_write_cipher_states);
map_remove_if(not_current_epoch, m_read_cipher_states);
@@ -276,19 +276,19 @@ void Channel::activate_session()
callbacks().tls_session_activated();
}
-size_t Channel::received_data(const std::vector<byte>& buf)
+size_t Channel::received_data(const std::vector<uint8_t>& buf)
{
return this->received_data(buf.data(), buf.size());
}
-size_t Channel::received_data(const byte input[], size_t input_size)
+size_t Channel::received_data(const uint8_t input[], size_t input_size)
{
try
{
while(!is_closed() && input_size)
{
- secure_vector<byte> record_data;
- u64bit record_sequence = 0;
+ secure_vector<uint8_t> record_data;
+ uint64_t record_sequence = 0;
Record_Type record_type = NO_RECORD;
Protocol_Version record_version;
@@ -364,8 +364,8 @@ size_t Channel::received_data(const byte input[], size_t input_size)
}
}
-void Channel::process_handshake_ccs(const secure_vector<byte>& record,
- u64bit record_sequence,
+void Channel::process_handshake_ccs(const secure_vector<uint8_t>& record,
+ uint64_t record_sequence,
Record_Type record_type,
Protocol_Version record_version)
{
@@ -382,7 +382,7 @@ void Channel::process_handshake_ccs(const secure_vector<byte>& record,
*/
sequence_numbers().read_accept(record_sequence);
- const u16bit epoch = record_sequence >> 48;
+ const uint16_t epoch = record_sequence >> 48;
if(epoch == sequence_numbers().current_read_epoch())
{
@@ -427,7 +427,7 @@ void Channel::process_handshake_ccs(const secure_vector<byte>& record,
}
}
-void Channel::process_application_data(u64bit seq_no, const secure_vector<byte>& record)
+void Channel::process_application_data(uint64_t seq_no, const secure_vector<uint8_t>& record)
{
if(!active_state())
throw Unexpected_Message("Application data before handshake done");
@@ -441,7 +441,7 @@ void Channel::process_application_data(u64bit seq_no, const secure_vector<byte>&
callbacks().tls_record_received(seq_no, record.data(), record.size());
}
-void Channel::process_alert(const secure_vector<byte>& record)
+void Channel::process_alert(const secure_vector<uint8_t>& record)
{
Alert alert_msg(record);
@@ -466,8 +466,8 @@ void Channel::process_alert(const secure_vector<byte>& record)
}
-void Channel::write_record(Connection_Cipher_State* cipher_state, u16bit epoch,
- byte record_type, const byte input[], size_t length)
+void Channel::write_record(Connection_Cipher_State* cipher_state, uint16_t epoch,
+ uint8_t record_type, const uint8_t input[], size_t length)
{
BOTAN_ASSERT(m_pending_state || m_active_state, "Some connection state exists");
@@ -486,7 +486,7 @@ void Channel::write_record(Connection_Cipher_State* cipher_state, u16bit epoch,
callbacks().tls_emit_data(m_writebuf.data(), m_writebuf.size());
}
-void Channel::send_record_array(u16bit epoch, byte type, const byte input[], size_t length)
+void Channel::send_record_array(uint16_t epoch, uint8_t type, const uint8_t input[], size_t length)
{
if(length == 0)
return;
@@ -523,19 +523,19 @@ void Channel::send_record_array(u16bit epoch, byte type, const byte input[], siz
}
}
-void Channel::send_record(byte record_type, const std::vector<byte>& record)
+void Channel::send_record(uint8_t record_type, const std::vector<uint8_t>& record)
{
send_record_array(sequence_numbers().current_write_epoch(),
record_type, record.data(), record.size());
}
-void Channel::send_record_under_epoch(u16bit epoch, byte record_type,
- const std::vector<byte>& record)
+void Channel::send_record_under_epoch(uint16_t epoch, uint8_t record_type,
+ const std::vector<uint8_t>& record)
{
send_record_array(epoch, record_type, record.data(), record.size());
}
-void Channel::send(const byte buf[], size_t buf_size)
+void Channel::send(const uint8_t buf[], size_t buf_size)
{
if(!is_active())
throw Exception("Data cannot be sent on inactive TLS connection");
@@ -546,7 +546,7 @@ void Channel::send(const byte buf[], size_t buf_size)
void Channel::send(const std::string& string)
{
- this->send(reinterpret_cast<const byte*>(string.c_str()), string.size());
+ this->send(reinterpret_cast<const uint8_t*>(string.c_str()), string.size());
}
void Channel::send_alert(const Alert& alert)
@@ -586,7 +586,7 @@ void Channel::secure_renegotiation_check(const Client_Hello* client_hello)
if(secure_renegotiation)
{
- const std::vector<byte>& data = client_hello->renegotiation_info();
+ const std::vector<uint8_t>& data = client_hello->renegotiation_info();
if(data != secure_renegotiation_data_for_client_hello())
throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
@@ -609,7 +609,7 @@ void Channel::secure_renegotiation_check(const Server_Hello* server_hello)
if(secure_renegotiation)
{
- const std::vector<byte>& data = server_hello->renegotiation_info();
+ const std::vector<uint8_t>& data = server_hello->renegotiation_info();
if(data != secure_renegotiation_data_for_server_hello())
throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
@@ -617,23 +617,23 @@ void Channel::secure_renegotiation_check(const Server_Hello* server_hello)
}
}
-std::vector<byte> Channel::secure_renegotiation_data_for_client_hello() const
+std::vector<uint8_t> Channel::secure_renegotiation_data_for_client_hello() const
{
if(auto active = active_state())
return active->client_finished()->verify_data();
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
-std::vector<byte> Channel::secure_renegotiation_data_for_server_hello() const
+std::vector<uint8_t> Channel::secure_renegotiation_data_for_server_hello() const
{
if(auto active = active_state())
{
- std::vector<byte> buf = active->client_finished()->verify_data();
+ std::vector<uint8_t> buf = active->client_finished()->verify_data();
buf += active->server_finished()->verify_data();
return buf;
}
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
bool Channel::secure_renegotiation_supported() const
@@ -656,10 +656,10 @@ SymmetricKey Channel::key_material_export(const std::string& label,
{
std::unique_ptr<KDF> prf(active->protocol_specific_prf());
- const secure_vector<byte>& master_secret =
+ const secure_vector<uint8_t>& master_secret =
active->session_keys().master_secret();
- std::vector<byte> salt;
+ std::vector<uint8_t> salt;
salt += active->client_hello()->random();
salt += active->server_hello()->random();
@@ -668,8 +668,8 @@ SymmetricKey Channel::key_material_export(const std::string& label,
size_t context_size = context.length();
if(context_size > 0xFFFF)
throw Exception("key_material_export context is too long");
- salt.push_back(get_byte(0, static_cast<u16bit>(context_size)));
- salt.push_back(get_byte(1, static_cast<u16bit>(context_size)));
+ salt.push_back(get_byte(0, static_cast<uint16_t>(context_size)));
+ salt.push_back(get_byte(1, static_cast<uint16_t>(context_size)));
salt += to_byte_vector(context);
}
diff --git a/src/lib/tls/tls_channel.h b/src/lib/tls/tls_channel.h
index 110269e80..e098d8ef1 100644
--- a/src/lib/tls/tls_channel.h
+++ b/src/lib/tls/tls_channel.h
@@ -36,9 +36,9 @@ class Server_Hello;
class BOTAN_DLL Channel
{
public:
- typedef std::function<void (const byte[], size_t)> output_fn;
- typedef std::function<void (const byte[], size_t)> data_cb;
- typedef std::function<void (Alert, const byte[], size_t)> alert_cb;
+ typedef std::function<void (const uint8_t[], size_t)> output_fn;
+ typedef std::function<void (const uint8_t[], size_t)> data_cb;
+ typedef std::function<void (Alert, const uint8_t[], size_t)> alert_cb;
typedef std::function<bool (const Session&)> handshake_cb;
typedef std::function<void (const Handshake_Message&)> handshake_msg_cb;
static size_t IO_BUF_DEFAULT_SIZE;
@@ -96,20 +96,20 @@ class BOTAN_DLL Channel
* @return a hint as the how many more bytes we need to process the
* current record (this may be 0 if on a record boundary)
*/
- size_t received_data(const byte buf[], size_t buf_size);
+ size_t received_data(const uint8_t buf[], size_t buf_size);
/**
* Inject TLS traffic received from counterparty
* @return a hint as the how many more bytes we need to process the
* current record (this may be 0 if on a record boundary)
*/
- size_t received_data(const std::vector<byte>& buf);
+ size_t received_data(const std::vector<uint8_t>& buf);
/**
* Inject plaintext intended for counterparty
* Throws an exception if is_active() is false
*/
- void send(const byte buf[], size_t buf_size);
+ void send(const uint8_t buf[], size_t buf_size);
/**
* Inject plaintext intended for counterparty
@@ -202,7 +202,7 @@ class BOTAN_DLL Channel
virtual void process_handshake_msg(const Handshake_State* active_state,
Handshake_State& pending_state,
Handshake_Type type,
- const std::vector<byte>& contents) = 0;
+ const std::vector<uint8_t>& contents) = 0;
virtual void initiate_handshake(Handshake_State& state,
bool force_full_renegotiation) = 0;
@@ -227,8 +227,8 @@ class BOTAN_DLL Channel
void secure_renegotiation_check(const Client_Hello* client_hello);
void secure_renegotiation_check(const Server_Hello* server_hello);
- std::vector<byte> secure_renegotiation_data_for_client_hello() const;
- std::vector<byte> secure_renegotiation_data_for_server_hello() const;
+ std::vector<uint8_t> secure_renegotiation_data_for_client_hello() const;
+ std::vector<uint8_t> secure_renegotiation_data_for_server_hello() const;
RandomNumberGenerator& rng() { return m_rng; }
@@ -242,22 +242,22 @@ class BOTAN_DLL Channel
private:
void init(size_t io_buf_sze);
- void send_record(byte record_type, const std::vector<byte>& record);
+ void send_record(uint8_t record_type, const std::vector<uint8_t>& record);
- void send_record_under_epoch(u16bit epoch, byte record_type,
- const std::vector<byte>& record);
+ void send_record_under_epoch(uint16_t epoch, uint8_t record_type,
+ const std::vector<uint8_t>& record);
- void send_record_array(u16bit epoch, byte record_type,
- const byte input[], size_t length);
+ void send_record_array(uint16_t epoch, uint8_t record_type,
+ const uint8_t input[], size_t length);
void write_record(Connection_Cipher_State* cipher_state,
- u16bit epoch, byte type, const byte input[], size_t length);
+ uint16_t epoch, uint8_t type, const uint8_t input[], size_t length);
Connection_Sequence_Numbers& sequence_numbers() const;
- std::shared_ptr<Connection_Cipher_State> read_cipher_state_epoch(u16bit epoch) const;
+ std::shared_ptr<Connection_Cipher_State> read_cipher_state_epoch(uint16_t epoch) const;
- std::shared_ptr<Connection_Cipher_State> write_cipher_state_epoch(u16bit epoch) const;
+ std::shared_ptr<Connection_Cipher_State> write_cipher_state_epoch(uint16_t epoch) const;
void reset_state();
@@ -266,14 +266,14 @@ class BOTAN_DLL Channel
const Handshake_State* pending_state() const { return m_pending_state.get(); }
/* methods to handle incoming traffic through Channel::receive_data. */
- void process_handshake_ccs(const secure_vector<byte>& record,
- u64bit record_sequence,
+ void process_handshake_ccs(const secure_vector<uint8_t>& record,
+ uint64_t record_sequence,
Record_Type record_type,
Protocol_Version record_version);
- void process_application_data(u64bit req_no, const secure_vector<byte>& record);
+ void process_application_data(uint64_t req_no, const secure_vector<uint8_t>& record);
- void process_alert(const secure_vector<byte>& record);
+ void process_alert(const secure_vector<uint8_t>& record);
bool m_is_datagram;
@@ -294,12 +294,12 @@ class BOTAN_DLL Channel
std::unique_ptr<Handshake_State> m_pending_state;
/* cipher states for each epoch */
- std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states;
- std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states;
+ std::map<uint16_t, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states;
+ std::map<uint16_t, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states;
/* I/O buffers */
- secure_vector<byte> m_writebuf;
- secure_vector<byte> m_readbuf;
+ secure_vector<uint8_t> m_writebuf;
+ secure_vector<uint8_t> m_readbuf;
};
}
diff --git a/src/lib/tls/tls_ciphersuite.cpp b/src/lib/tls/tls_ciphersuite.cpp
index 08ef8e812..346d62bea 100644
--- a/src/lib/tls/tls_ciphersuite.cpp
+++ b/src/lib/tls/tls_ciphersuite.cpp
@@ -17,7 +17,7 @@ namespace Botan {
namespace TLS {
-bool Ciphersuite::is_scsv(u16bit suite)
+bool Ciphersuite::is_scsv(uint16_t suite)
{
// TODO: derive from IANA file in script
return (suite == 0x00FF || suite == 0x5600);
@@ -40,7 +40,7 @@ bool Ciphersuite::cbc_ciphersuite() const
return (mac_algo() != "AEAD");
}
-Ciphersuite Ciphersuite::by_id(u16bit suite)
+Ciphersuite Ciphersuite::by_id(uint16_t suite)
{
const std::vector<Ciphersuite>& all_suites = all_known_ciphersuites();
auto s = std::lower_bound(all_suites.begin(), all_suites.end(), suite);
diff --git a/src/lib/tls/tls_ciphersuite.h b/src/lib/tls/tls_ciphersuite.h
index fe3392a38..dd8e27b6f 100644
--- a/src/lib/tls/tls_ciphersuite.h
+++ b/src/lib/tls/tls_ciphersuite.h
@@ -27,12 +27,12 @@ class BOTAN_DLL Ciphersuite
* @param suite the ciphersuite code number
* @return ciphersuite object
*/
- static Ciphersuite by_id(u16bit suite);
+ static Ciphersuite by_id(uint16_t suite);
/**
* Returns true iff this suite is a known SCSV
*/
- static bool is_scsv(u16bit suite);
+ static bool is_scsv(uint16_t suite);
/**
* Generate a static list of all known ciphersuites and return it.
@@ -50,7 +50,7 @@ class BOTAN_DLL Ciphersuite
/**
* @return ciphersuite number
*/
- u16bit ciphersuite_code() const { return m_ciphersuite_code; }
+ uint16_t ciphersuite_code() const { return m_ciphersuite_code; }
/**
* @return true if this is a PSK ciphersuite
@@ -111,7 +111,7 @@ class BOTAN_DLL Ciphersuite
bool valid() const { return m_usable; }
bool operator<(const Ciphersuite& o) const { return ciphersuite_code() < o.ciphersuite_code(); }
- bool operator<(const u16bit c) const { return ciphersuite_code() < c; }
+ bool operator<(const uint16_t c) const { return ciphersuite_code() < c; }
Ciphersuite() {}
@@ -119,7 +119,7 @@ class BOTAN_DLL Ciphersuite
bool is_usable() const;
- Ciphersuite(u16bit ciphersuite_code,
+ Ciphersuite(uint16_t ciphersuite_code,
const char* iana_id,
const char* sig_algo,
const char* kex_algo,
@@ -145,7 +145,7 @@ class BOTAN_DLL Ciphersuite
m_usable = is_usable();
}
- u16bit m_ciphersuite_code = 0;
+ uint16_t m_ciphersuite_code = 0;
/*
All of these const char* strings are references to compile time
diff --git a/src/lib/tls/tls_client.cpp b/src/lib/tls/tls_client.cpp
index 37dd37812..16179832a 100644
--- a/src/lib/tls/tls_client.cpp
+++ b/src/lib/tls/tls_client.cpp
@@ -35,7 +35,7 @@ class Client_Handshake_State : public Handshake_State
}
// Used during session resumption
- secure_vector<byte> resume_master_secret;
+ secure_vector<uint8_t> resume_master_secret;
std::unique_ptr<Public_Key> server_public_key;
};
@@ -196,7 +196,7 @@ void Client::send_client_hello(Handshake_State& state_base,
void Client::process_handshake_msg(const Handshake_State* active_state,
Handshake_State& state_base,
Handshake_Type type,
- const std::vector<byte>& contents)
+ const std::vector<uint8_t>& contents)
{
Client_Handshake_State& state = dynamic_cast<Client_Handshake_State&>(state_base);
@@ -281,7 +281,7 @@ void Client::process_handshake_msg(const Handshake_State* active_state,
throw TLS_Exception(Alert::HANDSHAKE_FAILURE, msg.str());
}
- if(u16bit srtp = state.server_hello()->srtp_profile())
+ if(uint16_t srtp = state.server_hello()->srtp_profile())
{
if(!value_exists(state.client_hello()->srtp_profiles(), srtp))
throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
@@ -561,9 +561,9 @@ void Client::process_handshake_msg(const Handshake_State* active_state,
state.client_finished(new Finished(state.handshake_io(), state, CLIENT));
}
- std::vector<byte> session_id = state.server_hello()->session_id();
+ std::vector<uint8_t> session_id = state.server_hello()->session_id();
- const std::vector<byte>& session_ticket = state.session_ticket();
+ const std::vector<uint8_t>& session_ticket = state.session_ticket();
if(session_id.empty() && !session_ticket.empty())
session_id = make_hello_random(rng(), policy());
diff --git a/src/lib/tls/tls_client.h b/src/lib/tls/tls_client.h
index d3cff147e..3cf6a1e2b 100644
--- a/src/lib/tls/tls_client.h
+++ b/src/lib/tls/tls_client.h
@@ -150,7 +150,7 @@ class BOTAN_DLL Client final : public Channel
void process_handshake_msg(const Handshake_State* active_state,
Handshake_State& pending_state,
Handshake_Type type,
- const std::vector<byte>& contents) override;
+ const std::vector<uint8_t>& contents) override;
Handshake_State* new_handshake_state(Handshake_IO* io) override;
diff --git a/src/lib/tls/tls_extensions.cpp b/src/lib/tls/tls_extensions.cpp
index 731e149b2..85379a817 100644
--- a/src/lib/tls/tls_extensions.cpp
+++ b/src/lib/tls/tls_extensions.cpp
@@ -16,7 +16,7 @@ namespace TLS {
namespace {
-Extension* make_extension(TLS_Data_Reader& reader, u16bit code, u16bit size)
+Extension* make_extension(TLS_Data_Reader& reader, uint16_t code, uint16_t size)
{
switch(code)
{
@@ -68,15 +68,15 @@ void Extensions::deserialize(TLS_Data_Reader& reader)
{
if(reader.has_remaining())
{
- const u16bit all_extn_size = reader.get_u16bit();
+ const uint16_t all_extn_size = reader.get_uint16_t();
if(reader.remaining_bytes() != all_extn_size)
throw Decoding_Error("Bad extension size");
while(reader.has_remaining())
{
- const u16bit extension_code = reader.get_u16bit();
- const u16bit extension_size = reader.get_u16bit();
+ const uint16_t extension_code = reader.get_uint16_t();
+ const uint16_t extension_size = reader.get_uint16_t();
Extension* extn = make_extension(reader,
extension_code,
@@ -90,36 +90,36 @@ void Extensions::deserialize(TLS_Data_Reader& reader)
}
}
-std::vector<byte> Extensions::serialize() const
+std::vector<uint8_t> Extensions::serialize() const
{
- std::vector<byte> buf(2); // 2 bytes for length field
+ std::vector<uint8_t> buf(2); // 2 bytes for length field
for(auto& extn : m_extensions)
{
if(extn.second->empty())
continue;
- const u16bit extn_code = extn.second->type();
+ const uint16_t extn_code = extn.second->type();
- std::vector<byte> extn_val = extn.second->serialize();
+ std::vector<uint8_t> extn_val = extn.second->serialize();
buf.push_back(get_byte(0, extn_code));
buf.push_back(get_byte(1, extn_code));
- buf.push_back(get_byte(0, static_cast<u16bit>(extn_val.size())));
- buf.push_back(get_byte(1, static_cast<u16bit>(extn_val.size())));
+ buf.push_back(get_byte(0, static_cast<uint16_t>(extn_val.size())));
+ buf.push_back(get_byte(1, static_cast<uint16_t>(extn_val.size())));
buf += extn_val;
}
- const u16bit extn_size = static_cast<u16bit>(buf.size() - 2);
+ const uint16_t extn_size = static_cast<uint16_t>(buf.size() - 2);
buf[0] = get_byte(0, extn_size);
buf[1] = get_byte(1, extn_size);
// avoid sending a completely empty extensions block
if(buf.size() == 2)
- return std::vector<byte>();
+ return std::vector<uint8_t>();
return buf;
}
@@ -133,7 +133,7 @@ std::set<Handshake_Extension_Type> Extensions::extension_types() const
}
Server_Name_Indicator::Server_Name_Indicator(TLS_Data_Reader& reader,
- u16bit extension_size)
+ uint16_t extension_size)
{
/*
* This is used by the server to confirm that it knew the name
@@ -141,20 +141,20 @@ Server_Name_Indicator::Server_Name_Indicator(TLS_Data_Reader& reader,
if(extension_size == 0)
return;
- u16bit name_bytes = reader.get_u16bit();
+ uint16_t name_bytes = reader.get_uint16_t();
if(name_bytes + 2 != extension_size)
throw Decoding_Error("Bad encoding of SNI extension");
while(name_bytes)
{
- byte name_type = reader.get_byte();
+ uint8_t name_type = reader.get_byte();
name_bytes--;
if(name_type == 0) // DNS
{
m_sni_host_name = reader.get_string(2, 1, 65535);
- name_bytes -= static_cast<u16bit>(2 + m_sni_host_name.size());
+ name_bytes -= static_cast<uint16_t>(2 + m_sni_host_name.size());
}
else // some other unknown name type
{
@@ -164,21 +164,21 @@ Server_Name_Indicator::Server_Name_Indicator(TLS_Data_Reader& reader,
}
}
-std::vector<byte> Server_Name_Indicator::serialize() const
+std::vector<uint8_t> Server_Name_Indicator::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
size_t name_len = m_sni_host_name.size();
- buf.push_back(get_byte(0, static_cast<u16bit>(name_len+3)));
- buf.push_back(get_byte(1, static_cast<u16bit>(name_len+3)));
+ buf.push_back(get_byte(0, static_cast<uint16_t>(name_len+3)));
+ buf.push_back(get_byte(1, static_cast<uint16_t>(name_len+3)));
buf.push_back(0); // DNS
- buf.push_back(get_byte(0, static_cast<u16bit>(name_len)));
- buf.push_back(get_byte(1, static_cast<u16bit>(name_len)));
+ buf.push_back(get_byte(0, static_cast<uint16_t>(name_len)));
+ buf.push_back(get_byte(1, static_cast<uint16_t>(name_len)));
buf += std::make_pair(
- reinterpret_cast<const byte*>(m_sni_host_name.data()),
+ reinterpret_cast<const uint8_t*>(m_sni_host_name.data()),
m_sni_host_name.size());
return buf;
@@ -187,18 +187,18 @@ std::vector<byte> Server_Name_Indicator::serialize() const
#if defined(BOTAN_HAS_SRP6)
SRP_Identifier::SRP_Identifier(TLS_Data_Reader& reader,
- u16bit extension_size) : m_srp_identifier(reader.get_string(1, 1, 255))
+ uint16_t extension_size) : m_srp_identifier(reader.get_string(1, 1, 255))
{
if(m_srp_identifier.size() + 1 != extension_size)
throw Decoding_Error("Bad encoding for SRP identifier extension");
}
-std::vector<byte> SRP_Identifier::serialize() const
+std::vector<uint8_t> SRP_Identifier::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
- const byte* srp_bytes =
- reinterpret_cast<const byte*>(m_srp_identifier.data());
+ const uint8_t* srp_bytes =
+ reinterpret_cast<const uint8_t*>(m_srp_identifier.data());
append_tls_length_value(buf, srp_bytes, m_srp_identifier.size(), 1);
@@ -208,26 +208,26 @@ std::vector<byte> SRP_Identifier::serialize() const
#endif
Renegotiation_Extension::Renegotiation_Extension(TLS_Data_Reader& reader,
- u16bit extension_size) : m_reneg_data(reader.get_range<byte>(1, 0, 255))
+ uint16_t extension_size) : m_reneg_data(reader.get_range<uint8_t>(1, 0, 255))
{
if(m_reneg_data.size() + 1 != extension_size)
throw Decoding_Error("Bad encoding for secure renegotiation extn");
}
-std::vector<byte> Renegotiation_Extension::serialize() const
+std::vector<uint8_t> Renegotiation_Extension::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
append_tls_length_value(buf, m_reneg_data, 1);
return buf;
}
Application_Layer_Protocol_Notification::Application_Layer_Protocol_Notification(TLS_Data_Reader& reader,
- u16bit extension_size)
+ uint16_t extension_size)
{
if(extension_size == 0)
return; // empty extension
- const u16bit name_bytes = reader.get_u16bit();
+ const uint16_t name_bytes = reader.get_uint16_t();
size_t bytes_remaining = extension_size - 2;
@@ -256,9 +256,9 @@ const std::string& Application_Layer_Protocol_Notification::single_protocol() co
return m_protocols[0];
}
-std::vector<byte> Application_Layer_Protocol_Notification::serialize() const
+std::vector<uint8_t> Application_Layer_Protocol_Notification::serialize() const
{
- std::vector<byte> buf(2);
+ std::vector<uint8_t> buf(2);
for(auto&& p: m_protocols)
{
@@ -266,18 +266,18 @@ std::vector<byte> Application_Layer_Protocol_Notification::serialize() const
throw TLS_Exception(Alert::INTERNAL_ERROR, "ALPN name too long");
if(p != "")
append_tls_length_value(buf,
- reinterpret_cast<const byte*>(p.data()),
+ reinterpret_cast<const uint8_t*>(p.data()),
p.size(),
1);
}
- buf[0] = get_byte(0, static_cast<u16bit>(buf.size()-2));
- buf[1] = get_byte(1, static_cast<u16bit>(buf.size()-2));
+ buf[0] = get_byte(0, static_cast<uint16_t>(buf.size()-2));
+ buf[1] = get_byte(1, static_cast<uint16_t>(buf.size()-2));
return buf;
}
-std::string Supported_Elliptic_Curves::curve_id_to_name(u16bit id)
+std::string Supported_Elliptic_Curves::curve_id_to_name(uint16_t id)
{
switch(id)
{
@@ -309,7 +309,7 @@ std::string Supported_Elliptic_Curves::curve_id_to_name(u16bit id)
}
}
-u16bit Supported_Elliptic_Curves::name_to_curve_id(const std::string& name)
+uint16_t Supported_Elliptic_Curves::name_to_curve_id(const std::string& name)
{
if(name == "secp256r1")
return 23;
@@ -338,13 +338,13 @@ u16bit Supported_Elliptic_Curves::name_to_curve_id(const std::string& name)
return 0;
}
-std::vector<byte> Supported_Elliptic_Curves::serialize() const
+std::vector<uint8_t> Supported_Elliptic_Curves::serialize() const
{
- std::vector<byte> buf(2);
+ std::vector<uint8_t> buf(2);
for(size_t i = 0; i != m_curves.size(); ++i)
{
- const u16bit id = name_to_curve_id(m_curves[i]);
+ const uint16_t id = name_to_curve_id(m_curves[i]);
if(id > 0)
{
@@ -353,16 +353,16 @@ std::vector<byte> Supported_Elliptic_Curves::serialize() const
}
}
- buf[0] = get_byte(0, static_cast<u16bit>(buf.size()-2));
- buf[1] = get_byte(1, static_cast<u16bit>(buf.size()-2));
+ buf[0] = get_byte(0, static_cast<uint16_t>(buf.size()-2));
+ buf[1] = get_byte(1, static_cast<uint16_t>(buf.size()-2));
return buf;
}
Supported_Elliptic_Curves::Supported_Elliptic_Curves(TLS_Data_Reader& reader,
- u16bit extension_size)
+ uint16_t extension_size)
{
- u16bit len = reader.get_u16bit();
+ uint16_t len = reader.get_uint16_t();
if(len + 2 != extension_size)
throw Decoding_Error("Inconsistent length field in elliptic curve list");
@@ -374,7 +374,7 @@ Supported_Elliptic_Curves::Supported_Elliptic_Curves(TLS_Data_Reader& reader,
for(size_t i = 0; i != len; ++i)
{
- const u16bit id = reader.get_u16bit();
+ const uint16_t id = reader.get_uint16_t();
const std::string name = curve_id_to_name(id);
if(!name.empty())
@@ -382,30 +382,30 @@ Supported_Elliptic_Curves::Supported_Elliptic_Curves(TLS_Data_Reader& reader,
}
}
-std::vector<byte> Supported_Point_Formats::serialize() const
+std::vector<uint8_t> Supported_Point_Formats::serialize() const
{
// if this extension is sent, it MUST include uncompressed (RFC 4492, section 5.1)
if(m_prefers_compressed)
{
- return std::vector<byte>{2, ANSIX962_COMPRESSED_PRIME, UNCOMPRESSED};
+ return std::vector<uint8_t>{2, ANSIX962_COMPRESSED_PRIME, UNCOMPRESSED};
}
else
{
- return std::vector<byte>{1, UNCOMPRESSED};
+ return std::vector<uint8_t>{1, UNCOMPRESSED};
}
}
Supported_Point_Formats::Supported_Point_Formats(TLS_Data_Reader& reader,
- u16bit extension_size)
+ uint16_t extension_size)
{
- byte len = reader.get_byte();
+ uint8_t len = reader.get_byte();
if(len + 1 != extension_size)
throw Decoding_Error("Inconsistent length field in supported point formats list");
for(size_t i = 0; i != len; ++i)
{
- byte format = reader.get_byte();
+ uint8_t format = reader.get_byte();
if(format == UNCOMPRESSED)
{
@@ -424,7 +424,7 @@ Supported_Point_Formats::Supported_Point_Formats(TLS_Data_Reader& reader,
}
}
-std::string Signature_Algorithms::hash_algo_name(byte code)
+std::string Signature_Algorithms::hash_algo_name(uint8_t code)
{
switch(code)
{
@@ -446,7 +446,7 @@ std::string Signature_Algorithms::hash_algo_name(byte code)
}
}
-byte Signature_Algorithms::hash_algo_code(const std::string& name)
+uint8_t Signature_Algorithms::hash_algo_code(const std::string& name)
{
if(name == "SHA-1")
return 2;
@@ -463,7 +463,7 @@ byte Signature_Algorithms::hash_algo_code(const std::string& name)
throw Internal_Error("Unknown hash ID " + name + " for signature_algorithms");
}
-std::string Signature_Algorithms::sig_algo_name(byte code)
+std::string Signature_Algorithms::sig_algo_name(uint8_t code)
{
switch(code)
{
@@ -478,7 +478,7 @@ std::string Signature_Algorithms::sig_algo_name(byte code)
}
}
-byte Signature_Algorithms::sig_algo_code(const std::string& name)
+uint8_t Signature_Algorithms::sig_algo_code(const std::string& name)
{
if(name == "RSA")
return 1;
@@ -492,16 +492,16 @@ byte Signature_Algorithms::sig_algo_code(const std::string& name)
throw Internal_Error("Unknown sig ID " + name + " for signature_algorithms");
}
-std::vector<byte> Signature_Algorithms::serialize() const
+std::vector<uint8_t> Signature_Algorithms::serialize() const
{
- std::vector<byte> buf(2);
+ std::vector<uint8_t> buf(2);
for(size_t i = 0; i != m_supported_algos.size(); ++i)
{
try
{
- const byte hash_code = hash_algo_code(m_supported_algos[i].first);
- const byte sig_code = sig_algo_code(m_supported_algos[i].second);
+ const uint8_t hash_code = hash_algo_code(m_supported_algos[i].first);
+ const uint8_t sig_code = sig_algo_code(m_supported_algos[i].second);
buf.push_back(hash_code);
buf.push_back(sig_code);
@@ -510,8 +510,8 @@ std::vector<byte> Signature_Algorithms::serialize() const
{}
}
- buf[0] = get_byte(0, static_cast<u16bit>(buf.size()-2));
- buf[1] = get_byte(1, static_cast<u16bit>(buf.size()-2));
+ buf[0] = get_byte(0, static_cast<uint16_t>(buf.size()-2));
+ buf[1] = get_byte(1, static_cast<uint16_t>(buf.size()-2));
return buf;
}
@@ -525,17 +525,17 @@ Signature_Algorithms::Signature_Algorithms(const std::vector<std::string>& hashe
}
Signature_Algorithms::Signature_Algorithms(TLS_Data_Reader& reader,
- u16bit extension_size)
+ uint16_t extension_size)
{
- u16bit len = reader.get_u16bit();
+ uint16_t len = reader.get_uint16_t();
if(len + 2 != extension_size)
throw Decoding_Error("Bad encoding on signature algorithms extension");
while(len)
{
- const byte hash_code = reader.get_byte();
- const byte sig_code = reader.get_byte();
+ const uint8_t hash_code = reader.get_byte();
+ const uint8_t sig_code = reader.get_byte();
len -= 2;
if(sig_code == 0)
@@ -559,13 +559,13 @@ Signature_Algorithms::Signature_Algorithms(TLS_Data_Reader& reader,
}
Session_Ticket::Session_Ticket(TLS_Data_Reader& reader,
- u16bit extension_size) : m_ticket(reader.get_elem<byte, std::vector<byte>>(extension_size))
+ uint16_t extension_size) : m_ticket(reader.get_elem<uint8_t, std::vector<uint8_t>>(extension_size))
{}
SRTP_Protection_Profiles::SRTP_Protection_Profiles(TLS_Data_Reader& reader,
- u16bit extension_size) : m_pp(reader.get_range<u16bit>(2, 0, 65535))
+ uint16_t extension_size) : m_pp(reader.get_range<uint16_t>(2, 0, 65535))
{
- const std::vector<byte> mki = reader.get_range<byte>(1, 0, 255);
+ const std::vector<uint8_t> mki = reader.get_range<uint8_t>(1, 0, 255);
if(m_pp.size() * 2 + mki.size() + 3 != extension_size)
throw Decoding_Error("Bad encoding for SRTP protection extension");
@@ -574,15 +574,15 @@ SRTP_Protection_Profiles::SRTP_Protection_Profiles(TLS_Data_Reader& reader,
throw Decoding_Error("Unhandled non-empty MKI for SRTP protection extension");
}
-std::vector<byte> SRTP_Protection_Profiles::serialize() const
+std::vector<uint8_t> SRTP_Protection_Profiles::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
- const u16bit pp_len = static_cast<u16bit>(m_pp.size() * 2);
+ const uint16_t pp_len = static_cast<uint16_t>(m_pp.size() * 2);
buf.push_back(get_byte(0, pp_len));
buf.push_back(get_byte(1, pp_len));
- for(u16bit pp : m_pp)
+ for(uint16_t pp : m_pp)
{
buf.push_back(get_byte(0, pp));
buf.push_back(get_byte(1, pp));
@@ -594,32 +594,32 @@ std::vector<byte> SRTP_Protection_Profiles::serialize() const
}
Extended_Master_Secret::Extended_Master_Secret(TLS_Data_Reader&,
- u16bit extension_size)
+ uint16_t extension_size)
{
if(extension_size != 0)
throw Decoding_Error("Invalid extended_master_secret extension");
}
-std::vector<byte> Extended_Master_Secret::serialize() const
+std::vector<uint8_t> Extended_Master_Secret::serialize() const
{
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
Encrypt_then_MAC::Encrypt_then_MAC(TLS_Data_Reader&,
- u16bit extension_size)
+ uint16_t extension_size)
{
if(extension_size != 0)
throw Decoding_Error("Invalid encrypt_then_mac extension");
}
-std::vector<byte> Encrypt_then_MAC::serialize() const
+std::vector<uint8_t> Encrypt_then_MAC::serialize() const
{
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
-std::vector<byte> Certificate_Status_Request::serialize() const
+std::vector<uint8_t> Certificate_Status_Request::serialize() const
{
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
if(m_server_side)
return buf; // server reply is empty
@@ -644,11 +644,11 @@ std::vector<byte> Certificate_Status_Request::serialize() const
}
Certificate_Status_Request::Certificate_Status_Request(TLS_Data_Reader& reader,
- u16bit extension_size)
+ uint16_t extension_size)
{
if(extension_size > 0)
{
- const byte type = reader.get_byte();
+ const uint8_t type = reader.get_byte();
if(type == 1)
{
reader.discard_next(extension_size - 1); // fixme
@@ -661,7 +661,7 @@ Certificate_Status_Request::Certificate_Status_Request(TLS_Data_Reader& reader,
}
Certificate_Status_Request::Certificate_Status_Request(const std::vector<X509_DN>& ocsp_responder_ids,
- const std::vector<std::vector<byte>>& ocsp_key_ids) :
+ const std::vector<std::vector<uint8_t>>& ocsp_key_ids) :
m_ocsp_names(ocsp_responder_ids),
m_ocsp_keys(ocsp_key_ids),
m_server_side(false)
diff --git a/src/lib/tls/tls_extensions.h b/src/lib/tls/tls_extensions.h
index f766a3b1b..38d810c76 100644
--- a/src/lib/tls/tls_extensions.h
+++ b/src/lib/tls/tls_extensions.h
@@ -58,7 +58,7 @@ class Extension
/**
* @return serialized binary for the extension
*/
- virtual std::vector<byte> serialize() const = 0;
+ virtual std::vector<uint8_t> serialize() const = 0;
/**
* @return if we should encode this extension or not
@@ -83,11 +83,11 @@ class Server_Name_Indicator final : public Extension
m_sni_host_name(host_name) {}
Server_Name_Indicator(TLS_Data_Reader& reader,
- u16bit extension_size);
+ uint16_t extension_size);
std::string host_name() const { return m_sni_host_name; }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return m_sni_host_name.empty(); }
private:
@@ -110,11 +110,11 @@ class SRP_Identifier final : public Extension
m_srp_identifier(identifier) {}
SRP_Identifier(TLS_Data_Reader& reader,
- u16bit extension_size);
+ uint16_t extension_size);
std::string identifier() const { return m_srp_identifier; }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return m_srp_identifier.empty(); }
private:
@@ -135,20 +135,20 @@ class Renegotiation_Extension final : public Extension
Renegotiation_Extension() {}
- explicit Renegotiation_Extension(const std::vector<byte>& bits) :
+ explicit Renegotiation_Extension(const std::vector<uint8_t>& bits) :
m_reneg_data(bits) {}
Renegotiation_Extension(TLS_Data_Reader& reader,
- u16bit extension_size);
+ uint16_t extension_size);
- const std::vector<byte>& renegotiation_info() const
+ const std::vector<uint8_t>& renegotiation_info() const
{ return m_reneg_data; }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return false; } // always send this
private:
- std::vector<byte> m_reneg_data;
+ std::vector<uint8_t> m_reneg_data;
};
/**
@@ -178,9 +178,9 @@ class Application_Layer_Protocol_Notification final : public Extension
m_protocols(protocols) {}
Application_Layer_Protocol_Notification(TLS_Data_Reader& reader,
- u16bit extension_size);
+ uint16_t extension_size);
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return m_protocols.empty(); }
private:
@@ -201,7 +201,7 @@ class Session_Ticket final : public Extension
/**
* @return contents of the session ticket
*/
- const std::vector<byte>& contents() const { return m_ticket; }
+ const std::vector<uint8_t>& contents() const { return m_ticket; }
/**
* Create empty extension, used by both client and server
@@ -211,19 +211,19 @@ class Session_Ticket final : public Extension
/**
* Extension with ticket, used by client
*/
- explicit Session_Ticket(const std::vector<byte>& session_ticket) :
+ explicit Session_Ticket(const std::vector<uint8_t>& session_ticket) :
m_ticket(session_ticket) {}
/**
* Deserialize a session ticket
*/
- Session_Ticket(TLS_Data_Reader& reader, u16bit extension_size);
+ Session_Ticket(TLS_Data_Reader& reader, uint16_t extension_size);
- std::vector<byte> serialize() const override { return m_ticket; }
+ std::vector<uint8_t> serialize() const override { return m_ticket; }
bool empty() const override { return false; }
private:
- std::vector<byte> m_ticket;
+ std::vector<uint8_t> m_ticket;
};
/**
@@ -237,18 +237,18 @@ class Supported_Elliptic_Curves final : public Extension
Handshake_Extension_Type type() const override { return static_type(); }
- static std::string curve_id_to_name(u16bit id);
- static u16bit name_to_curve_id(const std::string& name);
+ static std::string curve_id_to_name(uint16_t id);
+ static uint16_t name_to_curve_id(const std::string& name);
const std::vector<std::string>& curves() const { return m_curves; }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
explicit Supported_Elliptic_Curves(const std::vector<std::string>& curves) :
m_curves(curves) {}
Supported_Elliptic_Curves(TLS_Data_Reader& reader,
- u16bit extension_size);
+ uint16_t extension_size);
bool empty() const override { return m_curves.empty(); }
private:
@@ -261,7 +261,7 @@ class Supported_Elliptic_Curves final : public Extension
class Supported_Point_Formats final : public Extension
{
public:
- enum ECPointFormat : byte {
+ enum ECPointFormat : uint8_t {
UNCOMPRESSED = 0,
ANSIX962_COMPRESSED_PRIME = 1,
ANSIX962_COMPRESSED_CHAR2 = 2, // don't support these curves
@@ -272,13 +272,13 @@ class Supported_Point_Formats final : public Extension
Handshake_Extension_Type type() const override { return static_type(); }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
explicit Supported_Point_Formats(bool prefer_compressed) :
m_prefers_compressed(prefer_compressed) {}
Supported_Point_Formats(TLS_Data_Reader& reader,
- u16bit extension_size);
+ uint16_t extension_size);
bool empty() const override { return false; }
@@ -299,11 +299,11 @@ class Signature_Algorithms final : public Extension
Handshake_Extension_Type type() const override { return static_type(); }
- static std::string hash_algo_name(byte code);
- static byte hash_algo_code(const std::string& name);
+ static std::string hash_algo_name(uint8_t code);
+ static uint8_t hash_algo_code(const std::string& name);
- static std::string sig_algo_name(byte code);
- static byte sig_algo_code(const std::string& name);
+ static std::string sig_algo_name(uint8_t code);
+ static uint8_t sig_algo_code(const std::string& name);
// [(hash,sig),(hash,sig),...]
const std::vector<std::pair<std::string, std::string>>&
@@ -312,7 +312,7 @@ class Signature_Algorithms final : public Extension
return m_supported_algos;
}
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return false; }
@@ -323,7 +323,7 @@ class Signature_Algorithms final : public Extension
m_supported_algos(algos) {}
Signature_Algorithms(TLS_Data_Reader& reader,
- u16bit extension_size);
+ uint16_t extension_size);
private:
std::vector<std::pair<std::string, std::string>> m_supported_algos;
};
@@ -339,19 +339,19 @@ class SRTP_Protection_Profiles final : public Extension
Handshake_Extension_Type type() const override { return static_type(); }
- const std::vector<u16bit>& profiles() const { return m_pp; }
+ const std::vector<uint16_t>& profiles() const { return m_pp; }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return m_pp.empty(); }
- explicit SRTP_Protection_Profiles(const std::vector<u16bit>& pp) : m_pp(pp) {}
+ explicit SRTP_Protection_Profiles(const std::vector<uint16_t>& pp) : m_pp(pp) {}
- explicit SRTP_Protection_Profiles(u16bit pp) : m_pp(1, pp) {}
+ explicit SRTP_Protection_Profiles(uint16_t pp) : m_pp(1, pp) {}
- SRTP_Protection_Profiles(TLS_Data_Reader& reader, u16bit extension_size);
+ SRTP_Protection_Profiles(TLS_Data_Reader& reader, uint16_t extension_size);
private:
- std::vector<u16bit> m_pp;
+ std::vector<uint16_t> m_pp;
};
/**
@@ -365,13 +365,13 @@ class Extended_Master_Secret final : public Extension
Handshake_Extension_Type type() const override { return static_type(); }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return false; }
Extended_Master_Secret() {}
- Extended_Master_Secret(TLS_Data_Reader& reader, u16bit extension_size);
+ Extended_Master_Secret(TLS_Data_Reader& reader, uint16_t extension_size);
};
/**
@@ -385,13 +385,13 @@ class Encrypt_then_MAC final : public Extension
Handshake_Extension_Type type() const override { return static_type(); }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return false; }
Encrypt_then_MAC() {}
- Encrypt_then_MAC(TLS_Data_Reader& reader, u16bit extension_size);
+ Encrypt_then_MAC(TLS_Data_Reader& reader, uint16_t extension_size);
};
/**
@@ -405,7 +405,7 @@ class Certificate_Status_Request final : public Extension
Handshake_Extension_Type type() const override { return static_type(); }
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
bool empty() const override { return false; }
@@ -414,13 +414,13 @@ class Certificate_Status_Request final : public Extension
// Client version, both lists can be empty
Certificate_Status_Request(const std::vector<X509_DN>& ocsp_responder_ids,
- const std::vector<std::vector<byte>>& ocsp_key_ids);
+ const std::vector<std::vector<uint8_t>>& ocsp_key_ids);
- Certificate_Status_Request(TLS_Data_Reader& reader, u16bit extension_size);
+ Certificate_Status_Request(TLS_Data_Reader& reader, uint16_t extension_size);
private:
std::vector<X509_DN> m_ocsp_names;
- std::vector<std::vector<byte>> m_ocsp_keys;
- std::vector<byte> m_extension_bytes;
+ std::vector<std::vector<uint8_t>> m_ocsp_keys;
+ std::vector<uint8_t> m_extension_bytes;
bool m_server_side;
};
@@ -455,7 +455,7 @@ class BOTAN_DLL Extensions
m_extensions[extn->type()].reset(extn);
}
- std::vector<byte> serialize() const;
+ std::vector<uint8_t> serialize() const;
void deserialize(TLS_Data_Reader& reader);
diff --git a/src/lib/tls/tls_handshake_hash.cpp b/src/lib/tls/tls_handshake_hash.cpp
index 7bac87bc8..a3e90ebc5 100644
--- a/src/lib/tls/tls_handshake_hash.cpp
+++ b/src/lib/tls/tls_handshake_hash.cpp
@@ -16,7 +16,7 @@ namespace TLS {
/**
* Return a TLS Handshake Hash
*/
-secure_vector<byte> Handshake_Hash::final(Protocol_Version version,
+secure_vector<uint8_t> Handshake_Hash::final(Protocol_Version version,
const std::string& mac_algo) const
{
std::string hash_algo = mac_algo;
diff --git a/src/lib/tls/tls_handshake_hash.h b/src/lib/tls/tls_handshake_hash.h
index d0f5c882f..c0c266f9e 100644
--- a/src/lib/tls/tls_handshake_hash.h
+++ b/src/lib/tls/tls_handshake_hash.h
@@ -22,20 +22,20 @@ namespace TLS {
class Handshake_Hash
{
public:
- void update(const byte in[], size_t length)
+ void update(const uint8_t in[], size_t length)
{ m_data += std::make_pair(in, length); }
- void update(const std::vector<byte>& in)
+ void update(const std::vector<uint8_t>& in)
{ m_data += in; }
- secure_vector<byte> final(Protocol_Version version,
+ secure_vector<uint8_t> final(Protocol_Version version,
const std::string& mac_algo) const;
- const std::vector<byte>& get_contents() const { return m_data; }
+ const std::vector<uint8_t>& get_contents() const { return m_data; }
void reset() { m_data.clear(); }
private:
- std::vector<byte> m_data;
+ std::vector<uint8_t> m_data;
};
}
diff --git a/src/lib/tls/tls_handshake_io.cpp b/src/lib/tls/tls_handshake_io.cpp
index ed7b1487d..159e7289a 100644
--- a/src/lib/tls/tls_handshake_io.cpp
+++ b/src/lib/tls/tls_handshake_io.cpp
@@ -18,22 +18,22 @@ namespace TLS {
namespace {
-inline size_t load_be24(const byte q[3])
+inline size_t load_be24(const uint8_t q[3])
{
- return make_u32bit(0,
+ return make_uint32(0,
q[0],
q[1],
q[2]);
}
-void store_be24(byte out[3], size_t val)
+void store_be24(uint8_t out[3], size_t val)
{
- out[0] = get_byte(1, static_cast<u32bit>(val));
- out[1] = get_byte(2, static_cast<u32bit>(val));
- out[2] = get_byte(3, static_cast<u32bit>(val));
+ out[0] = get_byte(1, static_cast<uint32_t>(val));
+ out[1] = get_byte(2, static_cast<uint32_t>(val));
+ out[2] = get_byte(3, static_cast<uint32_t>(val));
}
-u64bit steady_clock_ms()
+uint64_t steady_clock_ms()
{
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch()).count();
@@ -58,8 +58,8 @@ Protocol_Version Stream_Handshake_IO::initial_record_version() const
return Protocol_Version::TLS_V10;
}
-void Stream_Handshake_IO::add_record(const std::vector<byte>& record,
- Record_Type record_type, u64bit)
+void Stream_Handshake_IO::add_record(const std::vector<uint8_t>& record,
+ Record_Type record_type, uint64_t)
{
if(record_type == HANDSHAKE)
{
@@ -71,25 +71,25 @@ void Stream_Handshake_IO::add_record(const std::vector<byte>& record,
throw Decoding_Error("Invalid ChangeCipherSpec");
// Pretend it's a regular handshake message of zero length
- const byte ccs_hs[] = { HANDSHAKE_CCS, 0, 0, 0 };
+ const uint8_t ccs_hs[] = { HANDSHAKE_CCS, 0, 0, 0 };
m_queue.insert(m_queue.end(), ccs_hs, ccs_hs + sizeof(ccs_hs));
}
else
throw Decoding_Error("Unknown message type " + std::to_string(record_type) + " in handshake processing");
}
-std::pair<Handshake_Type, std::vector<byte>>
+std::pair<Handshake_Type, std::vector<uint8_t>>
Stream_Handshake_IO::get_next_record(bool)
{
if(m_queue.size() >= 4)
{
- const size_t length = make_u32bit(0, m_queue[1], m_queue[2], m_queue[3]);
+ const size_t length = make_uint32(0, m_queue[1], m_queue[2], m_queue[3]);
if(m_queue.size() >= length + 4)
{
Handshake_Type type = static_cast<Handshake_Type>(m_queue[0]);
- std::vector<byte> contents(m_queue.begin() + 4,
+ std::vector<uint8_t> contents(m_queue.begin() + 4,
m_queue.begin() + 4 + length);
m_queue.erase(m_queue.begin(), m_queue.begin() + 4 + length);
@@ -98,14 +98,14 @@ Stream_Handshake_IO::get_next_record(bool)
}
}
- return std::make_pair(HANDSHAKE_NONE, std::vector<byte>());
+ return std::make_pair(HANDSHAKE_NONE, std::vector<uint8_t>());
}
-std::vector<byte>
-Stream_Handshake_IO::format(const std::vector<byte>& msg,
+std::vector<uint8_t>
+Stream_Handshake_IO::format(const std::vector<uint8_t>& msg,
Handshake_Type type) const
{
- std::vector<byte> send_buf(4 + msg.size());
+ std::vector<uint8_t> send_buf(4 + msg.size());
const size_t buf_size = msg.size();
@@ -121,17 +121,17 @@ Stream_Handshake_IO::format(const std::vector<byte>& msg,
return send_buf;
}
-std::vector<byte> Stream_Handshake_IO::send(const Handshake_Message& msg)
+std::vector<uint8_t> Stream_Handshake_IO::send(const Handshake_Message& msg)
{
- const std::vector<byte> msg_bits = msg.serialize();
+ const std::vector<uint8_t> msg_bits = msg.serialize();
if(msg.type() == HANDSHAKE_CCS)
{
m_send_hs(CHANGE_CIPHER_SPEC, msg_bits);
- return std::vector<byte>(); // not included in handshake hashes
+ return std::vector<uint8_t>(); // not included in handshake hashes
}
- const std::vector<byte> buf = format(msg_bits, msg.type());
+ const std::vector<uint8_t> buf = format(msg_bits, msg.type());
m_send_hs(HANDSHAKE, buf);
return buf;
}
@@ -149,11 +149,11 @@ void Datagram_Handshake_IO::retransmit_last_flight()
void Datagram_Handshake_IO::retransmit_flight(size_t flight_idx)
{
- const std::vector<u16bit>& flight = m_flights.at(flight_idx);
+ const std::vector<uint16_t>& flight = m_flights.at(flight_idx);
BOTAN_ASSERT(flight.size() > 0, "Nonempty flight to retransmit");
- u16bit epoch = m_flight_data[flight[0]].epoch;
+ uint16_t epoch = m_flight_data[flight[0]].epoch;
for(auto msg_seq : flight)
{
@@ -162,7 +162,7 @@ void Datagram_Handshake_IO::retransmit_flight(size_t flight_idx)
if(msg.epoch != epoch)
{
// Epoch gap: insert the CCS
- std::vector<byte> ccs(1, 1);
+ std::vector<uint8_t> ccs(1, 1);
m_send_hs(epoch, CHANGE_CIPHER_SPEC, ccs);
}
@@ -182,7 +182,7 @@ bool Datagram_Handshake_IO::timeout_check()
return false;
}
- const u64bit ms_since_write = steady_clock_ms() - m_last_write;
+ const uint64_t ms_since_write = steady_clock_ms() - m_last_write;
if(ms_since_write < m_next_timeout)
return false;
@@ -193,11 +193,11 @@ bool Datagram_Handshake_IO::timeout_check()
return true;
}
-void Datagram_Handshake_IO::add_record(const std::vector<byte>& record,
+void Datagram_Handshake_IO::add_record(const std::vector<uint8_t>& record,
Record_Type record_type,
- u64bit record_sequence)
+ uint64_t record_sequence)
{
- const u16bit epoch = static_cast<u16bit>(record_sequence >> 48);
+ const uint16_t epoch = static_cast<uint16_t>(record_sequence >> 48);
if(record_type == CHANGE_CIPHER_SPEC)
{
@@ -208,7 +208,7 @@ void Datagram_Handshake_IO::add_record(const std::vector<byte>& record,
const size_t DTLS_HANDSHAKE_HEADER_LEN = 12;
- const byte* record_bits = record.data();
+ const uint8_t* record_bits = record.data();
size_t record_size = record.size();
while(record_size)
@@ -216,9 +216,9 @@ void Datagram_Handshake_IO::add_record(const std::vector<byte>& record,
if(record_size < DTLS_HANDSHAKE_HEADER_LEN)
return; // completely bogus? at least degenerate/weird
- const byte msg_type = record_bits[0];
+ const uint8_t msg_type = record_bits[0];
const size_t msg_len = load_be24(&record_bits[1]);
- const u16bit message_seq = load_be<u16bit>(&record_bits[4], 0);
+ const uint16_t message_seq = load_be<uint16_t>(&record_bits[4], 0);
const size_t fragment_offset = load_be24(&record_bits[6]);
const size_t fragment_length = load_be24(&record_bits[9]);
@@ -246,29 +246,29 @@ void Datagram_Handshake_IO::add_record(const std::vector<byte>& record,
}
}
-std::pair<Handshake_Type, std::vector<byte>>
+std::pair<Handshake_Type, std::vector<uint8_t>>
Datagram_Handshake_IO::get_next_record(bool expecting_ccs)
{
// Expecting a message means the last flight is concluded
if(!m_flights.rbegin()->empty())
- m_flights.push_back(std::vector<u16bit>());
+ m_flights.push_back(std::vector<uint16_t>());
if(expecting_ccs)
{
if(!m_messages.empty())
{
- const u16bit current_epoch = m_messages.begin()->second.epoch();
+ const uint16_t current_epoch = m_messages.begin()->second.epoch();
if(m_ccs_epochs.count(current_epoch))
- return std::make_pair(HANDSHAKE_CCS, std::vector<byte>());
+ return std::make_pair(HANDSHAKE_CCS, std::vector<uint8_t>());
}
- return std::make_pair(HANDSHAKE_NONE, std::vector<byte>());
+ return std::make_pair(HANDSHAKE_NONE, std::vector<uint8_t>());
}
auto i = m_messages.find(m_in_message_seq);
if(i == m_messages.end() || !i->second.complete())
- return std::make_pair(HANDSHAKE_NONE, std::vector<byte>());
+ return std::make_pair(HANDSHAKE_NONE, std::vector<uint8_t>());
m_in_message_seq += 1;
@@ -276,11 +276,11 @@ Datagram_Handshake_IO::get_next_record(bool expecting_ccs)
}
void Datagram_Handshake_IO::Handshake_Reassembly::add_fragment(
- const byte fragment[],
+ const uint8_t fragment[],
size_t fragment_length,
size_t fragment_offset,
- u16bit epoch,
- byte msg_type,
+ uint16_t epoch,
+ uint8_t msg_type,
size_t msg_length)
{
if(complete())
@@ -335,7 +335,7 @@ bool Datagram_Handshake_IO::Handshake_Reassembly::complete() const
return (m_msg_type != HANDSHAKE_NONE && m_message.size() == m_msg_length);
}
-std::pair<Handshake_Type, std::vector<byte>>
+std::pair<Handshake_Type, std::vector<uint8_t>>
Datagram_Handshake_IO::Handshake_Reassembly::message() const
{
if(!complete())
@@ -344,15 +344,15 @@ Datagram_Handshake_IO::Handshake_Reassembly::message() const
return std::make_pair(static_cast<Handshake_Type>(m_msg_type), m_message);
}
-std::vector<byte>
-Datagram_Handshake_IO::format_fragment(const byte fragment[],
+std::vector<uint8_t>
+Datagram_Handshake_IO::format_fragment(const uint8_t fragment[],
size_t frag_len,
- u16bit frag_offset,
- u16bit msg_len,
+ uint16_t frag_offset,
+ uint16_t msg_len,
Handshake_Type type,
- u16bit msg_sequence) const
+ uint16_t msg_sequence) const
{
- std::vector<byte> send_buf(12 + frag_len);
+ std::vector<uint8_t> send_buf(12 + frag_len);
send_buf[0] = type;
@@ -371,33 +371,33 @@ Datagram_Handshake_IO::format_fragment(const byte fragment[],
return send_buf;
}
-std::vector<byte>
-Datagram_Handshake_IO::format_w_seq(const std::vector<byte>& msg,
+std::vector<uint8_t>
+Datagram_Handshake_IO::format_w_seq(const std::vector<uint8_t>& msg,
Handshake_Type type,
- u16bit msg_sequence) const
+ uint16_t msg_sequence) const
{
- return format_fragment(msg.data(), msg.size(), 0, static_cast<u16bit>(msg.size()), type, msg_sequence);
+ return format_fragment(msg.data(), msg.size(), 0, static_cast<uint16_t>(msg.size()), type, msg_sequence);
}
-std::vector<byte>
-Datagram_Handshake_IO::format(const std::vector<byte>& msg,
+std::vector<uint8_t>
+Datagram_Handshake_IO::format(const std::vector<uint8_t>& msg,
Handshake_Type type) const
{
return format_w_seq(msg, type, m_in_message_seq - 1);
}
-std::vector<byte>
+std::vector<uint8_t>
Datagram_Handshake_IO::send(const Handshake_Message& msg)
{
- const std::vector<byte> msg_bits = msg.serialize();
- const u16bit epoch = m_seqs.current_write_epoch();
+ const std::vector<uint8_t> msg_bits = msg.serialize();
+ const uint16_t epoch = m_seqs.current_write_epoch();
const Handshake_Type msg_type = msg.type();
if(msg_type == HANDSHAKE_CCS)
{
m_send_hs(epoch, CHANGE_CIPHER_SPEC, msg_bits);
- return std::vector<byte>(); // not included in handshake hashes
+ return std::vector<uint8_t>(); // not included in handshake hashes
}
// Note: not saving CCS, instead we know it was there due to change in epoch
@@ -411,12 +411,12 @@ Datagram_Handshake_IO::send(const Handshake_Message& msg)
return send_message(m_out_message_seq - 1, epoch, msg_type, msg_bits);
}
-std::vector<byte> Datagram_Handshake_IO::send_message(u16bit msg_seq,
- u16bit epoch,
+std::vector<uint8_t> Datagram_Handshake_IO::send_message(uint16_t msg_seq,
+ uint16_t epoch,
Handshake_Type msg_type,
- const std::vector<byte>& msg_bits)
+ const std::vector<uint8_t>& msg_bits)
{
- const std::vector<byte> no_fragment =
+ const std::vector<uint8_t> no_fragment =
format_w_seq(msg_bits, msg_type, msg_seq);
if(no_fragment.size() + DTLS_HEADER_SIZE <= m_mtu)
@@ -441,8 +441,8 @@ std::vector<byte> Datagram_Handshake_IO::send_message(u16bit msg_seq,
HANDSHAKE,
format_fragment(&msg_bits[frag_offset],
frag_len,
- static_cast<u16bit>(frag_offset),
- static_cast<u16bit>(msg_bits.size()),
+ static_cast<uint16_t>(frag_offset),
+ static_cast<uint16_t>(msg_bits.size()),
msg_type,
msg_seq));
diff --git a/src/lib/tls/tls_handshake_io.h b/src/lib/tls/tls_handshake_io.h
index 601ac41d9..a9453abcc 100644
--- a/src/lib/tls/tls_handshake_io.h
+++ b/src/lib/tls/tls_handshake_io.h
@@ -32,22 +32,22 @@ class Handshake_IO
public:
virtual Protocol_Version initial_record_version() const = 0;
- virtual std::vector<byte> send(const Handshake_Message& msg) = 0;
+ virtual std::vector<uint8_t> send(const Handshake_Message& msg) = 0;
virtual bool timeout_check() = 0;
- virtual std::vector<byte> format(
- const std::vector<byte>& handshake_msg,
+ virtual std::vector<uint8_t> format(
+ const std::vector<uint8_t>& handshake_msg,
Handshake_Type handshake_type) const = 0;
- virtual void add_record(const std::vector<byte>& record,
+ virtual void add_record(const std::vector<uint8_t>& record,
Record_Type type,
- u64bit sequence_number) = 0;
+ uint64_t sequence_number) = 0;
/**
* Returns (HANDSHAKE_NONE, std::vector<>()) if no message currently available
*/
- virtual std::pair<Handshake_Type, std::vector<byte>>
+ virtual std::pair<Handshake_Type, std::vector<uint8_t>>
get_next_record(bool expecting_ccs) = 0;
Handshake_IO() {}
@@ -65,7 +65,7 @@ class Handshake_IO
class Stream_Handshake_IO final : public Handshake_IO
{
public:
- typedef std::function<void (byte, const std::vector<byte>&)> writer_fn;
+ typedef std::function<void (uint8_t, const std::vector<uint8_t>&)> writer_fn;
explicit Stream_Handshake_IO(writer_fn writer) : m_send_hs(writer) {}
@@ -73,20 +73,20 @@ class Stream_Handshake_IO final : public Handshake_IO
bool timeout_check() override { return false; }
- std::vector<byte> send(const Handshake_Message& msg) override;
+ std::vector<uint8_t> send(const Handshake_Message& msg) override;
- std::vector<byte> format(
- const std::vector<byte>& handshake_msg,
+ std::vector<uint8_t> format(
+ const std::vector<uint8_t>& handshake_msg,
Handshake_Type handshake_type) const override;
- void add_record(const std::vector<byte>& record,
+ void add_record(const std::vector<uint8_t>& record,
Record_Type type,
- u64bit sequence_number) override;
+ uint64_t sequence_number) override;
- std::pair<Handshake_Type, std::vector<byte>>
+ std::pair<Handshake_Type, std::vector<uint8_t>>
get_next_record(bool expecting_ccs) override;
private:
- std::deque<byte> m_queue;
+ std::deque<uint8_t> m_queue;
writer_fn m_send_hs;
};
@@ -96,11 +96,11 @@ class Stream_Handshake_IO final : public Handshake_IO
class Datagram_Handshake_IO final : public Handshake_IO
{
public:
- typedef std::function<void (u16bit, byte, const std::vector<byte>&)> writer_fn;
+ typedef std::function<void (uint16_t, uint8_t, const std::vector<uint8_t>&)> writer_fn;
Datagram_Handshake_IO(writer_fn writer,
class Connection_Sequence_Numbers& seq,
- u16bit mtu, u64bit initial_timeout_ms, u64bit max_timeout_ms) :
+ uint16_t mtu, uint64_t initial_timeout_ms, uint64_t max_timeout_ms) :
m_seqs(seq),
m_flights(1),
m_initial_timeout(initial_timeout_ms),
@@ -113,96 +113,96 @@ class Datagram_Handshake_IO final : public Handshake_IO
bool timeout_check() override;
- std::vector<byte> send(const Handshake_Message& msg) override;
+ std::vector<uint8_t> send(const Handshake_Message& msg) override;
- std::vector<byte> format(
- const std::vector<byte>& handshake_msg,
+ std::vector<uint8_t> format(
+ const std::vector<uint8_t>& handshake_msg,
Handshake_Type handshake_type) const override;
- void add_record(const std::vector<byte>& record,
+ void add_record(const std::vector<uint8_t>& record,
Record_Type type,
- u64bit sequence_number) override;
+ uint64_t sequence_number) override;
- std::pair<Handshake_Type, std::vector<byte>>
+ std::pair<Handshake_Type, std::vector<uint8_t>>
get_next_record(bool expecting_ccs) override;
private:
void retransmit_flight(size_t flight);
void retransmit_last_flight();
- std::vector<byte> format_fragment(
- const byte fragment[],
+ std::vector<uint8_t> format_fragment(
+ const uint8_t fragment[],
size_t fragment_len,
- u16bit frag_offset,
- u16bit msg_len,
+ uint16_t frag_offset,
+ uint16_t msg_len,
Handshake_Type type,
- u16bit msg_sequence) const;
+ uint16_t msg_sequence) const;
- std::vector<byte> format_w_seq(
- const std::vector<byte>& handshake_msg,
+ std::vector<uint8_t> format_w_seq(
+ const std::vector<uint8_t>& handshake_msg,
Handshake_Type handshake_type,
- u16bit msg_sequence) const;
+ uint16_t msg_sequence) const;
- std::vector<byte> send_message(u16bit msg_seq, u16bit epoch,
+ std::vector<uint8_t> send_message(uint16_t msg_seq, uint16_t epoch,
Handshake_Type msg_type,
- const std::vector<byte>& msg);
+ const std::vector<uint8_t>& msg);
class Handshake_Reassembly
{
public:
- void add_fragment(const byte fragment[],
+ void add_fragment(const uint8_t fragment[],
size_t fragment_length,
size_t fragment_offset,
- u16bit epoch,
- byte msg_type,
+ uint16_t epoch,
+ uint8_t msg_type,
size_t msg_length);
bool complete() const;
- u16bit epoch() const { return m_epoch; }
+ uint16_t epoch() const { return m_epoch; }
- std::pair<Handshake_Type, std::vector<byte>> message() const;
+ std::pair<Handshake_Type, std::vector<uint8_t>> message() const;
private:
- byte m_msg_type = HANDSHAKE_NONE;
+ uint8_t m_msg_type = HANDSHAKE_NONE;
size_t m_msg_length = 0;
- u16bit m_epoch = 0;
+ uint16_t m_epoch = 0;
// vector<bool> m_seen;
- // vector<byte> m_fragments
- std::map<size_t, byte> m_fragments;
- std::vector<byte> m_message;
+ // vector<uint8_t> m_fragments
+ std::map<size_t, uint8_t> m_fragments;
+ std::vector<uint8_t> m_message;
};
struct Message_Info
{
- Message_Info(u16bit e, Handshake_Type mt, const std::vector<byte>& msg) :
+ Message_Info(uint16_t e, Handshake_Type mt, const std::vector<uint8_t>& msg) :
epoch(e), msg_type(mt), msg_bits(msg) {}
Message_Info(const Message_Info& other) = default;
Message_Info() : epoch(0xFFFF), msg_type(HANDSHAKE_NONE) {}
- u16bit epoch;
+ uint16_t epoch;
Handshake_Type msg_type;
- std::vector<byte> msg_bits;
+ std::vector<uint8_t> msg_bits;
};
class Connection_Sequence_Numbers& m_seqs;
- std::map<u16bit, Handshake_Reassembly> m_messages;
- std::set<u16bit> m_ccs_epochs;
- std::vector<std::vector<u16bit>> m_flights;
- std::map<u16bit, Message_Info> m_flight_data;
+ std::map<uint16_t, Handshake_Reassembly> m_messages;
+ std::set<uint16_t> m_ccs_epochs;
+ std::vector<std::vector<uint16_t>> m_flights;
+ std::map<uint16_t, Message_Info> m_flight_data;
- u64bit m_initial_timeout = 0;
- u64bit m_max_timeout = 0;
+ uint64_t m_initial_timeout = 0;
+ uint64_t m_max_timeout = 0;
- u64bit m_last_write = 0;
- u64bit m_next_timeout = 0;
+ uint64_t m_last_write = 0;
+ uint64_t m_next_timeout = 0;
- u16bit m_in_message_seq = 0;
- u16bit m_out_message_seq = 0;
+ uint16_t m_in_message_seq = 0;
+ uint16_t m_out_message_seq = 0;
writer_fn m_send_hs;
- u16bit m_mtu;
+ uint16_t m_mtu;
};
}
diff --git a/src/lib/tls/tls_handshake_msg.h b/src/lib/tls/tls_handshake_msg.h
index c1d3bfdc7..b4279fe34 100644
--- a/src/lib/tls/tls_handshake_msg.h
+++ b/src/lib/tls/tls_handshake_msg.h
@@ -39,7 +39,7 @@ class BOTAN_DLL Handshake_Message
/**
* @return DER representation of this message
*/
- virtual std::vector<byte> serialize() const = 0;
+ virtual std::vector<uint8_t> serialize() const = 0;
virtual ~Handshake_Message() {}
};
diff --git a/src/lib/tls/tls_handshake_state.cpp b/src/lib/tls/tls_handshake_state.cpp
index 039d5b326..461f60cc4 100644
--- a/src/lib/tls/tls_handshake_state.cpp
+++ b/src/lib/tls/tls_handshake_state.cpp
@@ -77,7 +77,7 @@ const char* handshake_type_to_string(Handshake_Type type)
namespace {
-u32bit bitmask_for_handshake_type(Handshake_Type type)
+uint32_t bitmask_for_handshake_type(Handshake_Type type)
{
switch(type)
{
@@ -134,7 +134,7 @@ u32bit bitmask_for_handshake_type(Handshake_Type type)
throw Internal_Error("Unknown handshake type " + std::to_string(type));
}
-std::string handshake_mask_to_string(u32bit mask)
+std::string handshake_mask_to_string(uint32_t mask)
{
const Handshake_Type types[] = {
HELLO_VERIFY_REQUEST,
@@ -288,14 +288,14 @@ void Handshake_State::compute_session_keys()
m_session_keys = Session_Keys(this, client_kex()->pre_master_secret(), false);
}
-void Handshake_State::compute_session_keys(const secure_vector<byte>& resume_master_secret)
+void Handshake_State::compute_session_keys(const secure_vector<uint8_t>& resume_master_secret)
{
m_session_keys = Session_Keys(this, resume_master_secret, true);
}
void Handshake_State::confirm_transition_to(Handshake_Type handshake_msg)
{
- const u32bit mask = bitmask_for_handshake_type(handshake_msg);
+ const uint32_t mask = bitmask_for_handshake_type(handshake_msg);
m_hand_received_mask |= mask;
@@ -321,12 +321,12 @@ void Handshake_State::set_expected_next(Handshake_Type handshake_msg)
bool Handshake_State::received_handshake_msg(Handshake_Type handshake_msg) const
{
- const u32bit mask = bitmask_for_handshake_type(handshake_msg);
+ const uint32_t mask = bitmask_for_handshake_type(handshake_msg);
return (m_hand_received_mask & mask) != 0;
}
-std::pair<Handshake_Type, std::vector<byte>>
+std::pair<Handshake_Type, std::vector<uint8_t>>
Handshake_State::get_next_handshake_msg()
{
const bool expecting_ccs =
@@ -347,7 +347,7 @@ std::string Handshake_State::srp_identifier() const
}
-std::vector<byte> Handshake_State::session_ticket() const
+std::vector<uint8_t> Handshake_State::session_ticket() const
{
if(new_session_ticket() && !new_session_ticket()->ticket().empty())
return new_session_ticket()->ticket();
diff --git a/src/lib/tls/tls_handshake_state.h b/src/lib/tls/tls_handshake_state.h
index bdfc0d5d5..889f0d101 100644
--- a/src/lib/tls/tls_handshake_state.h
+++ b/src/lib/tls/tls_handshake_state.h
@@ -74,10 +74,10 @@ class Handshake_State
*/
void set_expected_next(Handshake_Type msg_type);
- std::pair<Handshake_Type, std::vector<byte>>
+ std::pair<Handshake_Type, std::vector<uint8_t>>
get_next_handshake_msg();
- std::vector<byte> session_ticket() const;
+ std::vector<uint8_t> session_ticket() const;
std::pair<std::string, Signature_Format>
parse_sig_format(const Public_Key& key,
@@ -162,7 +162,7 @@ class Handshake_State
void compute_session_keys();
- void compute_session_keys(const secure_vector<byte>& resume_master_secret);
+ void compute_session_keys(const secure_vector<uint8_t>& resume_master_secret);
Handshake_Hash& hash() { return m_handshake_hash; }
@@ -175,8 +175,8 @@ class Handshake_State
std::unique_ptr<Handshake_IO> m_handshake_io;
- u32bit m_hand_expecting_mask = 0;
- u32bit m_hand_received_mask = 0;
+ uint32_t m_hand_expecting_mask = 0;
+ uint32_t m_hand_received_mask = 0;
Protocol_Version m_version;
Ciphersuite m_ciphersuite;
Session_Keys m_session_keys;
diff --git a/src/lib/tls/tls_messages.h b/src/lib/tls/tls_messages.h
index 82fa22320..30a037e8e 100644
--- a/src/lib/tls/tls_messages.h
+++ b/src/lib/tls/tls_messages.h
@@ -38,7 +38,7 @@ namespace TLS {
class Session;
class Handshake_IO;
-std::vector<byte> make_hello_random(RandomNumberGenerator& rng,
+std::vector<uint8_t> make_hello_random(RandomNumberGenerator& rng,
const Policy& policy);
/**
@@ -47,18 +47,18 @@ std::vector<byte> make_hello_random(RandomNumberGenerator& rng,
class BOTAN_DLL Hello_Verify_Request final : public Handshake_Message
{
public:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
Handshake_Type type() const override { return HELLO_VERIFY_REQUEST; }
- std::vector<byte> cookie() const { return m_cookie; }
+ std::vector<uint8_t> cookie() const { return m_cookie; }
- explicit Hello_Verify_Request(const std::vector<byte>& buf);
+ explicit Hello_Verify_Request(const std::vector<uint8_t>& buf);
- Hello_Verify_Request(const std::vector<byte>& client_hello_bits,
+ Hello_Verify_Request(const std::vector<uint8_t>& client_hello_bits,
const std::string& client_identity,
const SymmetricKey& secret_key);
private:
- std::vector<byte> m_cookie;
+ std::vector<uint8_t> m_cookie;
};
/**
@@ -91,15 +91,15 @@ class BOTAN_DLL Client_Hello final : public Handshake_Message
Protocol_Version version() const { return m_version; }
- const std::vector<byte>& random() const { return m_random; }
+ const std::vector<uint8_t>& random() const { return m_random; }
- const std::vector<byte>& session_id() const { return m_session_id; }
+ const std::vector<uint8_t>& session_id() const { return m_session_id; }
- std::vector<u16bit> ciphersuites() const { return m_suites; }
+ std::vector<uint16_t> ciphersuites() const { return m_suites; }
- std::vector<byte> compression_methods() const { return m_comp_methods; }
+ std::vector<uint8_t> compression_methods() const { return m_comp_methods; }
- bool offered_suite(u16bit ciphersuite) const;
+ bool offered_suite(uint16_t ciphersuite) const;
bool sent_fallback_scsv() const;
@@ -155,11 +155,11 @@ class BOTAN_DLL Client_Hello final : public Handshake_Message
return m_extensions.has<Renegotiation_Extension>();
}
- std::vector<byte> renegotiation_info() const
+ std::vector<uint8_t> renegotiation_info() const
{
if(Renegotiation_Extension* reneg = m_extensions.get<Renegotiation_Extension>())
return reneg->renegotiation_info();
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
bool supports_session_ticket() const
@@ -167,11 +167,11 @@ class BOTAN_DLL Client_Hello final : public Handshake_Message
return m_extensions.has<Session_Ticket>();
}
- std::vector<byte> session_ticket() const
+ std::vector<uint8_t> session_ticket() const
{
if(Session_Ticket* ticket = m_extensions.get<Session_Ticket>())
return ticket->contents();
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
bool supports_alpn() const
@@ -206,11 +206,11 @@ class BOTAN_DLL Client_Hello final : public Handshake_Message
return std::vector<std::string>();
}
- std::vector<u16bit> srtp_profiles() const
+ std::vector<uint16_t> srtp_profiles() const
{
if(SRTP_Protection_Profiles* srtp = m_extensions.get<SRTP_Protection_Profiles>())
return srtp->profiles();
- return std::vector<u16bit>();
+ return std::vector<uint16_t>();
}
void update_hello_cookie(const Hello_Verify_Request& hello_verify);
@@ -222,7 +222,7 @@ class BOTAN_DLL Client_Hello final : public Handshake_Message
Handshake_Hash& hash,
const Policy& policy,
RandomNumberGenerator& rng,
- const std::vector<byte>& reneg_info,
+ const std::vector<uint8_t>& reneg_info,
const Client_Hello::Settings& client_settings,
const std::vector<std::string>& next_protocols);
@@ -230,21 +230,21 @@ class BOTAN_DLL Client_Hello final : public Handshake_Message
Handshake_Hash& hash,
const Policy& policy,
RandomNumberGenerator& rng,
- const std::vector<byte>& reneg_info,
+ const std::vector<uint8_t>& reneg_info,
const Session& resumed_session,
const std::vector<std::string>& next_protocols);
- explicit Client_Hello(const std::vector<byte>& buf);
+ explicit Client_Hello(const std::vector<uint8_t>& buf);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
Protocol_Version m_version;
- std::vector<byte> m_session_id;
- std::vector<byte> m_random;
- std::vector<u16bit> m_suites;
- std::vector<byte> m_comp_methods;
- std::vector<byte> m_hello_cookie; // DTLS only
+ std::vector<uint8_t> m_session_id;
+ std::vector<uint8_t> m_random;
+ std::vector<uint16_t> m_suites;
+ std::vector<uint8_t> m_comp_methods;
+ std::vector<uint8_t> m_hello_cookie; // DTLS only
Extensions m_extensions;
};
@@ -258,10 +258,10 @@ class BOTAN_DLL Server_Hello final : public Handshake_Message
class Settings
{
public:
- Settings(const std::vector<byte> new_session_id,
+ Settings(const std::vector<uint8_t> new_session_id,
Protocol_Version new_session_version,
- u16bit ciphersuite,
- byte compression,
+ uint16_t ciphersuite,
+ uint8_t compression,
bool offer_session_ticket)
: m_new_session_id(new_session_id),
m_new_session_version(new_session_version),
@@ -269,17 +269,17 @@ class BOTAN_DLL Server_Hello final : public Handshake_Message
m_compression(compression),
m_offer_session_ticket(offer_session_ticket) {};
- const std::vector<byte>& session_id() const { return m_new_session_id; };
+ const std::vector<uint8_t>& session_id() const { return m_new_session_id; };
Protocol_Version protocol_version() const { return m_new_session_version; };
- u16bit ciphersuite() const { return m_ciphersuite; };
- byte compression() const { return m_compression; }
+ uint16_t ciphersuite() const { return m_ciphersuite; };
+ uint8_t compression() const { return m_compression; }
bool offer_session_ticket() const { return m_offer_session_ticket; }
private:
- const std::vector<byte> m_new_session_id;
+ const std::vector<uint8_t> m_new_session_id;
Protocol_Version m_new_session_version;
- u16bit m_ciphersuite;
- byte m_compression;
+ uint16_t m_ciphersuite;
+ uint8_t m_compression;
bool m_offer_session_ticket;
};
@@ -288,24 +288,24 @@ class BOTAN_DLL Server_Hello final : public Handshake_Message
Protocol_Version version() const { return m_version; }
- const std::vector<byte>& random() const { return m_random; }
+ const std::vector<uint8_t>& random() const { return m_random; }
- const std::vector<byte>& session_id() const { return m_session_id; }
+ const std::vector<uint8_t>& session_id() const { return m_session_id; }
- u16bit ciphersuite() const { return m_ciphersuite; }
+ uint16_t ciphersuite() const { return m_ciphersuite; }
- byte compression_method() const { return m_comp_method; }
+ uint8_t compression_method() const { return m_comp_method; }
bool secure_renegotiation() const
{
return m_extensions.has<Renegotiation_Extension>();
}
- std::vector<byte> renegotiation_info() const
+ std::vector<uint8_t> renegotiation_info() const
{
if(Renegotiation_Extension* reneg = m_extensions.get<Renegotiation_Extension>())
return reneg->renegotiation_info();
- return std::vector<byte>();
+ return std::vector<uint8_t>();
}
bool supports_extended_master_secret() const
@@ -328,7 +328,7 @@ class BOTAN_DLL Server_Hello final : public Handshake_Message
return m_extensions.has<Session_Ticket>();
}
- u16bit srtp_profile() const
+ uint16_t srtp_profile() const
{
if(auto srtp = m_extensions.get<SRTP_Protection_Profiles>())
{
@@ -364,7 +364,7 @@ class BOTAN_DLL Server_Hello final : public Handshake_Message
Handshake_Hash& hash,
const Policy& policy,
RandomNumberGenerator& rng,
- const std::vector<byte>& secure_reneg_info,
+ const std::vector<uint8_t>& secure_reneg_info,
const Client_Hello& client_hello,
const Server_Hello::Settings& settings,
const std::string next_protocol);
@@ -373,20 +373,20 @@ class BOTAN_DLL Server_Hello final : public Handshake_Message
Handshake_Hash& hash,
const Policy& policy,
RandomNumberGenerator& rng,
- const std::vector<byte>& secure_reneg_info,
+ const std::vector<uint8_t>& secure_reneg_info,
const Client_Hello& client_hello,
Session& resumed_session,
bool offer_session_ticket,
const std::string& next_protocol);
- explicit Server_Hello(const std::vector<byte>& buf);
+ explicit Server_Hello(const std::vector<uint8_t>& buf);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
Protocol_Version m_version;
- std::vector<byte> m_session_id, m_random;
- u16bit m_ciphersuite;
- byte m_comp_method;
+ std::vector<uint8_t> m_session_id, m_random;
+ uint16_t m_ciphersuite;
+ uint8_t m_comp_method;
Extensions m_extensions;
};
@@ -399,7 +399,7 @@ class Client_Key_Exchange final : public Handshake_Message
public:
Handshake_Type type() const override { return CLIENT_KEX; }
- const secure_vector<byte>& pre_master_secret() const
+ const secure_vector<uint8_t>& pre_master_secret() const
{ return m_pre_master; }
Client_Key_Exchange(Handshake_IO& io,
@@ -410,7 +410,7 @@ class Client_Key_Exchange final : public Handshake_Message
const std::string& hostname,
RandomNumberGenerator& rng);
- Client_Key_Exchange(const std::vector<byte>& buf,
+ Client_Key_Exchange(const std::vector<uint8_t>& buf,
const Handshake_State& state,
const Private_Key* server_rsa_kex_key,
Credentials_Manager& creds,
@@ -418,11 +418,11 @@ class Client_Key_Exchange final : public Handshake_Message
RandomNumberGenerator& rng);
private:
- std::vector<byte> serialize() const override
+ std::vector<uint8_t> serialize() const override
{ return m_key_material; }
- std::vector<byte> m_key_material;
- secure_vector<byte> m_pre_master;
+ std::vector<uint8_t> m_key_material;
+ secure_vector<uint8_t> m_pre_master;
};
/**
@@ -441,9 +441,9 @@ class Certificate final : public Handshake_Message
Handshake_Hash& hash,
const std::vector<X509_Certificate>& certs);
- explicit Certificate(const std::vector<byte>& buf, const Policy &policy);
+ explicit Certificate(const std::vector<uint8_t>& buf, const Policy &policy);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
std::vector<X509_Certificate> m_certs;
};
@@ -458,14 +458,14 @@ class Certificate_Status final : public Handshake_Message
std::shared_ptr<const OCSP::Response> response() const { return m_response; }
- Certificate_Status(const std::vector<byte>& buf);
+ Certificate_Status(const std::vector<uint8_t>& buf);
Certificate_Status(Handshake_IO& io,
Handshake_Hash& hash,
std::shared_ptr<const OCSP::Response> response);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
std::shared_ptr<const OCSP::Response> m_response;
};
@@ -491,10 +491,10 @@ class Certificate_Req final : public Handshake_Message
const std::vector<X509_DN>& allowed_cas,
Protocol_Version version);
- Certificate_Req(const std::vector<byte>& buf,
+ Certificate_Req(const std::vector<uint8_t>& buf,
Protocol_Version version);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
std::vector<X509_DN> m_names;
std::vector<std::string> m_cert_key_types;
@@ -526,14 +526,14 @@ class BOTAN_DLL Certificate_Verify final : public Handshake_Message
RandomNumberGenerator& rng,
const Private_Key* key);
- Certificate_Verify(const std::vector<byte>& buf,
+ Certificate_Verify(const std::vector<uint8_t>& buf,
Protocol_Version version);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
std::string m_sig_algo; // sig algo used to create signature
std::string m_hash_algo; // hash used to create signature
- std::vector<byte> m_signature;
+ std::vector<uint8_t> m_signature;
};
/**
@@ -544,7 +544,7 @@ class Finished final : public Handshake_Message
public:
Handshake_Type type() const override { return FINISHED; }
- std::vector<byte> verify_data() const
+ std::vector<uint8_t> verify_data() const
{ return m_verification_data; }
bool verify(const Handshake_State& state,
@@ -554,11 +554,11 @@ class Finished final : public Handshake_Message
Handshake_State& state,
Connection_Side side);
- explicit Finished(const std::vector<byte>& buf);
+ explicit Finished(const std::vector<uint8_t>& buf);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
- std::vector<byte> m_verification_data;
+ std::vector<uint8_t> m_verification_data;
};
/**
@@ -570,9 +570,9 @@ class BOTAN_DLL Hello_Request final : public Handshake_Message
Handshake_Type type() const override { return HELLO_REQUEST; }
explicit Hello_Request(Handshake_IO& io);
- explicit Hello_Request(const std::vector<byte>& buf);
+ explicit Hello_Request(const std::vector<uint8_t>& buf);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
};
/**
@@ -583,7 +583,7 @@ class Server_Key_Exchange final : public Handshake_Message
public:
Handshake_Type type() const override { return SERVER_KEX; }
- const std::vector<byte>& params() const { return m_params; }
+ const std::vector<uint8_t>& params() const { return m_params; }
bool verify(const Public_Key& server_key,
const Handshake_State& state,
@@ -617,14 +617,14 @@ class Server_Key_Exchange final : public Handshake_Message
RandomNumberGenerator& rng,
const Private_Key* signing_key = nullptr);
- Server_Key_Exchange(const std::vector<byte>& buf,
+ Server_Key_Exchange(const std::vector<uint8_t>& buf,
const std::string& kex_alg,
const std::string& sig_alg,
Protocol_Version version);
~Server_Key_Exchange();
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
#if defined(BOTAN_HAS_SRP6)
std::unique_ptr<SRP6_Server_Session> m_srp_params;
@@ -636,11 +636,11 @@ class Server_Key_Exchange final : public Handshake_Message
std::unique_ptr<Private_Key> m_kex_key;
- std::vector<byte> m_params;
+ std::vector<uint8_t> m_params;
std::string m_sig_algo; // sig algo used to create signature
std::string m_hash_algo; // hash used to create signature
- std::vector<byte> m_signature;
+ std::vector<uint8_t> m_signature;
};
/**
@@ -652,9 +652,9 @@ class Server_Hello_Done final : public Handshake_Message
Handshake_Type type() const override { return SERVER_HELLO_DONE; }
Server_Hello_Done(Handshake_IO& io, Handshake_Hash& hash);
- explicit Server_Hello_Done(const std::vector<byte>& buf);
+ explicit Server_Hello_Done(const std::vector<uint8_t>& buf);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
};
/**
@@ -665,23 +665,23 @@ class BOTAN_DLL New_Session_Ticket final : public Handshake_Message
public:
Handshake_Type type() const override { return NEW_SESSION_TICKET; }
- u32bit ticket_lifetime_hint() const { return m_ticket_lifetime_hint; }
- const std::vector<byte>& ticket() const { return m_ticket; }
+ uint32_t ticket_lifetime_hint() const { return m_ticket_lifetime_hint; }
+ const std::vector<uint8_t>& ticket() const { return m_ticket; }
New_Session_Ticket(Handshake_IO& io,
Handshake_Hash& hash,
- const std::vector<byte>& ticket,
- u32bit lifetime);
+ const std::vector<uint8_t>& ticket,
+ uint32_t lifetime);
New_Session_Ticket(Handshake_IO& io,
Handshake_Hash& hash);
- explicit New_Session_Ticket(const std::vector<byte>& buf);
+ explicit New_Session_Ticket(const std::vector<uint8_t>& buf);
private:
- std::vector<byte> serialize() const override;
+ std::vector<uint8_t> serialize() const override;
- u32bit m_ticket_lifetime_hint = 0;
- std::vector<byte> m_ticket;
+ uint32_t m_ticket_lifetime_hint = 0;
+ std::vector<uint8_t> m_ticket;
};
/**
@@ -692,8 +692,8 @@ class Change_Cipher_Spec final : public Handshake_Message
public:
Handshake_Type type() const override { return HANDSHAKE_CCS; }
- std::vector<byte> serialize() const override
- { return std::vector<byte>(1, 1); }
+ std::vector<uint8_t> serialize() const override
+ { return std::vector<uint8_t>(1, 1); }
};
}
diff --git a/src/lib/tls/tls_policy.cpp b/src/lib/tls/tls_policy.cpp
index 84ba5e4bf..ccab54ca0 100644
--- a/src/lib/tls/tls_policy.cpp
+++ b/src/lib/tls/tls_policy.cpp
@@ -224,12 +224,12 @@ void Policy::check_peer_key_acceptable(const Public_Key& public_key) const
/*
* Return allowed compression algorithms
*/
-std::vector<byte> Policy::compression() const
+std::vector<uint8_t> Policy::compression() const
{
- return std::vector<byte>{ NO_COMPRESSION };
+ return std::vector<uint8_t>{ NO_COMPRESSION };
}
-u32bit Policy::session_ticket_lifetime() const
+uint32_t Policy::session_ticket_lifetime() const
{
return 86400; // ~1 day
}
@@ -289,9 +289,9 @@ size_t Policy::dtls_default_mtu() const
return 1280 - 40 - 8;
}
-std::vector<u16bit> Policy::srtp_profiles() const
+std::vector<uint16_t> Policy::srtp_profiles() const
{
- return std::vector<u16bit>();
+ return std::vector<uint16_t>();
}
namespace {
@@ -367,7 +367,7 @@ class Ciphersuite_Preference_Ordering
}
-std::vector<u16bit> Policy::ciphersuite_list(Protocol_Version version,
+std::vector<uint16_t> Policy::ciphersuite_list(Protocol_Version version,
bool have_srp) const
{
const std::vector<std::string> ciphers = allowed_ciphers();
@@ -421,7 +421,7 @@ std::vector<u16bit> Policy::ciphersuite_list(Protocol_Version version,
Ciphersuite_Preference_Ordering order(ciphers, macs, kex, sigs);
std::sort(ciphersuites.begin(), ciphersuites.end(), order);
- std::vector<u16bit> ciphersuite_codes;
+ std::vector<uint16_t> ciphersuite_codes;
for(auto i : ciphersuites)
ciphersuite_codes.push_back(i.ciphersuite_code());
return ciphersuite_codes;
diff --git a/src/lib/tls/tls_policy.h b/src/lib/tls/tls_policy.h
index b577eb265..9fd3561a3 100644
--- a/src/lib/tls/tls_policy.h
+++ b/src/lib/tls/tls_policy.h
@@ -94,7 +94,7 @@ class BOTAN_DLL Policy
*
* @note Compression is not currently supported
*/
- virtual std::vector<byte> compression() const;
+ virtual std::vector<uint8_t> compression() const;
/**
* Choose an elliptic curve to use
@@ -215,14 +215,14 @@ class BOTAN_DLL Policy
* tickets do not expire until the session ticket key rolls over.
* Expired session tickets cannot be used to resume a session.
*/
- virtual u32bit session_ticket_lifetime() const;
+ virtual uint32_t session_ticket_lifetime() const;
/**
* If this returns a non-empty vector, and DTLS is negotiated,
* then we will also attempt to negotiate the SRTP extension from
* RFC 5764 using the returned values as the profile ids.
*/
- virtual std::vector<u16bit> srtp_profiles() const;
+ virtual std::vector<uint16_t> srtp_profiles() const;
/**
* @return true if and only if we are willing to accept this version
@@ -267,7 +267,7 @@ class BOTAN_DLL Policy
/**
* Return allowed ciphersuites, in order of preference
*/
- virtual std::vector<u16bit> ciphersuite_list(Protocol_Version version,
+ virtual std::vector<uint16_t> ciphersuite_list(Protocol_Version version,
bool have_srp) const;
/**
@@ -450,15 +450,15 @@ class BOTAN_DLL Text_Policy : public Policy
bool hide_unknown_users() const override
{ return get_bool("hide_unknown_users", Policy::hide_unknown_users()); }
- u32bit session_ticket_lifetime() const override
- { return static_cast<u32bit>(get_len("session_ticket_lifetime", Policy::session_ticket_lifetime())); }
+ uint32_t session_ticket_lifetime() const override
+ { return static_cast<uint32_t>(get_len("session_ticket_lifetime", Policy::session_ticket_lifetime())); }
bool send_fallback_scsv(Protocol_Version version) const override
{ return get_bool("send_fallback_scsv", false) ? Policy::send_fallback_scsv(version) : false; }
- std::vector<u16bit> srtp_profiles() const override
+ std::vector<uint16_t> srtp_profiles() const override
{
- std::vector<u16bit> r;
+ std::vector<uint16_t> r;
for(auto&& p : get_list("srtp_profiles", std::vector<std::string>()))
{
r.push_back(to_u32bit(p));
diff --git a/src/lib/tls/tls_reader.h b/src/lib/tls/tls_reader.h
index 88bc4e932..e461d8ffc 100644
--- a/src/lib/tls/tls_reader.h
+++ b/src/lib/tls/tls_reader.h
@@ -24,7 +24,7 @@ namespace TLS {
class TLS_Data_Reader
{
public:
- TLS_Data_Reader(const char* type, const std::vector<byte>& buf_in) :
+ TLS_Data_Reader(const char* type, const std::vector<uint8_t>& buf_in) :
m_typename(type), m_buf(buf_in), m_offset(0) {}
void assert_done() const
@@ -39,9 +39,9 @@ class TLS_Data_Reader
bool has_remaining() const { return (remaining_bytes() > 0); }
- std::vector<byte> get_remaining()
+ std::vector<uint8_t> get_remaining()
{
- return std::vector<byte>(m_buf.begin() + m_offset, m_buf.end());
+ return std::vector<uint8_t>(m_buf.begin() + m_offset, m_buf.end());
}
void discard_next(size_t bytes)
@@ -50,27 +50,27 @@ class TLS_Data_Reader
m_offset += bytes;
}
- u32bit get_u32bit()
+ uint32_t get_uint32_t()
{
assert_at_least(4);
- u32bit result = make_u32bit(m_buf[m_offset ], m_buf[m_offset+1],
+ uint32_t result = make_uint32(m_buf[m_offset ], m_buf[m_offset+1],
m_buf[m_offset+2], m_buf[m_offset+3]);
m_offset += 4;
return result;
}
- u16bit get_u16bit()
+ uint16_t get_uint16_t()
{
assert_at_least(2);
- u16bit result = make_u16bit(m_buf[m_offset], m_buf[m_offset+1]);
+ uint16_t result = make_uint16(m_buf[m_offset], m_buf[m_offset+1]);
m_offset += 2;
return result;
}
- byte get_byte()
+ uint8_t get_byte()
{
assert_at_least(1);
- byte result = m_buf[m_offset];
+ uint8_t result = m_buf[m_offset];
m_offset += 1;
return result;
}
@@ -116,8 +116,8 @@ class TLS_Data_Reader
size_t min_bytes,
size_t max_bytes)
{
- std::vector<byte> v =
- get_range_vector<byte>(len_bytes, min_bytes, max_bytes);
+ std::vector<uint8_t> v =
+ get_range_vector<uint8_t>(len_bytes, min_bytes, max_bytes);
return std::string(reinterpret_cast<char*>(v.data()), v.size());
}
@@ -136,7 +136,7 @@ class TLS_Data_Reader
if(len_bytes == 1)
return get_byte();
else if(len_bytes == 2)
- return get_u16bit();
+ return get_uint16_t();
throw decode_error("Bad length size");
}
@@ -174,7 +174,7 @@ class TLS_Data_Reader
}
const char* m_typename;
- const std::vector<byte>& m_buf;
+ const std::vector<uint8_t>& m_buf;
size_t m_offset;
};
@@ -182,7 +182,7 @@ class TLS_Data_Reader
* Helper function for encoding length-tagged vectors
*/
template<typename T, typename Alloc>
-void append_tls_length_value(std::vector<byte, Alloc>& buf,
+void append_tls_length_value(std::vector<uint8_t, Alloc>& buf,
const T* vals,
size_t vals_size,
size_t tag_size)
@@ -206,7 +206,7 @@ void append_tls_length_value(std::vector<byte, Alloc>& buf,
}
template<typename T, typename Alloc, typename Alloc2>
-void append_tls_length_value(std::vector<byte, Alloc>& buf,
+void append_tls_length_value(std::vector<uint8_t, Alloc>& buf,
const std::vector<T, Alloc2>& vals,
size_t tag_size)
{
@@ -214,12 +214,12 @@ void append_tls_length_value(std::vector<byte, Alloc>& buf,
}
template<typename Alloc>
-void append_tls_length_value(std::vector<byte, Alloc>& buf,
+void append_tls_length_value(std::vector<uint8_t, Alloc>& buf,
const std::string& str,
size_t tag_size)
{
append_tls_length_value(buf,
- reinterpret_cast<const byte*>(str.data()),
+ reinterpret_cast<const uint8_t*>(str.data()),
str.size(),
tag_size);
}
diff --git a/src/lib/tls/tls_record.cpp b/src/lib/tls/tls_record.cpp
index 5eef2b4e2..71251398b 100644
--- a/src/lib/tls/tls_record.cpp
+++ b/src/lib/tls/tls_record.cpp
@@ -109,43 +109,43 @@ Connection_Cipher_State::Connection_Cipher_State(Protocol_Version version,
}
}
-std::vector<byte> Connection_Cipher_State::aead_nonce(u64bit seq, RandomNumberGenerator& rng)
+std::vector<uint8_t> Connection_Cipher_State::aead_nonce(uint64_t seq, RandomNumberGenerator& rng)
{
if(m_cbc_nonce)
{
if(m_nonce.size())
{
- std::vector<byte> nonce;
+ std::vector<uint8_t> nonce;
nonce.swap(m_nonce);
return nonce;
}
- std::vector<byte> nonce(nonce_bytes_from_record());
+ std::vector<uint8_t> nonce(nonce_bytes_from_record());
rng.randomize(nonce.data(), nonce.size());
return nonce;
}
else if(nonce_bytes_from_handshake() == 12)
{
- std::vector<byte> nonce(12);
+ std::vector<uint8_t> nonce(12);
store_be(seq, nonce.data() + 4);
xor_buf(nonce, m_nonce.data(), m_nonce.size());
return nonce;
}
else
{
- std::vector<byte> nonce = m_nonce;
+ std::vector<uint8_t> nonce = m_nonce;
store_be(seq, &nonce[nonce_bytes_from_handshake()]);
return nonce;
}
}
-std::vector<byte>
-Connection_Cipher_State::aead_nonce(const byte record[], size_t record_len, u64bit seq)
+std::vector<uint8_t>
+Connection_Cipher_State::aead_nonce(const uint8_t record[], size_t record_len, uint64_t seq)
{
if(m_cbc_nonce)
{
if(record_len < nonce_bytes_from_record())
throw Decoding_Error("Invalid CBC packet too short to be valid");
- std::vector<byte> nonce(record, record + nonce_bytes_from_record());
+ std::vector<uint8_t> nonce(record, record + nonce_bytes_from_record());
return nonce;
}
else if(nonce_bytes_from_handshake() == 12)
@@ -155,7 +155,7 @@ Connection_Cipher_State::aead_nonce(const byte record[], size_t record_len, u64b
use the XOR nonce construction from draft-ietf-tls-chacha20-poly1305
*/
- std::vector<byte> nonce(12);
+ std::vector<uint8_t> nonce(12);
store_be(seq, nonce.data() + 4);
xor_buf(nonce, m_nonce.data(), m_nonce.size());
return nonce;
@@ -164,7 +164,7 @@ Connection_Cipher_State::aead_nonce(const byte record[], size_t record_len, u64b
{
if(record_len < nonce_bytes_from_record())
throw Decoding_Error("Invalid AEAD packet too short to be valid");
- std::vector<byte> nonce = m_nonce;
+ std::vector<uint8_t> nonce = m_nonce;
copy_mem(&nonce[nonce_bytes_from_handshake()], record, nonce_bytes_from_record());
return nonce;
}
@@ -174,19 +174,19 @@ Connection_Cipher_State::aead_nonce(const byte record[], size_t record_len, u64b
nonce_len == 0 is assumed to mean no nonce in the message but
instead the AEAD uses the seq number in network order.
*/
- std::vector<byte> nonce = m_nonce;
+ std::vector<uint8_t> nonce = m_nonce;
store_be(seq, &nonce[nonce_bytes_from_handshake()]);
return nonce;
}
}
-std::vector<byte>
-Connection_Cipher_State::format_ad(u64bit msg_sequence,
- byte msg_type,
+std::vector<uint8_t>
+Connection_Cipher_State::format_ad(uint64_t msg_sequence,
+ uint8_t msg_type,
Protocol_Version version,
- u16bit msg_length)
+ uint16_t msg_length)
{
- std::vector<byte> ad(13);
+ std::vector<uint8_t> ad(13);
store_be(msg_sequence, &ad[0]);
ad[8] = msg_type;
@@ -200,7 +200,7 @@ Connection_Cipher_State::format_ad(u64bit msg_sequence,
namespace {
-inline void append_u16_len(secure_vector<byte>& output, size_t len_field)
+inline void append_u16_len(secure_vector<uint8_t>& output, size_t len_field)
{
const uint16_t len16 = len_field;
BOTAN_ASSERT_EQUAL(len_field, len16, "No truncation");
@@ -210,10 +210,10 @@ inline void append_u16_len(secure_vector<byte>& output, size_t len_field)
}
-void write_record(secure_vector<byte>& output,
+void write_record(secure_vector<uint8_t>& output,
Record_Message msg,
Protocol_Version version,
- u64bit seq,
+ uint64_t seq,
Connection_Cipher_State* cs,
RandomNumberGenerator& rng)
{
@@ -237,7 +237,7 @@ void write_record(secure_vector<byte>& output,
}
AEAD_Mode* aead = cs->aead();
- std::vector<byte> aad = cs->format_ad(seq, msg.get_type(), version, static_cast<u16bit>(msg.get_size()));
+ std::vector<uint8_t> aad = cs->format_ad(seq, msg.get_type(), version, static_cast<uint16_t>(msg.get_size()));
const size_t ctext_size = aead->output_length(msg.get_size());
@@ -245,7 +245,7 @@ void write_record(secure_vector<byte>& output,
aead->set_ad(aad);
- const std::vector<byte> nonce = cs->aead_nonce(seq, rng);
+ const std::vector<uint8_t> nonce = cs->aead_nonce(seq, rng);
append_u16_len(output, rec_size);
@@ -269,8 +269,8 @@ void write_record(secure_vector<byte>& output,
namespace {
-size_t fill_buffer_to(secure_vector<byte>& readbuf,
- const byte*& input,
+size_t fill_buffer_to(secure_vector<uint8_t>& readbuf,
+ const uint8_t*& input,
size_t& input_size,
size_t& input_consumed,
size_t desired)
@@ -288,9 +288,9 @@ size_t fill_buffer_to(secure_vector<byte>& readbuf,
return (desired - readbuf.size()); // how many bytes do we still need?
}
-void decrypt_record(secure_vector<byte>& output,
- byte record_contents[], size_t record_len,
- u64bit record_sequence,
+void decrypt_record(secure_vector<uint8_t>& output,
+ uint8_t record_contents[], size_t record_len,
+ uint64_t record_sequence,
Protocol_Version record_version,
Record_Type record_type,
Connection_Cipher_State& cs)
@@ -298,14 +298,14 @@ void decrypt_record(secure_vector<byte>& output,
AEAD_Mode* aead = cs.aead();
BOTAN_ASSERT(aead, "Cannot decrypt without cipher");
- const std::vector<byte> nonce = cs.aead_nonce(record_contents, record_len, record_sequence);
- const byte* msg = &record_contents[cs.nonce_bytes_from_record()];
+ const std::vector<uint8_t> nonce = cs.aead_nonce(record_contents, record_len, record_sequence);
+ const uint8_t* msg = &record_contents[cs.nonce_bytes_from_record()];
const size_t msg_length = record_len - cs.nonce_bytes_from_record();
const size_t ptext_size = aead->output_length(msg_length);
aead->set_associated_data_vec(
- cs.format_ad(record_sequence, record_type, record_version, static_cast<u16bit>(ptext_size))
+ cs.format_ad(record_sequence, record_type, record_version, static_cast<uint16_t>(ptext_size))
);
aead->start(nonce);
@@ -315,7 +315,7 @@ void decrypt_record(secure_vector<byte>& output,
aead->finish(output, offset);
}
-size_t read_tls_record(secure_vector<byte>& readbuf,
+size_t read_tls_record(secure_vector<uint8_t>& readbuf,
Record_Raw_Input& raw_input,
Record& rec,
Connection_Sequence_Numbers* sequence_numbers,
@@ -335,7 +335,7 @@ size_t read_tls_record(secure_vector<byte>& readbuf,
BOTAN_ASSERT(!rec.get_protocol_version()->is_datagram_protocol(), "Expected TLS");
- const size_t record_size = make_u16bit(readbuf[TLS_HEADER_SIZE-2],
+ const size_t record_size = make_uint16(readbuf[TLS_HEADER_SIZE-2],
readbuf[TLS_HEADER_SIZE-1]);
if(record_size > MAX_CIPHERTEXT_SIZE)
@@ -357,7 +357,7 @@ size_t read_tls_record(secure_vector<byte>& readbuf,
*rec.get_type() = static_cast<Record_Type>(readbuf[0]);
- u16bit epoch = 0;
+ uint16_t epoch = 0;
if(sequence_numbers)
{
@@ -371,7 +371,7 @@ size_t read_tls_record(secure_vector<byte>& readbuf,
epoch = 0;
}
- byte* record_contents = &readbuf[TLS_HEADER_SIZE];
+ uint8_t* record_contents = &readbuf[TLS_HEADER_SIZE];
if(epoch == 0) // Unencrypted initial handshake
{
@@ -400,7 +400,7 @@ size_t read_tls_record(secure_vector<byte>& readbuf,
return 0;
}
-size_t read_dtls_record(secure_vector<byte>& readbuf,
+size_t read_dtls_record(secure_vector<uint8_t>& readbuf,
Record_Raw_Input& raw_input,
Record& rec,
Connection_Sequence_Numbers* sequence_numbers,
@@ -421,7 +421,7 @@ size_t read_dtls_record(secure_vector<byte>& readbuf,
BOTAN_ASSERT(rec.get_protocol_version()->is_datagram_protocol(), "Expected DTLS");
- const size_t record_size = make_u16bit(readbuf[DTLS_HEADER_SIZE-2],
+ const size_t record_size = make_uint16(readbuf[DTLS_HEADER_SIZE-2],
readbuf[DTLS_HEADER_SIZE-1]);
if(record_size > MAX_CIPHERTEXT_SIZE)
@@ -440,9 +440,9 @@ size_t read_dtls_record(secure_vector<byte>& readbuf,
*rec.get_type() = static_cast<Record_Type>(readbuf[0]);
- u16bit epoch = 0;
+ uint16_t epoch = 0;
- *rec.get_sequence() = load_be<u64bit>(&readbuf[3], 0);
+ *rec.get_sequence() = load_be<uint64_t>(&readbuf[3], 0);
epoch = (*rec.get_sequence() >> 48);
if(sequence_numbers && sequence_numbers->already_seen(*rec.get_sequence()))
@@ -451,7 +451,7 @@ size_t read_dtls_record(secure_vector<byte>& readbuf,
return 0;
}
- byte* record_contents = &readbuf[DTLS_HEADER_SIZE];
+ uint8_t* record_contents = &readbuf[DTLS_HEADER_SIZE];
if(epoch == 0) // Unencrypted initial handshake
{
@@ -491,7 +491,7 @@ size_t read_dtls_record(secure_vector<byte>& readbuf,
}
-size_t read_record(secure_vector<byte>& readbuf,
+size_t read_record(secure_vector<uint8_t>& readbuf,
Record_Raw_Input& raw_input,
Record& rec,
Connection_Sequence_Numbers* sequence_numbers,
diff --git a/src/lib/tls/tls_record.h b/src/lib/tls/tls_record.h
index d4a2a9372..ebb83c484 100644
--- a/src/lib/tls/tls_record.h
+++ b/src/lib/tls/tls_record.h
@@ -44,13 +44,13 @@ class Connection_Cipher_State
AEAD_Mode* aead() { return m_aead.get(); }
- std::vector<byte> aead_nonce(u64bit seq, RandomNumberGenerator& rng);
+ std::vector<uint8_t> aead_nonce(uint64_t seq, RandomNumberGenerator& rng);
- std::vector<byte> aead_nonce(const byte record[], size_t record_len, u64bit seq);
+ std::vector<uint8_t> aead_nonce(const uint8_t record[], size_t record_len, uint64_t seq);
- std::vector<byte> format_ad(u64bit seq, byte type,
+ std::vector<uint8_t> format_ad(uint64_t seq, uint8_t type,
Protocol_Version version,
- u16bit ptext_length);
+ uint16_t ptext_length);
size_t nonce_bytes_from_handshake() const { return m_nonce_bytes_from_handshake; }
size_t nonce_bytes_from_record() const { return m_nonce_bytes_from_record; }
@@ -66,7 +66,7 @@ class Connection_Cipher_State
std::chrono::system_clock::time_point m_start_time;
std::unique_ptr<AEAD_Mode> m_aead;
- std::vector<byte> m_nonce;
+ std::vector<uint8_t> m_nonce;
size_t m_nonce_bytes_from_handshake;
size_t m_nonce_bytes_from_record;
bool m_cbc_nonce;
@@ -75,26 +75,26 @@ class Connection_Cipher_State
class Record
{
public:
- Record(secure_vector<byte>& data,
- u64bit* sequence,
+ Record(secure_vector<uint8_t>& data,
+ uint64_t* sequence,
Protocol_Version* protocol_version,
Record_Type* type)
: m_data(data), m_sequence(sequence), m_protocol_version(protocol_version),
m_type(type), m_size(data.size()) {};
- secure_vector<byte>& get_data() { return m_data; }
+ secure_vector<uint8_t>& get_data() { return m_data; }
Protocol_Version* get_protocol_version() { return m_protocol_version; }
- u64bit* get_sequence() { return m_sequence; }
+ uint64_t* get_sequence() { return m_sequence; }
Record_Type* get_type() { return m_type; }
size_t& get_size() { return m_size; }
private:
- secure_vector<byte>& m_data;
- u64bit* m_sequence;
+ secure_vector<uint8_t>& m_data;
+ uint64_t* m_sequence;
Protocol_Version* m_protocol_version;
Record_Type* m_type;
size_t m_size;
@@ -103,33 +103,33 @@ class Record
class Record_Message
{
public:
- Record_Message(const byte* data, size_t size)
+ Record_Message(const uint8_t* data, size_t size)
: m_type(0), m_sequence(0), m_data(data), m_size(size) {};
- Record_Message(byte type, u64bit sequence, const byte* data, size_t size)
+ Record_Message(uint8_t type, uint64_t sequence, const uint8_t* data, size_t size)
: m_type(type), m_sequence(sequence), m_data(data),
m_size(size) {};
- byte& get_type() { return m_type; };
- u64bit& get_sequence() { return m_sequence; };
- const byte* get_data() { return m_data; };
+ uint8_t& get_type() { return m_type; };
+ uint64_t& get_sequence() { return m_sequence; };
+ const uint8_t* get_data() { return m_data; };
size_t& get_size() { return m_size; };
private:
- byte m_type;
- u64bit m_sequence;
- const byte* m_data;
+ uint8_t m_type;
+ uint64_t m_sequence;
+ const uint8_t* m_data;
size_t m_size;
};
class Record_Raw_Input
{
public:
- Record_Raw_Input(const byte* data, size_t size, size_t& consumed,
+ Record_Raw_Input(const uint8_t* data, size_t size, size_t& consumed,
bool is_datagram)
: m_data(data), m_size(size), m_consumed(consumed),
m_is_datagram(is_datagram) {};
- const byte*& get_data() { return m_data; };
+ const uint8_t*& get_data() { return m_data; };
size_t& get_size() { return m_size; };
@@ -139,7 +139,7 @@ class Record_Raw_Input
bool is_datagram() { return m_is_datagram; };
private:
- const byte* m_data;
+ const uint8_t* m_data;
size_t m_size;
size_t& m_consumed;
bool m_is_datagram;
@@ -155,21 +155,21 @@ class Record_Raw_Input
* @param cipherstate is the writing cipher state
* @param rng is a random number generator
*/
-void write_record(secure_vector<byte>& write_buffer,
+void write_record(secure_vector<uint8_t>& write_buffer,
Record_Message rec_msg,
Protocol_Version version,
- u64bit msg_sequence,
+ uint64_t msg_sequence,
Connection_Cipher_State* cipherstate,
RandomNumberGenerator& rng);
// epoch -> cipher state
-typedef std::function<std::shared_ptr<Connection_Cipher_State> (u16bit)> get_cipherstate_fn;
+typedef std::function<std::shared_ptr<Connection_Cipher_State> (uint16_t)> get_cipherstate_fn;
/**
* Decode a TLS record
* @return zero if full message, else number of bytes still needed
*/
-size_t read_record(secure_vector<byte>& read_buffer,
+size_t read_record(secure_vector<uint8_t>& read_buffer,
Record_Raw_Input& raw_input,
Record& rec,
Connection_Sequence_Numbers* sequence_numbers,
diff --git a/src/lib/tls/tls_seq_numbers.h b/src/lib/tls/tls_seq_numbers.h
index aa0cfe1f4..ece329494 100644
--- a/src/lib/tls/tls_seq_numbers.h
+++ b/src/lib/tls/tls_seq_numbers.h
@@ -22,14 +22,14 @@ class Connection_Sequence_Numbers
virtual void new_read_cipher_state() = 0;
virtual void new_write_cipher_state() = 0;
- virtual u16bit current_read_epoch() const = 0;
- virtual u16bit current_write_epoch() const = 0;
+ virtual uint16_t current_read_epoch() const = 0;
+ virtual uint16_t current_write_epoch() const = 0;
- virtual u64bit next_write_sequence(u16bit) = 0;
- virtual u64bit next_read_sequence() = 0;
+ virtual uint64_t next_write_sequence(uint16_t) = 0;
+ virtual uint64_t next_read_sequence() = 0;
- virtual bool already_seen(u64bit seq) const = 0;
- virtual void read_accept(u64bit seq) = 0;
+ virtual bool already_seen(uint64_t seq) const = 0;
+ virtual void read_accept(uint64_t seq) = 0;
};
class Stream_Sequence_Numbers final : public Connection_Sequence_Numbers
@@ -38,19 +38,19 @@ class Stream_Sequence_Numbers final : public Connection_Sequence_Numbers
void new_read_cipher_state() override { m_read_seq_no = 0; m_read_epoch += 1; }
void new_write_cipher_state() override { m_write_seq_no = 0; m_write_epoch += 1; }
- u16bit current_read_epoch() const override { return m_read_epoch; }
- u16bit current_write_epoch() const override { return m_write_epoch; }
+ uint16_t current_read_epoch() const override { return m_read_epoch; }
+ uint16_t current_write_epoch() const override { return m_write_epoch; }
- u64bit next_write_sequence(u16bit) override { return m_write_seq_no++; }
- u64bit next_read_sequence() override { return m_read_seq_no; }
+ uint64_t next_write_sequence(uint16_t) override { return m_write_seq_no++; }
+ uint64_t next_read_sequence() override { return m_read_seq_no; }
- bool already_seen(u64bit) const override { return false; }
- void read_accept(u64bit) override { m_read_seq_no++; }
+ bool already_seen(uint64_t) const override { return false; }
+ void read_accept(uint64_t) override { m_read_seq_no++; }
private:
- u64bit m_write_seq_no = 0;
- u64bit m_read_seq_no = 0;
- u16bit m_read_epoch = 0;
- u16bit m_write_epoch = 0;
+ uint64_t m_write_seq_no = 0;
+ uint64_t m_read_seq_no = 0;
+ uint16_t m_read_epoch = 0;
+ uint16_t m_write_epoch = 0;
};
class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
@@ -66,29 +66,29 @@ class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
m_write_seqs[m_write_epoch] = 0;
}
- u16bit current_read_epoch() const override { return m_read_epoch; }
- u16bit current_write_epoch() const override { return m_write_epoch; }
+ uint16_t current_read_epoch() const override { return m_read_epoch; }
+ uint16_t current_write_epoch() const override { return m_write_epoch; }
- u64bit next_write_sequence(u16bit epoch) override
+ uint64_t next_write_sequence(uint16_t epoch) override
{
auto i = m_write_seqs.find(epoch);
BOTAN_ASSERT(i != m_write_seqs.end(), "Found epoch");
- return (static_cast<u64bit>(epoch) << 48) | i->second++;
+ return (static_cast<uint64_t>(epoch) << 48) | i->second++;
}
- u64bit next_read_sequence() override
+ uint64_t next_read_sequence() override
{
throw Exception("DTLS uses explicit sequence numbers");
}
- bool already_seen(u64bit sequence) const override
+ bool already_seen(uint64_t sequence) const override
{
const size_t window_size = sizeof(m_window_bits) * 8;
if(sequence > m_window_highest)
return false;
- const u64bit offset = m_window_highest - sequence;
+ const uint64_t offset = m_window_highest - sequence;
if(offset >= window_size)
return true; // really old?
@@ -96,7 +96,7 @@ class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
return (((m_window_bits >> offset) & 1) == 1);
}
- void read_accept(u64bit sequence) override
+ void read_accept(uint64_t sequence) override
{
const size_t window_size = sizeof(m_window_bits) * 8;
@@ -114,17 +114,17 @@ class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
}
else
{
- const u64bit offset = m_window_highest - sequence;
- m_window_bits |= (static_cast<u64bit>(1) << offset);
+ const uint64_t offset = m_window_highest - sequence;
+ m_window_bits |= (static_cast<uint64_t>(1) << offset);
}
}
private:
- std::map<u16bit, u64bit> m_write_seqs;
- u16bit m_write_epoch = 0;
- u16bit m_read_epoch = 0;
- u64bit m_window_highest = 0;
- u64bit m_window_bits = 0;
+ std::map<uint16_t, uint64_t> m_write_seqs;
+ uint16_t m_write_epoch = 0;
+ uint16_t m_read_epoch = 0;
+ uint64_t m_window_highest = 0;
+ uint64_t m_window_bits = 0;
};
}
diff --git a/src/lib/tls/tls_server.cpp b/src/lib/tls/tls_server.cpp
index 78c7704cc..1d42a6d25 100644
--- a/src/lib/tls/tls_server.cpp
+++ b/src/lib/tls/tls_server.cpp
@@ -51,8 +51,8 @@ bool check_for_resume(Session& session_info,
const Client_Hello* client_hello,
std::chrono::seconds session_ticket_lifetime)
{
- const std::vector<byte>& client_session_id = client_hello->session_id();
- const std::vector<byte>& session_ticket = client_hello->session_ticket();
+ const std::vector<uint8_t>& client_session_id = client_hello->session_id();
+ const std::vector<uint8_t>& session_ticket = client_hello->session_ticket();
if(session_ticket.empty())
{
@@ -149,7 +149,7 @@ bool check_for_resume(Session& session_info,
/*
* Choose which ciphersuite to use
*/
-u16bit choose_ciphersuite(
+uint16_t choose_ciphersuite(
const Policy& policy,
Protocol_Version version,
Credentials_Manager& creds,
@@ -158,8 +158,8 @@ u16bit choose_ciphersuite(
{
const bool our_choice = policy.server_uses_own_ciphersuite_preferences();
const bool have_srp = creds.attempt_srp("tls-server", client_hello.sni_hostname());
- const std::vector<u16bit> client_suites = client_hello.ciphersuites();
- const std::vector<u16bit> server_suites = policy.ciphersuite_list(version, have_srp);
+ const std::vector<uint16_t> client_suites = client_hello.ciphersuites();
+ const std::vector<uint16_t> server_suites = policy.ciphersuite_list(version, have_srp);
if(server_suites.empty())
throw TLS_Exception(Alert::HANDSHAKE_FAILURE,
@@ -172,8 +172,8 @@ u16bit choose_ciphersuite(
Walk down one list in preference order
*/
- std::vector<u16bit> pref_list = server_suites;
- std::vector<u16bit> other_list = client_suites;
+ std::vector<uint16_t> pref_list = server_suites;
+ std::vector<uint16_t> other_list = client_suites;
if(!our_choice)
std::swap(pref_list, other_list);
@@ -230,10 +230,10 @@ u16bit choose_ciphersuite(
/*
* Choose which compression algorithm to use
*/
-byte choose_compression(const Policy& policy,
- const std::vector<byte>& c_comp)
+uint8_t choose_compression(const Policy& policy,
+ const std::vector<uint8_t>& c_comp)
{
- std::vector<byte> s_comp = policy.compression();
+ std::vector<uint8_t> s_comp = policy.compression();
for(size_t i = 0; i != s_comp.size(); ++i)
for(size_t j = 0; j != c_comp.size(); ++j)
@@ -352,7 +352,7 @@ void Server::initiate_handshake(Handshake_State& state,
*/
void Server::process_client_hello_msg(const Handshake_State* active_state,
Server_Handshake_State& pending_state,
- const std::vector<byte>& contents)
+ const std::vector<uint8_t>& contents)
{
const bool initial_handshake = !active_state;
@@ -470,14 +470,14 @@ void Server::process_client_hello_msg(const Handshake_State* active_state,
}
void Server::process_certificate_msg(Server_Handshake_State& pending_state,
- const std::vector<byte>& contents)
+ const std::vector<uint8_t>& contents)
{
pending_state.client_certs(new Certificate(contents, policy()));
pending_state.set_expected_next(CLIENT_KEX);
}
void Server::process_client_key_exchange_msg(Server_Handshake_State& pending_state,
- const std::vector<byte>& contents)
+ const std::vector<uint8_t>& contents)
{
if(pending_state.received_handshake_msg(CERTIFICATE) && !pending_state.client_certs()->empty())
pending_state.set_expected_next(CERTIFICATE_VERIFY);
@@ -501,7 +501,7 @@ void Server::process_change_cipher_spec_msg(Server_Handshake_State& pending_stat
void Server::process_certificate_verify_msg(Server_Handshake_State& pending_state,
Handshake_Type type,
- const std::vector<byte>& contents)
+ const std::vector<uint8_t>& contents)
{
pending_state.client_verify ( new Certificate_Verify ( contents, pending_state.version() ) );
@@ -543,7 +543,7 @@ void Server::process_certificate_verify_msg(Server_Handshake_State& pending_stat
void Server::process_finished_msg(Server_Handshake_State& pending_state,
Handshake_Type type,
- const std::vector<byte>& contents)
+ const std::vector<uint8_t>& contents)
{
pending_state.set_expected_next ( HANDSHAKE_NONE );
@@ -569,7 +569,7 @@ void Server::process_finished_msg(Server_Handshake_State& pending_state,
pending_state.server_hello()->supports_extended_master_secret(),
pending_state.server_hello()->supports_encrypt_then_mac(),
get_peer_cert_chain ( pending_state ),
- std::vector<byte>(),
+ std::vector<uint8_t>(),
Server_Information(pending_state.client_hello()->sni_hostname()),
pending_state.srp_identifier(),
pending_state.server_hello()->srtp_profile()
@@ -621,7 +621,7 @@ void Server::process_finished_msg(Server_Handshake_State& pending_state,
void Server::process_handshake_msg(const Handshake_State* active_state,
Handshake_State& state_base,
Handshake_Type type,
- const std::vector<byte>& contents)
+ const std::vector<uint8_t>& contents)
{
Server_Handshake_State& state = dynamic_cast<Server_Handshake_State&>(state_base);
state.confirm_transition_to(type);
diff --git a/src/lib/tls/tls_server.h b/src/lib/tls/tls_server.h
index 051eda445..bea498ab7 100644
--- a/src/lib/tls/tls_server.h
+++ b/src/lib/tls/tls_server.h
@@ -112,27 +112,27 @@ class BOTAN_DLL Server final : public Channel
void process_handshake_msg(const Handshake_State* active_state,
Handshake_State& pending_state,
Handshake_Type type,
- const std::vector<byte>& contents) override;
+ const std::vector<uint8_t>& contents) override;
void process_client_hello_msg(const Handshake_State* active_state,
Server_Handshake_State& pending_state,
- const std::vector<byte>& contents);
+ const std::vector<uint8_t>& contents);
void process_certificate_msg(Server_Handshake_State& pending_state,
- const std::vector<byte>& contents);
+ const std::vector<uint8_t>& contents);
void process_client_key_exchange_msg(Server_Handshake_State& pending_state,
- const std::vector<byte>& contents);
+ const std::vector<uint8_t>& contents);
void process_change_cipher_spec_msg(Server_Handshake_State& pending_state);
void process_certificate_verify_msg(Server_Handshake_State& pending_state,
Handshake_Type type,
- const std::vector<byte>& contents);
+ const std::vector<uint8_t>& contents);
void process_finished_msg(Server_Handshake_State& pending_state,
Handshake_Type type,
- const std::vector<byte>& contents);
+ const std::vector<uint8_t>& contents);
void session_resume(Server_Handshake_State& pending_state,
bool have_session_ticket_key,
diff --git a/src/lib/tls/tls_server_info.h b/src/lib/tls/tls_server_info.h
index cd46aea3f..06b4f088a 100644
--- a/src/lib/tls/tls_server_info.h
+++ b/src/lib/tls/tls_server_info.h
@@ -32,7 +32,7 @@ class BOTAN_DLL Server_Information
* TCP/UDP). Zero represents unknown.
*/
Server_Information(const std::string& hostname,
- u16bit port = 0) :
+ uint16_t port = 0) :
m_hostname(hostname), m_service(""), m_port(port) {}
/**
@@ -44,7 +44,7 @@ class BOTAN_DLL Server_Information
*/
Server_Information(const std::string& hostname,
const std::string& service,
- u16bit port = 0) :
+ uint16_t port = 0) :
m_hostname(hostname), m_service(service), m_port(port) {}
/**
@@ -61,7 +61,7 @@ class BOTAN_DLL Server_Information
/**
* @return the protocol port of the server, or zero if unknown
*/
- u16bit port() const { return m_port; }
+ uint16_t port() const { return m_port; }
/**
* @return whether the hostname is known
@@ -70,7 +70,7 @@ class BOTAN_DLL Server_Information
private:
std::string m_hostname, m_service;
- u16bit m_port;
+ uint16_t m_port;
};
inline bool operator==(const Server_Information& a, const Server_Information& b)
diff --git a/src/lib/tls/tls_session.cpp b/src/lib/tls/tls_session.cpp
index d6b52846f..d82c490ab 100644
--- a/src/lib/tls/tls_session.cpp
+++ b/src/lib/tls/tls_session.cpp
@@ -17,19 +17,19 @@ namespace Botan {
namespace TLS {
-Session::Session(const std::vector<byte>& session_identifier,
- const secure_vector<byte>& master_secret,
+Session::Session(const std::vector<uint8_t>& session_identifier,
+ const secure_vector<uint8_t>& master_secret,
Protocol_Version version,
- u16bit ciphersuite,
- byte compression_method,
+ uint16_t ciphersuite,
+ uint8_t compression_method,
Connection_Side side,
bool extended_master_secret,
bool encrypt_then_mac,
const std::vector<X509_Certificate>& certs,
- const std::vector<byte>& ticket,
+ const std::vector<uint8_t>& ticket,
const Server_Information& server_info,
const std::string& srp_identifier,
- u16bit srtp_profile) :
+ uint16_t srtp_profile) :
m_start_time(std::chrono::system_clock::now()),
m_identifier(session_identifier),
m_session_ticket(ticket),
@@ -49,14 +49,14 @@ Session::Session(const std::vector<byte>& session_identifier,
Session::Session(const std::string& pem)
{
- secure_vector<byte> der = PEM_Code::decode_check_label(pem, "TLS SESSION");
+ secure_vector<uint8_t> der = PEM_Code::decode_check_label(pem, "TLS SESSION");
*this = Session(der.data(), der.size());
}
-Session::Session(const byte ber[], size_t ber_len)
+Session::Session(const uint8_t ber[], size_t ber_len)
{
- byte side_code = 0;
+ uint8_t side_code = 0;
ASN1_String server_hostname;
ASN1_String server_service;
@@ -64,8 +64,8 @@ Session::Session(const byte ber[], size_t ber_len)
ASN1_String srp_identifier_str;
- byte major_version = 0, minor_version = 0;
- std::vector<byte> peer_cert_bits;
+ uint8_t major_version = 0, minor_version = 0;
+ std::vector<uint8_t> peer_cert_bits;
size_t start_time = 0;
size_t srtp_profile = 0;
@@ -109,11 +109,11 @@ Session::Session(const byte ber[], size_t ber_len)
m_version = Protocol_Version(major_version, minor_version);
m_start_time = std::chrono::system_clock::from_time_t(start_time);
m_connection_side = static_cast<Connection_Side>(side_code);
- m_srtp_profile = static_cast<u16bit>(srtp_profile);
+ m_srtp_profile = static_cast<uint16_t>(srtp_profile);
m_server_info = Server_Information(server_hostname.value(),
server_service.value(),
- static_cast<u16bit>(server_port));
+ static_cast<uint16_t>(server_port));
m_srp_identifier = srp_identifier_str.value();
@@ -126,9 +126,9 @@ Session::Session(const byte ber[], size_t ber_len)
}
}
-secure_vector<byte> Session::DER_encode() const
+secure_vector<uint8_t> Session::DER_encode() const
{
- std::vector<byte> peer_cert_bits;
+ std::vector<uint8_t> peer_cert_bits;
for(size_t i = 0; i != m_peer_certs.size(); ++i)
peer_cert_bits += m_peer_certs[i].BER_encode();
@@ -168,14 +168,14 @@ std::chrono::seconds Session::session_age() const
std::chrono::system_clock::now() - m_start_time);
}
-std::vector<byte>
+std::vector<uint8_t>
Session::encrypt(const SymmetricKey& key, RandomNumberGenerator& rng) const
{
std::unique_ptr<AEAD_Mode> aead(get_aead("AES-256/GCM", ENCRYPTION));
const size_t nonce_len = aead->default_nonce_length();
- const secure_vector<byte> nonce = rng.random_vec(nonce_len);
- const secure_vector<byte> bits = this->DER_encode();
+ const secure_vector<uint8_t> nonce = rng.random_vec(nonce_len);
+ const secure_vector<uint8_t> bits = this->DER_encode();
// Support any length key for input
std::unique_ptr<MessageAuthenticationCode> hmac(MessageAuthenticationCode::create("HMAC(SHA-256)"));
@@ -183,14 +183,14 @@ Session::encrypt(const SymmetricKey& key, RandomNumberGenerator& rng) const
hmac->update(nonce);
aead->set_key(hmac->final());
- secure_vector<byte> buf = nonce;
+ secure_vector<uint8_t> buf = nonce;
buf += bits;
aead->start(buf.data(), nonce_len);
aead->finish(buf, nonce_len);
return unlock(buf);
}
-Session Session::decrypt(const byte in[], size_t in_len, const SymmetricKey& key)
+Session Session::decrypt(const uint8_t in[], size_t in_len, const SymmetricKey& key)
{
try
{
@@ -207,7 +207,7 @@ Session Session::decrypt(const byte in[], size_t in_len, const SymmetricKey& key
aead->set_key(hmac->final());
aead->start(in, nonce_len);
- secure_vector<byte> buf(in + nonce_len, in + in_len);
+ secure_vector<uint8_t> buf(in + nonce_len, in + in_len);
aead->finish(buf, 0);
return Session(buf.data(), buf.size());
diff --git a/src/lib/tls/tls_session.h b/src/lib/tls/tls_session.h
index 5530632db..115409014 100644
--- a/src/lib/tls/tls_session.h
+++ b/src/lib/tls/tls_session.h
@@ -45,26 +45,26 @@ class BOTAN_DLL Session
/**
* New session (sets session start time)
*/
- Session(const std::vector<byte>& session_id,
- const secure_vector<byte>& master_secret,
+ Session(const std::vector<uint8_t>& session_id,
+ const secure_vector<uint8_t>& master_secret,
Protocol_Version version,
- u16bit ciphersuite,
- byte compression_method,
+ uint16_t ciphersuite,
+ uint8_t compression_method,
Connection_Side side,
bool supports_extended_master_secret,
bool supports_encrypt_then_mac,
const std::vector<X509_Certificate>& peer_certs,
- const std::vector<byte>& session_ticket,
+ const std::vector<uint8_t>& session_ticket,
const Server_Information& server_info,
const std::string& srp_identifier,
- u16bit srtp_profile);
+ uint16_t srtp_profile);
/**
* Load a session from DER representation (created by DER_encode)
* @param ber DER representation buffer
* @param ber_len size of buffer in bytes
*/
- Session(const byte ber[], size_t ber_len);
+ Session(const uint8_t ber[], size_t ber_len);
/**
* Load a session from PEM representation (created by PEM_encode)
@@ -77,12 +77,12 @@ class BOTAN_DLL Session
* @warning if the master secret is compromised so is the
* session traffic
*/
- secure_vector<byte> DER_encode() const;
+ secure_vector<uint8_t> DER_encode() const;
/**
* Encrypt a session (useful for serialization or session tickets)
*/
- std::vector<byte> encrypt(const SymmetricKey& key,
+ std::vector<uint8_t> encrypt(const SymmetricKey& key,
RandomNumberGenerator& rng) const;
@@ -92,7 +92,7 @@ class BOTAN_DLL Session
* @param ctext_size the size of ctext in bytes
* @param key the same key used by the encrypting side
*/
- static Session decrypt(const byte ctext[],
+ static Session decrypt(const uint8_t ctext[],
size_t ctext_size,
const SymmetricKey& key);
@@ -101,7 +101,7 @@ class BOTAN_DLL Session
* @param ctext the ciphertext returned by encrypt
* @param key the same key used by the encrypting side
*/
- static inline Session decrypt(const std::vector<byte>& ctext,
+ static inline Session decrypt(const std::vector<uint8_t>& ctext,
const SymmetricKey& key)
{
return Session::decrypt(ctext.data(), ctext.size(), key);
@@ -122,7 +122,7 @@ class BOTAN_DLL Session
/**
* Get the ciphersuite code of the saved session
*/
- u16bit ciphersuite_code() const { return m_ciphersuite; }
+ uint16_t ciphersuite_code() const { return m_ciphersuite; }
/**
* Get the ciphersuite info of the saved session
@@ -132,7 +132,7 @@ class BOTAN_DLL Session
/**
* Get the compression method used in the saved session
*/
- byte compression_method() const { return m_compression_method; }
+ uint8_t compression_method() const { return m_compression_method; }
/**
* Get which side of the connection the resumed session we are/were
@@ -148,17 +148,17 @@ class BOTAN_DLL Session
/**
* Get the saved master secret
*/
- const secure_vector<byte>& master_secret() const { return m_master_secret; }
+ const secure_vector<uint8_t>& master_secret() const { return m_master_secret; }
/**
* Get the session identifier
*/
- const std::vector<byte>& session_id() const { return m_identifier; }
+ const std::vector<uint8_t>& session_id() const { return m_identifier; }
/**
* Get the negotiated DTLS-SRTP algorithm (RFC 5764)
*/
- u16bit dtls_srtp_profile() const { return m_srtp_profile; }
+ uint16_t dtls_srtp_profile() const { return m_srtp_profile; }
bool supports_extended_master_secret() const { return m_extended_master_secret; }
@@ -182,7 +182,7 @@ class BOTAN_DLL Session
/**
* Return the session ticket the server gave us
*/
- const std::vector<byte>& session_ticket() const { return m_session_ticket; }
+ const std::vector<uint8_t>& session_ticket() const { return m_session_ticket; }
/**
* @return information about the TLS server
@@ -194,15 +194,15 @@ class BOTAN_DLL Session
std::chrono::system_clock::time_point m_start_time;
- std::vector<byte> m_identifier;
- std::vector<byte> m_session_ticket; // only used by client side
- secure_vector<byte> m_master_secret;
+ std::vector<uint8_t> m_identifier;
+ std::vector<uint8_t> m_session_ticket; // only used by client side
+ secure_vector<uint8_t> m_master_secret;
Protocol_Version m_version;
- u16bit m_ciphersuite;
- byte m_compression_method;
+ uint16_t m_ciphersuite;
+ uint8_t m_compression_method;
Connection_Side m_connection_side;
- u16bit m_srtp_profile;
+ uint16_t m_srtp_profile;
bool m_extended_master_secret;
bool m_encrypt_then_mac;
diff --git a/src/lib/tls/tls_session_key.cpp b/src/lib/tls/tls_session_key.cpp
index 193af8d9f..d2aff858f 100644
--- a/src/lib/tls/tls_session_key.cpp
+++ b/src/lib/tls/tls_session_key.cpp
@@ -17,7 +17,7 @@ namespace TLS {
* Session_Keys Constructor
*/
Session_Keys::Session_Keys(const Handshake_State* state,
- const secure_vector<byte>& pre_master_secret,
+ const secure_vector<uint8_t>& pre_master_secret,
bool resuming)
{
const size_t cipher_keylen = state->ciphersuite().cipher_keylen();
@@ -28,14 +28,14 @@ Session_Keys::Session_Keys(const Handshake_State* state,
const size_t prf_gen = 2 * (mac_keylen + cipher_keylen + cipher_nonce_bytes);
- const byte MASTER_SECRET_MAGIC[] = {
+ const uint8_t MASTER_SECRET_MAGIC[] = {
0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74 };
- const byte EXT_MASTER_SECRET_MAGIC[] = {
+ const uint8_t EXT_MASTER_SECRET_MAGIC[] = {
0x65, 0x78, 0x74, 0x65, 0x6E, 0x64, 0x65, 0x64, 0x20,
0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74 };
- const byte KEY_GEN_MAGIC[] = {
+ const uint8_t KEY_GEN_MAGIC[] = {
0x6B, 0x65, 0x79, 0x20, 0x65, 0x78, 0x70, 0x61, 0x6E, 0x73, 0x69, 0x6F, 0x6E };
std::unique_ptr<KDF> prf(state->protocol_specific_prf());
@@ -47,8 +47,8 @@ Session_Keys::Session_Keys(const Handshake_State* state,
}
else
{
- secure_vector<byte> salt;
- secure_vector<byte> label;
+ secure_vector<uint8_t> salt;
+ secure_vector<uint8_t> label;
if(extended_master_secret)
{
label += std::make_pair(EXT_MASTER_SECRET_MAGIC, sizeof(EXT_MASTER_SECRET_MAGIC));
@@ -65,15 +65,15 @@ Session_Keys::Session_Keys(const Handshake_State* state,
m_master_sec = prf->derive_key(48, pre_master_secret, salt, label);
}
- secure_vector<byte> salt;
- secure_vector<byte> label;
+ secure_vector<uint8_t> salt;
+ secure_vector<uint8_t> label;
label += std::make_pair(KEY_GEN_MAGIC, sizeof(KEY_GEN_MAGIC));
salt += state->server_hello()->random();
salt += state->client_hello()->random();
SymmetricKey keyblock = prf->derive_key(prf_gen, m_master_sec, salt, label);
- const byte* key_data = keyblock.begin();
+ const uint8_t* key_data = keyblock.begin();
m_c_mac = SymmetricKey(key_data, mac_keylen);
key_data += mac_keylen;
diff --git a/src/lib/tls/tls_session_key.h b/src/lib/tls/tls_session_key.h
index 8399a9676..c2c082d4a 100644
--- a/src/lib/tls/tls_session_key.h
+++ b/src/lib/tls/tls_session_key.h
@@ -55,7 +55,7 @@ class Session_Keys
/**
* @return TLS master secret
*/
- const secure_vector<byte>& master_secret() const { return m_master_sec; }
+ const secure_vector<uint8_t>& master_secret() const { return m_master_sec; }
Session_Keys() {}
@@ -65,11 +65,11 @@ class Session_Keys
* @param resuming whether this TLS session is resumed
*/
Session_Keys(const Handshake_State* state,
- const secure_vector<byte>& pre_master_secret,
+ const secure_vector<uint8_t>& pre_master_secret,
bool resuming);
private:
- secure_vector<byte> m_master_sec;
+ secure_vector<uint8_t> m_master_sec;
SymmetricKey m_c_cipher, m_s_cipher, m_c_mac, m_s_mac;
InitializationVector m_c_iv, m_s_iv;
};
diff --git a/src/lib/tls/tls_session_manager.h b/src/lib/tls/tls_session_manager.h
index ca6712e1f..88b73c73a 100644
--- a/src/lib/tls/tls_session_manager.h
+++ b/src/lib/tls/tls_session_manager.h
@@ -36,7 +36,7 @@ class BOTAN_DLL Session_Manager
or not modified if not found
* @return true if session was modified
*/
- virtual bool load_from_session_id(const std::vector<byte>& session_id,
+ virtual bool load_from_session_id(const std::vector<uint8_t>& session_id,
Session& session) = 0;
/**
@@ -52,7 +52,7 @@ class BOTAN_DLL Session_Manager
/**
* Remove this session id from the cache, if it exists
*/
- virtual void remove_entry(const std::vector<byte>& session_id) = 0;
+ virtual void remove_entry(const std::vector<uint8_t>& session_id) = 0;
/**
* Remove all sessions from the cache, return number of sessions deleted
@@ -86,13 +86,13 @@ class BOTAN_DLL Session_Manager
class BOTAN_DLL Session_Manager_Noop : public Session_Manager
{
public:
- bool load_from_session_id(const std::vector<byte>&, Session&) override
+ bool load_from_session_id(const std::vector<uint8_t>&, Session&) override
{ return false; }
bool load_from_server_info(const Server_Information&, Session&) override
{ return false; }
- void remove_entry(const std::vector<byte>&) override {}
+ void remove_entry(const std::vector<uint8_t>&) override {}
size_t remove_all() override { return 0; }
@@ -121,13 +121,13 @@ class BOTAN_DLL Session_Manager_In_Memory : public Session_Manager
std::chrono::seconds session_lifetime =
std::chrono::seconds(7200));
- bool load_from_session_id(const std::vector<byte>& session_id,
+ bool load_from_session_id(const std::vector<uint8_t>& session_id,
Session& session) override;
bool load_from_server_info(const Server_Information& info,
Session& session) override;
- void remove_entry(const std::vector<byte>& session_id) override;
+ void remove_entry(const std::vector<uint8_t>& session_id) override;
size_t remove_all() override;
@@ -147,9 +147,9 @@ class BOTAN_DLL Session_Manager_In_Memory : public Session_Manager
std::chrono::seconds m_session_lifetime;
RandomNumberGenerator& m_rng;
- secure_vector<byte> m_session_key;
+ secure_vector<uint8_t> m_session_key;
- std::map<std::string, std::vector<byte>> m_sessions; // hex(session_id) -> session
+ std::map<std::string, std::vector<uint8_t>> m_sessions; // hex(session_id) -> session
std::map<Server_Information, std::string> m_info_sessions;
};
diff --git a/src/lib/tls/tls_session_manager_memory.cpp b/src/lib/tls/tls_session_manager_memory.cpp
index d0866b37a..f120a4290 100644
--- a/src/lib/tls/tls_session_manager_memory.cpp
+++ b/src/lib/tls/tls_session_manager_memory.cpp
@@ -55,7 +55,7 @@ bool Session_Manager_In_Memory::load_from_session_str(
}
bool Session_Manager_In_Memory::load_from_session_id(
- const std::vector<byte>& session_id, Session& session)
+ const std::vector<uint8_t>& session_id, Session& session)
{
lock_guard_type<mutex_type> lock(m_mutex);
@@ -85,7 +85,7 @@ bool Session_Manager_In_Memory::load_from_server_info(
}
void Session_Manager_In_Memory::remove_entry(
- const std::vector<byte>& session_id)
+ const std::vector<uint8_t>& session_id)
{
lock_guard_type<mutex_type> lock(m_mutex);
diff --git a/src/lib/tls/tls_version.cpp b/src/lib/tls/tls_version.cpp
index 37360b410..274cedc11 100644
--- a/src/lib/tls/tls_version.cpp
+++ b/src/lib/tls/tls_version.cpp
@@ -15,8 +15,8 @@ namespace TLS {
std::string Protocol_Version::to_string() const
{
- const byte maj = major_version();
- const byte min = minor_version();
+ const uint8_t maj = major_version();
+ const uint8_t min = minor_version();
if(maj == 3 && min == 0)
return "SSL v3";
diff --git a/src/lib/tls/tls_version.h b/src/lib/tls/tls_version.h
index 29839502d..f60297e8a 100644
--- a/src/lib/tls/tls_version.h
+++ b/src/lib/tls/tls_version.h
@@ -52,14 +52,14 @@ class BOTAN_DLL Protocol_Version
* @param named_version a specific named version of the protocol
*/
Protocol_Version(Version_Code named_version) :
- m_version(static_cast<u16bit>(named_version)) {}
+ m_version(static_cast<uint16_t>(named_version)) {}
/**
* @param major the major version
* @param minor the minor version
*/
- Protocol_Version(byte major, byte minor) :
- m_version((static_cast<u16bit>(major) << 8) | minor) {}
+ Protocol_Version(uint8_t major, uint8_t minor) :
+ m_version((static_cast<uint16_t>(major) << 8) | minor) {}
/**
* @return true if this is a valid protocol version
@@ -74,12 +74,12 @@ class BOTAN_DLL Protocol_Version
/**
* @return major version of the protocol version
*/
- byte major_version() const { return get_byte(0, m_version); }
+ uint8_t major_version() const { return get_byte(0, m_version); }
/**
* @return minor version of the protocol version
*/
- byte minor_version() const { return get_byte(1, m_version); }
+ uint8_t minor_version() const { return get_byte(1, m_version); }
/**
* @return human-readable description of this version
@@ -138,7 +138,7 @@ class BOTAN_DLL Protocol_Version
}
private:
- u16bit m_version;
+ uint16_t m_version;
};
}
diff --git a/src/lib/utils/bit_ops.h b/src/lib/utils/bit_ops.h
index 5e8821593..b7ee94125 100644
--- a/src/lib/utils/bit_ops.h
+++ b/src/lib/utils/bit_ops.h
@@ -79,7 +79,7 @@ inline size_t significant_bytes(T n)
template<typename T>
inline size_t hamming_weight(T n)
{
- const byte NIBBLE_WEIGHTS[] = {
+ const uint8_t NIBBLE_WEIGHTS[] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
size_t weight = 0;
diff --git a/src/lib/utils/bswap.h b/src/lib/utils/bswap.h
index beb3f9555..b55445f59 100644
--- a/src/lib/utils/bswap.h
+++ b/src/lib/utils/bswap.h
@@ -21,7 +21,7 @@ namespace Botan {
/**
* Swap a 16 bit integer
*/
-inline u16bit reverse_bytes(u16bit val)
+inline uint16_t reverse_bytes(uint16_t val)
{
return rotate_left(val, 8);
}
@@ -29,7 +29,7 @@ inline u16bit reverse_bytes(u16bit val)
/**
* Swap a 32 bit integer
*/
-inline u32bit reverse_bytes(u32bit val)
+inline uint32_t reverse_bytes(uint32_t val)
{
#if BOTAN_GCC_VERSION >= 430 && !defined(BOTAN_TARGET_ARCH_IS_ARM32)
/*
@@ -77,7 +77,7 @@ inline u32bit reverse_bytes(u32bit val)
/**
* Swap a 64 bit integer
*/
-inline u64bit reverse_bytes(u64bit val)
+inline uint64_t reverse_bytes(uint64_t val)
{
#if BOTAN_GCC_VERSION >= 430
@@ -95,13 +95,13 @@ inline u64bit reverse_bytes(u64bit val)
* useful for 32-bit x86).
*/
- u32bit hi = static_cast<u32bit>(val >> 32);
- u32bit lo = static_cast<u32bit>(val);
+ uint32_t hi = static_cast<uint32_t>(val >> 32);
+ uint32_t lo = static_cast<uint32_t>(val);
hi = reverse_bytes(hi);
lo = reverse_bytes(lo);
- return (static_cast<u64bit>(lo) << 32) | hi;
+ return (static_cast<uint64_t>(lo) << 32) | hi;
#endif
}
@@ -120,10 +120,10 @@ inline void bswap_4(T x[4])
#if defined(BOTAN_TARGET_CPU_HAS_SSE2) && !defined(BOTAN_NO_SSE_INTRINSICS)
/**
-* Swap 4 u32bits in an array using SSE2 shuffle instructions
+* Swap 4 uint32_ts in an array using SSE2 shuffle instructions
*/
template<>
-inline void bswap_4(u32bit x[4])
+inline void bswap_4(uint32_t x[4])
{
__m128i T = _mm_loadu_si128(reinterpret_cast<const __m128i*>(x));
diff --git a/src/lib/utils/calendar.h b/src/lib/utils/calendar.h
index a0b91f913..91da9edc0 100644
--- a/src/lib/utils/calendar.h
+++ b/src/lib/utils/calendar.h
@@ -21,24 +21,24 @@ namespace Botan {
struct BOTAN_DLL calendar_point
{
/** The year */
- u32bit year;
+ uint32_t year;
/** The month, 1 through 12 for Jan to Dec */
- u32bit month;
+ uint32_t month;
/** The day of the month, 1 through 31 (or 28 or 30 based on month */
- u32bit day;
+ uint32_t day;
/** Hour in 24-hour form, 0 to 23 */
- u32bit hour;
+ uint32_t hour;
/** Minutes in the hour, 0 to 60 */
- u32bit minutes;
+ uint32_t minutes;
/** Seconds in the minute, 0 to 60, but might be slightly
larger to deal with leap seconds on some systems
*/
- u32bit seconds;
+ uint32_t seconds;
/**
* Initialize a calendar_point
@@ -49,7 +49,7 @@ struct BOTAN_DLL calendar_point
* @param min the minute
* @param sec the second
*/
- calendar_point(u32bit y, u32bit mon, u32bit d, u32bit h, u32bit min, u32bit sec) :
+ calendar_point(uint32_t y, uint32_t mon, uint32_t d, uint32_t h, uint32_t min, uint32_t sec) :
year(y), month(mon), day(d), hour(h), minutes(min), seconds(sec) {}
/**
diff --git a/src/lib/utils/charset.cpp b/src/lib/utils/charset.cpp
index cb106d6e9..72db6c792 100644
--- a/src/lib/utils/charset.cpp
+++ b/src/lib/utils/charset.cpp
@@ -28,8 +28,8 @@ std::string ucs2_to_latin1(const std::string& ucs2)
for(size_t i = 0; i != ucs2.size(); i += 2)
{
- const byte c1 = ucs2[i];
- const byte c2 = ucs2[i+1];
+ const uint8_t c1 = ucs2[i];
+ const uint8_t c2 = ucs2[i+1];
if(c1 != 0)
throw Decoding_Error("UCS-2 has non-Latin1 characters");
@@ -50,7 +50,7 @@ std::string utf8_to_latin1(const std::string& utf8)
size_t position = 0;
while(position != utf8.size())
{
- const byte c1 = static_cast<byte>(utf8[position++]);
+ const uint8_t c1 = static_cast<uint8_t>(utf8[position++]);
if(c1 <= 0x7F)
iso8859 += static_cast<char>(c1);
@@ -59,8 +59,8 @@ std::string utf8_to_latin1(const std::string& utf8)
if(position == utf8.size())
throw Decoding_Error("UTF-8: sequence truncated");
- const byte c2 = static_cast<byte>(utf8[position++]);
- const byte iso_char = ((c1 & 0x07) << 6) | (c2 & 0x3F);
+ const uint8_t c2 = static_cast<uint8_t>(utf8[position++]);
+ const uint8_t iso_char = ((c1 & 0x07) << 6) | (c2 & 0x3F);
if(iso_char <= 0x7F)
throw Decoding_Error("UTF-8: sequence longer than needed");
@@ -82,7 +82,7 @@ std::string latin1_to_utf8(const std::string& iso8859)
std::string utf8;
for(size_t i = 0; i != iso8859.size(); ++i)
{
- const byte c = static_cast<byte>(iso8859[i]);
+ const uint8_t c = static_cast<uint8_t>(iso8859[i]);
if(c <= 0x7F)
utf8 += static_cast<char>(c);
@@ -146,7 +146,7 @@ bool is_space(char c)
/*
* Convert a character to a digit
*/
-byte char2digit(char c)
+uint8_t char2digit(char c)
{
switch(c)
{
@@ -168,7 +168,7 @@ byte char2digit(char c)
/*
* Convert a digit to a character
*/
-char digit2char(byte b)
+char digit2char(uint8_t b)
{
switch(b)
{
diff --git a/src/lib/utils/charset.h b/src/lib/utils/charset.h
index b708c886a..5ab28661a 100644
--- a/src/lib/utils/charset.h
+++ b/src/lib/utils/charset.h
@@ -36,8 +36,8 @@ bool BOTAN_DLL is_digit(char c);
bool BOTAN_DLL is_space(char c);
bool BOTAN_DLL caseless_cmp(char x, char y);
-byte BOTAN_DLL char2digit(char c);
-char BOTAN_DLL digit2char(byte b);
+uint8_t BOTAN_DLL char2digit(char c);
+char BOTAN_DLL digit2char(uint8_t b);
}
diff --git a/src/lib/utils/cpuid.cpp b/src/lib/utils/cpuid.cpp
index cb25ed09d..428ca2715 100644
--- a/src/lib/utils/cpuid.cpp
+++ b/src/lib/utils/cpuid.cpp
@@ -74,7 +74,7 @@
namespace Botan {
-u64bit CPUID::g_processor_flags[2] = { 0, 0 };
+uint64_t CPUID::g_processor_flags[2] = { 0, 0 };
size_t CPUID::g_cache_line_size = BOTAN_TARGET_CPU_DEFAULT_CACHE_LINE_SIZE;
bool CPUID::g_initialized = false;
bool CPUID::g_little_endian = false;
@@ -119,20 +119,20 @@ bool altivec_check_pvr_emul()
PearPC and Linux sources, mostly.
*/
- const u16bit PVR_G4_7400 = 0x000C;
- const u16bit PVR_G5_970 = 0x0039;
- const u16bit PVR_G5_970FX = 0x003C;
- const u16bit PVR_G5_970MP = 0x0044;
- const u16bit PVR_G5_970GX = 0x0045;
- const u16bit PVR_POWER6 = 0x003E;
- const u16bit PVR_POWER7 = 0x003F;
- const u16bit PVR_POWER8 = 0x004B;
- const u16bit PVR_CELL_PPU = 0x0070;
+ const uint16_t PVR_G4_7400 = 0x000C;
+ const uint16_t PVR_G5_970 = 0x0039;
+ const uint16_t PVR_G5_970FX = 0x003C;
+ const uint16_t PVR_G5_970MP = 0x0044;
+ const uint16_t PVR_G5_970GX = 0x0045;
+ const uint16_t PVR_POWER6 = 0x003E;
+ const uint16_t PVR_POWER7 = 0x003F;
+ const uint16_t PVR_POWER8 = 0x004B;
+ const uint16_t PVR_CELL_PPU = 0x0070;
// Motorola produced G4s with PVR 0x800[0123C] (at least)
- const u16bit PVR_G4_74xx_24 = 0x800;
+ const uint16_t PVR_G4_74xx_24 = 0x800;
- u32bit pvr = 0;
+ uint32_t pvr = 0;
asm volatile("mfspr %0, 287" : "=r" (pvr));
@@ -213,13 +213,13 @@ void CPUID::initialize()
#endif
#if defined(BOTAN_TARGET_CPU_IS_X86_FAMILY)
- const u32bit INTEL_CPUID[3] = { 0x756E6547, 0x6C65746E, 0x49656E69 };
- const u32bit AMD_CPUID[3] = { 0x68747541, 0x444D4163, 0x69746E65 };
+ const uint32_t INTEL_CPUID[3] = { 0x756E6547, 0x6C65746E, 0x49656E69 };
+ const uint32_t AMD_CPUID[3] = { 0x68747541, 0x444D4163, 0x69746E65 };
- u32bit cpuid[4] = { 0 };
+ uint32_t cpuid[4] = { 0 };
X86_CPUID(0, cpuid);
- const u32bit max_supported_sublevel = cpuid[0];
+ const uint32_t max_supported_sublevel = cpuid[0];
if(max_supported_sublevel == 0)
return;
@@ -229,7 +229,7 @@ void CPUID::initialize()
X86_CPUID(1, cpuid);
- g_processor_flags[0] = (static_cast<u64bit>(cpuid[2]) << 32) | cpuid[3];
+ g_processor_flags[0] = (static_cast<uint64_t>(cpuid[2]) << 32) | cpuid[3];
if(is_intel)
g_cache_line_size = 8 * get_byte(2, cpuid[1]);
@@ -238,7 +238,7 @@ void CPUID::initialize()
{
clear_mem(cpuid, 4);
X86_CPUID_SUBLEVEL(7, 0, cpuid);
- g_processor_flags[1] = (static_cast<u64bit>(cpuid[2]) << 32) | cpuid[1];
+ g_processor_flags[1] = (static_cast<uint64_t>(cpuid[2]) << 32) | cpuid[1];
}
if(is_amd)
diff --git a/src/lib/utils/cpuid.h b/src/lib/utils/cpuid.h
index aa7bae963..634305aa1 100644
--- a/src/lib/utils/cpuid.h
+++ b/src/lib/utils/cpuid.h
@@ -195,7 +195,7 @@ class BOTAN_DLL CPUID
static bool g_initialized;
static bool g_little_endian;
static size_t g_cache_line_size;
- static u64bit g_processor_flags[2];
+ static uint64_t g_processor_flags[2];
};
}
diff --git a/src/lib/utils/ct_utils.h b/src/lib/utils/ct_utils.h
index 1f095ba88..68bd01c94 100644
--- a/src/lib/utils/ct_utils.h
+++ b/src/lib/utils/ct_utils.h
@@ -195,10 +195,10 @@ inline secure_vector<uint8_t> strip_leading_zeros(const uint8_t in[], size_t len
leading_zeros += CT::select<uint8_t>(only_zeros, 1, 0);
}
- return secure_vector<byte>(in + leading_zeros, in + length);
+ return secure_vector<uint8_t>(in + leading_zeros, in + length);
}
-inline secure_vector<byte> strip_leading_zeros(const secure_vector<uint8_t>& in)
+inline secure_vector<uint8_t> strip_leading_zeros(const secure_vector<uint8_t>& in)
{
return strip_leading_zeros(in.data(), in.size());
}
diff --git a/src/lib/utils/data_src.cpp b/src/lib/utils/data_src.cpp
index 7da94d7c0..169f8e186 100644
--- a/src/lib/utils/data_src.cpp
+++ b/src/lib/utils/data_src.cpp
@@ -19,7 +19,7 @@ namespace Botan {
/*
* Read a single byte from the DataSource
*/
-size_t DataSource::read_byte(byte& out)
+size_t DataSource::read_byte(uint8_t& out)
{
return read(&out, 1);
}
@@ -27,7 +27,7 @@ size_t DataSource::read_byte(byte& out)
/*
* Peek a single byte from the DataSource
*/
-size_t DataSource::peek_byte(byte& out) const
+size_t DataSource::peek_byte(uint8_t& out) const
{
return peek(&out, 1, 0);
}
@@ -37,7 +37,7 @@ size_t DataSource::peek_byte(byte& out) const
*/
size_t DataSource::discard_next(size_t n)
{
- byte buf[64] = { 0 };
+ uint8_t buf[64] = { 0 };
size_t discarded = 0;
while(n)
@@ -56,7 +56,7 @@ size_t DataSource::discard_next(size_t n)
/*
* Read from a memory buffer
*/
-size_t DataSource_Memory::read(byte out[], size_t length)
+size_t DataSource_Memory::read(uint8_t out[], size_t length)
{
size_t got = std::min<size_t>(m_source.size() - m_offset, length);
copy_mem(out, m_source.data() + m_offset, got);
@@ -72,7 +72,7 @@ bool DataSource_Memory::check_available(size_t n)
/*
* Peek into a memory buffer
*/
-size_t DataSource_Memory::peek(byte out[], size_t length,
+size_t DataSource_Memory::peek(uint8_t out[], size_t length,
size_t peek_offset) const
{
const size_t bytes_left = m_source.size() - m_offset;
@@ -95,8 +95,8 @@ bool DataSource_Memory::end_of_data() const
* DataSource_Memory Constructor
*/
DataSource_Memory::DataSource_Memory(const std::string& in) :
- m_source(reinterpret_cast<const byte*>(in.data()),
- reinterpret_cast<const byte*>(in.data()) + in.length()),
+ m_source(reinterpret_cast<const uint8_t*>(in.data()),
+ reinterpret_cast<const uint8_t*>(in.data()) + in.length()),
m_offset(0)
{
}
@@ -106,7 +106,7 @@ DataSource_Memory::DataSource_Memory(const std::string& in) :
/*
* Read from a stream
*/
-size_t DataSource_Stream::read(byte out[], size_t length)
+size_t DataSource_Stream::read(uint8_t out[], size_t length)
{
m_source.read(reinterpret_cast<char*>(out), length);
if(m_source.bad())
@@ -129,7 +129,7 @@ bool DataSource_Stream::check_available(size_t n)
/*
* Peek into a stream
*/
-size_t DataSource_Stream::peek(byte out[], size_t length, size_t offset) const
+size_t DataSource_Stream::peek(uint8_t out[], size_t length, size_t offset) const
{
if(end_of_data())
throw Invalid_State("DataSource_Stream: Cannot peek when out of data");
@@ -138,7 +138,7 @@ size_t DataSource_Stream::peek(byte out[], size_t length, size_t offset) const
if(offset)
{
- secure_vector<byte> buf(offset);
+ secure_vector<uint8_t> buf(offset);
m_source.read(reinterpret_cast<char*>(buf.data()), buf.size());
if(m_source.bad())
throw Stream_IO_Error("DataSource_Stream::peek: Source failure");
diff --git a/src/lib/utils/data_src.h b/src/lib/utils/data_src.h
index 299a42ab5..ea28b7602 100644
--- a/src/lib/utils/data_src.h
+++ b/src/lib/utils/data_src.h
@@ -30,7 +30,7 @@ class BOTAN_DLL DataSource
* @return length in bytes that was actually read and put
* into out
*/
- virtual size_t read(byte out[], size_t length) BOTAN_WARN_UNUSED_RESULT = 0;
+ virtual size_t read(uint8_t out[], size_t length) BOTAN_WARN_UNUSED_RESULT = 0;
virtual bool check_available(size_t n) = 0;
@@ -45,7 +45,7 @@ class BOTAN_DLL DataSource
* @return length in bytes that was actually read and put
* into out
*/
- virtual size_t peek(byte out[], size_t length, size_t peek_offset) const BOTAN_WARN_UNUSED_RESULT = 0;
+ virtual size_t peek(uint8_t out[], size_t length, size_t peek_offset) const BOTAN_WARN_UNUSED_RESULT = 0;
/**
* Test whether the source still has data that can be read.
@@ -64,7 +64,7 @@ class BOTAN_DLL DataSource
* @return length in bytes that was actually read and put
* into out
*/
- size_t read_byte(byte& out);
+ size_t read_byte(uint8_t& out);
/**
* Peek at one byte.
@@ -72,7 +72,7 @@ class BOTAN_DLL DataSource
* @return length in bytes that was actually read and put
* into out
*/
- size_t peek_byte(byte& out) const;
+ size_t peek_byte(uint8_t& out) const;
/**
* Discard the next N bytes of the data
@@ -98,8 +98,8 @@ class BOTAN_DLL DataSource
class BOTAN_DLL DataSource_Memory : public DataSource
{
public:
- size_t read(byte[], size_t) override;
- size_t peek(byte[], size_t, size_t) const override;
+ size_t read(uint8_t[], size_t) override;
+ size_t peek(uint8_t[], size_t, size_t) const override;
bool check_available(size_t n) override;
bool end_of_data() const override;
@@ -114,26 +114,26 @@ class BOTAN_DLL DataSource_Memory : public DataSource
* @param in the byte array to read from
* @param length the length of the byte array
*/
- DataSource_Memory(const byte in[], size_t length) :
+ DataSource_Memory(const uint8_t in[], size_t length) :
m_source(in, in + length), m_offset(0) {}
/**
* Construct a memory source that reads from a secure_vector
* @param in the MemoryRegion to read from
*/
- explicit DataSource_Memory(const secure_vector<byte>& in) :
+ explicit DataSource_Memory(const secure_vector<uint8_t>& in) :
m_source(in), m_offset(0) {}
/**
* Construct a memory source that reads from a std::vector
* @param in the MemoryRegion to read from
*/
- explicit DataSource_Memory(const std::vector<byte>& in) :
+ explicit DataSource_Memory(const std::vector<uint8_t>& in) :
m_source(in.begin(), in.end()), m_offset(0) {}
size_t get_bytes_read() const override { return m_offset; }
private:
- secure_vector<byte> m_source;
+ secure_vector<uint8_t> m_source;
size_t m_offset;
};
@@ -145,8 +145,8 @@ class BOTAN_DLL DataSource_Memory : public DataSource
class BOTAN_DLL DataSource_Stream : public DataSource
{
public:
- size_t read(byte[], size_t) override;
- size_t peek(byte[], size_t, size_t) const override;
+ size_t read(uint8_t[], size_t) override;
+ size_t peek(uint8_t[], size_t, size_t) const override;
bool check_available(size_t n) override;
bool end_of_data() const override;
std::string id() const override;
diff --git a/src/lib/utils/database.h b/src/lib/utils/database.h
index 0cd45dac0..6a1fa6b02 100644
--- a/src/lib/utils/database.h
+++ b/src/lib/utils/database.h
@@ -36,12 +36,12 @@ class BOTAN_DLL SQL_Database
virtual void bind(int column, std::chrono::system_clock::time_point time) = 0;
- virtual void bind(int column, const std::vector<byte>& blob) = 0;
+ virtual void bind(int column, const std::vector<uint8_t>& blob) = 0;
- virtual void bind(int column, const byte* data, size_t len) = 0;
+ virtual void bind(int column, const uint8_t* data, size_t len) = 0;
/* Get output */
- virtual std::pair<const byte*, size_t> get_blob(int column) = 0;
+ virtual std::pair<const uint8_t*, size_t> get_blob(int column) = 0;
virtual size_t get_size_t(int column) = 0;
diff --git a/src/lib/utils/datastor/datastor.cpp b/src/lib/utils/datastor/datastor.cpp
index 6f1b71082..ae6b1e45c 100644
--- a/src/lib/utils/datastor/datastor.cpp
+++ b/src/lib/utils/datastor/datastor.cpp
@@ -88,13 +88,13 @@ std::string Data_Store::get1(const std::string& key,
/*
* Get a single std::vector atom
*/
-std::vector<byte>
+std::vector<uint8_t>
Data_Store::get1_memvec(const std::string& key) const
{
std::vector<std::string> vals = get(key);
if(vals.empty())
- return std::vector<byte>();
+ return std::vector<uint8_t>();
if(vals.size() > 1)
throw Invalid_State("Data_Store::get1_memvec: Multiple values for " +
@@ -104,18 +104,17 @@ Data_Store::get1_memvec(const std::string& key) const
}
/*
-* Get a single u32bit atom
+* Get a single uint32_t atom
*/
-u32bit Data_Store::get1_u32bit(const std::string& key,
- u32bit default_val) const
+uint32_t Data_Store::get1_uint32(const std::string& key,
+ uint32_t default_val) const
{
std::vector<std::string> vals = get(key);
if(vals.empty())
return default_val;
else if(vals.size() > 1)
- throw Invalid_State("Data_Store::get1_u32bit: Multiple values for " +
- key);
+ throw Invalid_State("Data_Store::get1_uint32: Multiple values for " + key);
return to_u32bit(vals[0]);
}
@@ -131,7 +130,7 @@ void Data_Store::add(const std::string& key, const std::string& val)
/*
* Insert a single key and value
*/
-void Data_Store::add(const std::string& key, u32bit val)
+void Data_Store::add(const std::string& key, uint32_t val)
{
add(key, std::to_string(val));
}
@@ -139,12 +138,12 @@ void Data_Store::add(const std::string& key, u32bit val)
/*
* Insert a single key and value
*/
-void Data_Store::add(const std::string& key, const secure_vector<byte>& val)
+void Data_Store::add(const std::string& key, const secure_vector<uint8_t>& val)
{
add(key, hex_encode(val.data(), val.size()));
}
-void Data_Store::add(const std::string& key, const std::vector<byte>& val)
+void Data_Store::add(const std::string& key, const std::vector<uint8_t>& val)
{
add(key, hex_encode(val.data(), val.size()));
}
diff --git a/src/lib/utils/datastor/datastor.h b/src/lib/utils/datastor/datastor.h
index 3b25e1fe4..ee9ef219a 100644
--- a/src/lib/utils/datastor/datastor.h
+++ b/src/lib/utils/datastor/datastor.h
@@ -38,16 +38,16 @@ class BOTAN_DLL Data_Store
std::string get1(const std::string& key,
const std::string& default_value) const;
- std::vector<byte> get1_memvec(const std::string&) const;
- u32bit get1_u32bit(const std::string&, u32bit = 0) const;
+ std::vector<uint8_t> get1_memvec(const std::string&) const;
+ uint32_t get1_uint32(const std::string&, uint32_t = 0) const;
bool has_value(const std::string&) const;
void add(const std::multimap<std::string, std::string>&);
void add(const std::string&, const std::string&);
- void add(const std::string&, u32bit);
- void add(const std::string&, const secure_vector<byte>&);
- void add(const std::string&, const std::vector<byte>&);
+ void add(const std::string&, uint32_t);
+ void add(const std::string&, const secure_vector<uint8_t>&);
+ void add(const std::string&, const std::vector<uint8_t>&);
private:
std::multimap<std::string, std::string> m_contents;
};
diff --git a/src/lib/utils/donna128.h b/src/lib/utils/donna128.h
index 2a2d1e339..3e11f71c2 100644
--- a/src/lib/utils/donna128.h
+++ b/src/lib/utils/donna128.h
@@ -15,7 +15,7 @@ namespace Botan {
class donna128
{
public:
- donna128(u64bit ll = 0, u64bit hh = 0) { l = ll; h = hh; }
+ donna128(uint64_t ll = 0, uint64_t hh = 0) { l = ll; h = hh; }
donna128(const donna128&) = default;
donna128& operator=(const donna128&) = default;
@@ -25,7 +25,7 @@ class donna128
donna128 z = x;
if(shift > 0)
{
- const u64bit carry = z.h << (64 - shift);
+ const uint64_t carry = z.h << (64 - shift);
z.h = (z.h >> shift);
z.l = (z.l >> shift) | carry;
}
@@ -37,19 +37,19 @@ class donna128
donna128 z = x;
if(shift > 0)
{
- const u64bit carry = z.l >> (64 - shift);
+ const uint64_t carry = z.l >> (64 - shift);
z.l = (z.l << shift);
z.h = (z.h << shift) | carry;
}
return z;
}
- friend u64bit operator&(const donna128& x, u64bit mask)
+ friend uint64_t operator&(const donna128& x, uint64_t mask)
{
return x.l & mask;
}
- u64bit operator&=(u64bit mask)
+ uint64_t operator&=(uint64_t mask)
{
h = 0;
l &= mask;
@@ -64,24 +64,24 @@ class donna128
return *this;
}
- donna128& operator+=(u64bit x)
+ donna128& operator+=(uint64_t x)
{
l += x;
h += (l < x);
return *this;
}
- u64bit lo() const { return l; }
- u64bit hi() const { return h; }
+ uint64_t lo() const { return l; }
+ uint64_t hi() const { return h; }
private:
- u64bit h = 0, l = 0;
+ uint64_t h = 0, l = 0;
};
-inline donna128 operator*(const donna128& x, u64bit y)
+inline donna128 operator*(const donna128& x, uint64_t y)
{
BOTAN_ASSERT(x.hi() == 0, "High 64 bits of donna128 set to zero during multiply");
- u64bit lo = 0, hi = 0;
+ uint64_t lo = 0, hi = 0;
mul64x64_128(x.lo(), y, &lo, &hi);
return donna128(lo, hi);
}
@@ -93,7 +93,7 @@ inline donna128 operator+(const donna128& x, const donna128& y)
return z;
}
-inline donna128 operator+(const donna128& x, u64bit y)
+inline donna128 operator+(const donna128& x, uint64_t y)
{
donna128 z = x;
z += y;
@@ -105,12 +105,12 @@ inline donna128 operator|(const donna128& x, const donna128& y)
return donna128(x.lo() | y.lo(), x.hi() | y.hi());
}
-inline u64bit carry_shift(const donna128& a, size_t shift)
+inline uint64_t carry_shift(const donna128& a, size_t shift)
{
return (a >> shift).lo();
}
-inline u64bit combine_lower(const donna128& a, size_t s1,
+inline uint64_t combine_lower(const donna128& a, size_t s1,
const donna128& b, size_t s2)
{
donna128 z = (a >> s1) | (b << s2);
@@ -118,15 +118,15 @@ inline u64bit combine_lower(const donna128& a, size_t s1,
}
#if defined(BOTAN_TARGET_HAS_NATIVE_UINT128)
-inline u64bit carry_shift(const uint128_t a, size_t shift)
+inline uint64_t carry_shift(const uint128_t a, size_t shift)
{
- return static_cast<u64bit>(a >> shift);
+ return static_cast<uint64_t>(a >> shift);
}
-inline u64bit combine_lower(const uint128_t a, size_t s1,
+inline uint64_t combine_lower(const uint128_t a, size_t s1,
const uint128_t b, size_t s2)
{
- return static_cast<u64bit>((a >> s1) | (b << s2));
+ return static_cast<uint64_t>((a >> s1) | (b << s2));
}
#endif
diff --git a/src/lib/utils/http_util/http_util.cpp b/src/lib/utils/http_util/http_util.cpp
index c699b786f..f714c1bca 100644
--- a/src/lib/utils/http_util/http_util.cpp
+++ b/src/lib/utils/http_util/http_util.cpp
@@ -146,7 +146,7 @@ std::string url_encode(const std::string& in)
else if(c == '-' || c == '_' || c == '.' || c == '~')
out << c;
else
- out << '%' << hex_encode(reinterpret_cast<byte*>(&c), 1);
+ out << '%' << hex_encode(reinterpret_cast<uint8_t*>(&c), 1);
}
return out.str();
@@ -166,7 +166,7 @@ Response http_sync(http_exch_fn http_transact,
const std::string& verb,
const std::string& url,
const std::string& content_type,
- const std::vector<byte>& body,
+ const std::vector<uint8_t>& body,
size_t allowable_redirects)
{
if(url.empty())
@@ -251,8 +251,8 @@ Response http_sync(http_exch_fn http_transact,
return GET_sync(headers["Location"], allowable_redirects - 1);
}
- std::vector<byte> resp_body;
- std::vector<byte> buf(4096);
+ std::vector<uint8_t> resp_body;
+ std::vector<uint8_t> buf(4096);
while(io.good())
{
io.read(reinterpret_cast<char*>(buf.data()), buf.size());
@@ -274,7 +274,7 @@ Response http_sync(http_exch_fn http_transact,
Response http_sync(const std::string& verb,
const std::string& url,
const std::string& content_type,
- const std::vector<byte>& body,
+ const std::vector<uint8_t>& body,
size_t allowable_redirects)
{
return http_sync(
@@ -288,12 +288,12 @@ Response http_sync(const std::string& verb,
Response GET_sync(const std::string& url, size_t allowable_redirects)
{
- return http_sync("GET", url, "", std::vector<byte>(), allowable_redirects);
+ return http_sync("GET", url, "", std::vector<uint8_t>(), allowable_redirects);
}
Response POST_sync(const std::string& url,
const std::string& content_type,
- const std::vector<byte>& body,
+ const std::vector<uint8_t>& body,
size_t allowable_redirects)
{
return http_sync("POST", url, content_type, body, allowable_redirects);
diff --git a/src/lib/utils/http_util/http_util.h b/src/lib/utils/http_util/http_util.h
index 1b4da3d2c..c1cef4542 100644
--- a/src/lib/utils/http_util/http_util.h
+++ b/src/lib/utils/http_util/http_util.h
@@ -25,7 +25,7 @@ struct Response
Response() : m_status_code(0), m_status_message("Uninitialized") {}
Response(unsigned int status_code, const std::string& status_message,
- const std::vector<byte>& body,
+ const std::vector<uint8_t>& body,
const std::map<std::string, std::string>& headers) :
m_status_code(status_code),
m_status_message(status_message),
@@ -34,7 +34,7 @@ struct Response
unsigned int status_code() const { return m_status_code; }
- const std::vector<byte>& body() const { return m_body; }
+ const std::vector<uint8_t>& body() const { return m_body; }
const std::map<std::string, std::string>& headers() const { return m_headers; }
@@ -49,7 +49,7 @@ struct Response
private:
unsigned int m_status_code;
std::string m_status_message;
- std::vector<byte> m_body;
+ std::vector<uint8_t> m_body;
std::map<std::string, std::string> m_headers;
};
@@ -71,13 +71,13 @@ BOTAN_DLL Response http_sync(http_exch_fn fn,
const std::string& verb,
const std::string& url,
const std::string& content_type,
- const std::vector<byte>& body,
+ const std::vector<uint8_t>& body,
size_t allowable_redirects);
BOTAN_DLL Response http_sync(const std::string& verb,
const std::string& url,
const std::string& content_type,
- const std::vector<byte>& body,
+ const std::vector<uint8_t>& body,
size_t allowable_redirects);
BOTAN_DLL Response GET_sync(const std::string& url,
@@ -85,7 +85,7 @@ BOTAN_DLL Response GET_sync(const std::string& url,
BOTAN_DLL Response POST_sync(const std::string& url,
const std::string& content_type,
- const std::vector<byte>& body,
+ const std::vector<uint8_t>& body,
size_t allowable_redirects = 1);
BOTAN_DLL std::string url_encode(const std::string& url);
diff --git a/src/lib/utils/loadstor.h b/src/lib/utils/loadstor.h
index 15ff6a708..c8368fbea 100644
--- a/src/lib/utils/loadstor.h
+++ b/src/lib/utils/loadstor.h
@@ -44,42 +44,42 @@ namespace Botan {
* @param input the value to extract from
* @return byte byte_num of input
*/
-template<typename T> inline byte get_byte(size_t byte_num, T input)
+template<typename T> inline uint8_t get_byte(size_t byte_num, T input)
{
- return static_cast<byte>(
+ return static_cast<uint8_t>(
input >> (((~byte_num)&(sizeof(T)-1)) << 3)
);
}
/**
-* Make a u16bit from two bytes
+* Make a uint16_t from two bytes
* @param i0 the first byte
* @param i1 the second byte
* @return i0 || i1
*/
-inline u16bit make_u16bit(byte i0, byte i1)
+inline uint16_t make_uint16(uint8_t i0, uint8_t i1)
{
- return ((static_cast<u16bit>(i0) << 8) | i1);
+ return ((static_cast<uint16_t>(i0) << 8) | i1);
}
/**
-* Make a u32bit from four bytes
+* Make a uint32_t from four bytes
* @param i0 the first byte
* @param i1 the second byte
* @param i2 the third byte
* @param i3 the fourth byte
* @return i0 || i1 || i2 || i3
*/
-inline u32bit make_u32bit(byte i0, byte i1, byte i2, byte i3)
+inline uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3)
{
- return ((static_cast<u32bit>(i0) << 24) |
- (static_cast<u32bit>(i1) << 16) |
- (static_cast<u32bit>(i2) << 8) |
- (static_cast<u32bit>(i3)));
+ return ((static_cast<uint32_t>(i0) << 24) |
+ (static_cast<uint32_t>(i1) << 16) |
+ (static_cast<uint32_t>(i2) << 8) |
+ (static_cast<uint32_t>(i3)));
}
/**
-* Make a u32bit from eight bytes
+* Make a uint32_t from eight bytes
* @param i0 the first byte
* @param i1 the second byte
* @param i2 the third byte
@@ -90,17 +90,17 @@ inline u32bit make_u32bit(byte i0, byte i1, byte i2, byte i3)
* @param i7 the eighth byte
* @return i0 || i1 || i2 || i3 || i4 || i5 || i6 || i7
*/
-inline u64bit make_u64bit(byte i0, byte i1, byte i2, byte i3,
- byte i4, byte i5, byte i6, byte i7)
+inline uint64_t make_uint64(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3,
+ uint8_t i4, uint8_t i5, uint8_t i6, uint8_t i7)
{
- return ((static_cast<u64bit>(i0) << 56) |
- (static_cast<u64bit>(i1) << 48) |
- (static_cast<u64bit>(i2) << 40) |
- (static_cast<u64bit>(i3) << 32) |
- (static_cast<u64bit>(i4) << 24) |
- (static_cast<u64bit>(i5) << 16) |
- (static_cast<u64bit>(i6) << 8) |
- (static_cast<u64bit>(i7)));
+ return ((static_cast<uint64_t>(i0) << 56) |
+ (static_cast<uint64_t>(i1) << 48) |
+ (static_cast<uint64_t>(i2) << 40) |
+ (static_cast<uint64_t>(i3) << 32) |
+ (static_cast<uint64_t>(i4) << 24) |
+ (static_cast<uint64_t>(i5) << 16) |
+ (static_cast<uint64_t>(i6) << 8) |
+ (static_cast<uint64_t>(i7)));
}
/**
@@ -110,7 +110,7 @@ inline u64bit make_u64bit(byte i0, byte i1, byte i2, byte i3,
* @return off'th T of in, as a big-endian value
*/
template<typename T>
-inline T load_be(const byte in[], size_t off)
+inline T load_be(const uint8_t in[], size_t off)
{
in += off * sizeof(T);
T out = 0;
@@ -126,7 +126,7 @@ inline T load_be(const byte in[], size_t off)
* @return off'th T of in, as a litte-endian value
*/
template<typename T>
-inline T load_le(const byte in[], size_t off)
+inline T load_le(const uint8_t in[], size_t off)
{
in += off * sizeof(T);
T out = 0;
@@ -136,119 +136,119 @@ inline T load_le(const byte in[], size_t off)
}
/**
-* Load a big-endian u16bit
+* Load a big-endian uint16_t
* @param in a pointer to some bytes
* @param off an offset into the array
-* @return off'th u16bit of in, as a big-endian value
+* @return off'th uint16_t of in, as a big-endian value
*/
template<>
-inline u16bit load_be<u16bit>(const byte in[], size_t off)
+inline uint16_t load_be<uint16_t>(const uint8_t in[], size_t off)
{
- in += off * sizeof(u16bit);
+ in += off * sizeof(uint16_t);
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u16bit x;
+ uint16_t x;
std::memcpy(&x, in, sizeof(x));
return BOTAN_ENDIAN_N2B(x);
#else
- return make_u16bit(in[0], in[1]);
+ return make_uint16(in[0], in[1]);
#endif
}
/**
-* Load a little-endian u16bit
+* Load a little-endian uint16_t
* @param in a pointer to some bytes
* @param off an offset into the array
-* @return off'th u16bit of in, as a little-endian value
+* @return off'th uint16_t of in, as a little-endian value
*/
template<>
-inline u16bit load_le<u16bit>(const byte in[], size_t off)
+inline uint16_t load_le<uint16_t>(const uint8_t in[], size_t off)
{
- in += off * sizeof(u16bit);
+ in += off * sizeof(uint16_t);
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u16bit x;
+ uint16_t x;
std::memcpy(&x, in, sizeof(x));
return BOTAN_ENDIAN_N2L(x);
#else
- return make_u16bit(in[1], in[0]);
+ return make_uint16(in[1], in[0]);
#endif
}
/**
-* Load a big-endian u32bit
+* Load a big-endian uint32_t
* @param in a pointer to some bytes
* @param off an offset into the array
-* @return off'th u32bit of in, as a big-endian value
+* @return off'th uint32_t of in, as a big-endian value
*/
template<>
-inline u32bit load_be<u32bit>(const byte in[], size_t off)
+inline uint32_t load_be<uint32_t>(const uint8_t in[], size_t off)
{
- in += off * sizeof(u32bit);
+ in += off * sizeof(uint32_t);
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u32bit x;
+ uint32_t x;
std::memcpy(&x, in, sizeof(x));
return BOTAN_ENDIAN_N2B(x);
#else
- return make_u32bit(in[0], in[1], in[2], in[3]);
+ return make_uint32(in[0], in[1], in[2], in[3]);
#endif
}
/**
-* Load a little-endian u32bit
+* Load a little-endian uint32_t
* @param in a pointer to some bytes
* @param off an offset into the array
-* @return off'th u32bit of in, as a little-endian value
+* @return off'th uint32_t of in, as a little-endian value
*/
template<>
-inline u32bit load_le<u32bit>(const byte in[], size_t off)
+inline uint32_t load_le<uint32_t>(const uint8_t in[], size_t off)
{
- in += off * sizeof(u32bit);
+ in += off * sizeof(uint32_t);
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u32bit x;
+ uint32_t x;
std::memcpy(&x, in, sizeof(x));
return BOTAN_ENDIAN_N2L(x);
#else
- return make_u32bit(in[3], in[2], in[1], in[0]);
+ return make_uint32(in[3], in[2], in[1], in[0]);
#endif
}
/**
-* Load a big-endian u64bit
+* Load a big-endian uint64_t
* @param in a pointer to some bytes
* @param off an offset into the array
-* @return off'th u64bit of in, as a big-endian value
+* @return off'th uint64_t of in, as a big-endian value
*/
template<>
-inline u64bit load_be<u64bit>(const byte in[], size_t off)
+inline uint64_t load_be<uint64_t>(const uint8_t in[], size_t off)
{
- in += off * sizeof(u64bit);
+ in += off * sizeof(uint64_t);
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u64bit x;
+ uint64_t x;
std::memcpy(&x, in, sizeof(x));
return BOTAN_ENDIAN_N2B(x);
#else
- return make_u64bit(in[0], in[1], in[2], in[3],
+ return make_uint64(in[0], in[1], in[2], in[3],
in[4], in[5], in[6], in[7]);
#endif
}
/**
-* Load a little-endian u64bit
+* Load a little-endian uint64_t
* @param in a pointer to some bytes
* @param off an offset into the array
-* @return off'th u64bit of in, as a little-endian value
+* @return off'th uint64_t of in, as a little-endian value
*/
template<>
-inline u64bit load_le<u64bit>(const byte in[], size_t off)
+inline uint64_t load_le<uint64_t>(const uint8_t in[], size_t off)
{
- in += off * sizeof(u64bit);
+ in += off * sizeof(uint64_t);
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u64bit x;
+ uint64_t x;
std::memcpy(&x, in, sizeof(x));
return BOTAN_ENDIAN_N2L(x);
#else
- return make_u64bit(in[7], in[6], in[5], in[4],
+ return make_uint64(in[7], in[6], in[5], in[4],
in[3], in[2], in[1], in[0]);
#endif
}
@@ -260,7 +260,7 @@ inline u64bit load_le<u64bit>(const byte in[], size_t off)
* @param x1 where the second word will be written
*/
template<typename T>
-inline void load_le(const byte in[], T& x0, T& x1)
+inline void load_le(const uint8_t in[], T& x0, T& x1)
{
x0 = load_le<T>(in, 0);
x1 = load_le<T>(in, 1);
@@ -275,7 +275,7 @@ inline void load_le(const byte in[], T& x0, T& x1)
* @param x3 where the fourth word will be written
*/
template<typename T>
-inline void load_le(const byte in[],
+inline void load_le(const uint8_t in[],
T& x0, T& x1, T& x2, T& x3)
{
x0 = load_le<T>(in, 0);
@@ -297,7 +297,7 @@ inline void load_le(const byte in[],
* @param x7 where the eighth word will be written
*/
template<typename T>
-inline void load_le(const byte in[],
+inline void load_le(const uint8_t in[],
T& x0, T& x1, T& x2, T& x3,
T& x4, T& x5, T& x6, T& x7)
{
@@ -319,7 +319,7 @@ inline void load_le(const byte in[],
*/
template<typename T>
inline void load_le(T out[],
- const byte in[],
+ const uint8_t in[],
size_t count)
{
if(count > 0)
@@ -350,7 +350,7 @@ inline void load_le(T out[],
* @param x1 where the second word will be written
*/
template<typename T>
-inline void load_be(const byte in[], T& x0, T& x1)
+inline void load_be(const uint8_t in[], T& x0, T& x1)
{
x0 = load_be<T>(in, 0);
x1 = load_be<T>(in, 1);
@@ -365,7 +365,7 @@ inline void load_be(const byte in[], T& x0, T& x1)
* @param x3 where the fourth word will be written
*/
template<typename T>
-inline void load_be(const byte in[],
+inline void load_be(const uint8_t in[],
T& x0, T& x1, T& x2, T& x3)
{
x0 = load_be<T>(in, 0);
@@ -387,7 +387,7 @@ inline void load_be(const byte in[],
* @param x7 where the eighth word will be written
*/
template<typename T>
-inline void load_be(const byte in[],
+inline void load_be(const uint8_t in[],
T& x0, T& x1, T& x2, T& x3,
T& x4, T& x5, T& x6, T& x7)
{
@@ -409,7 +409,7 @@ inline void load_be(const byte in[],
*/
template<typename T>
inline void load_be(T out[],
- const byte in[],
+ const uint8_t in[],
size_t count)
{
if(count > 0)
@@ -434,14 +434,14 @@ inline void load_be(T out[],
}
/**
-* Store a big-endian u16bit
-* @param in the input u16bit
+* Store a big-endian uint16_t
+* @param in the input uint16_t
* @param out the byte array to write to
*/
-inline void store_be(u16bit in, byte out[2])
+inline void store_be(uint16_t in, uint8_t out[2])
{
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u16bit o = BOTAN_ENDIAN_N2B(in);
+ uint16_t o = BOTAN_ENDIAN_N2B(in);
std::memcpy(out, &o, sizeof(o));
#else
out[0] = get_byte(0, in);
@@ -450,14 +450,14 @@ inline void store_be(u16bit in, byte out[2])
}
/**
-* Store a little-endian u16bit
-* @param in the input u16bit
+* Store a little-endian uint16_t
+* @param in the input uint16_t
* @param out the byte array to write to
*/
-inline void store_le(u16bit in, byte out[2])
+inline void store_le(uint16_t in, uint8_t out[2])
{
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u16bit o = BOTAN_ENDIAN_N2L(in);
+ uint16_t o = BOTAN_ENDIAN_N2L(in);
std::memcpy(out, &o, sizeof(o));
#else
out[0] = get_byte(1, in);
@@ -466,14 +466,14 @@ inline void store_le(u16bit in, byte out[2])
}
/**
-* Store a big-endian u32bit
-* @param in the input u32bit
+* Store a big-endian uint32_t
+* @param in the input uint32_t
* @param out the byte array to write to
*/
-inline void store_be(u32bit in, byte out[4])
+inline void store_be(uint32_t in, uint8_t out[4])
{
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u32bit o = BOTAN_ENDIAN_B2N(in);
+ uint32_t o = BOTAN_ENDIAN_B2N(in);
std::memcpy(out, &o, sizeof(o));
#else
out[0] = get_byte(0, in);
@@ -484,14 +484,14 @@ inline void store_be(u32bit in, byte out[4])
}
/**
-* Store a little-endian u32bit
-* @param in the input u32bit
+* Store a little-endian uint32_t
+* @param in the input uint32_t
* @param out the byte array to write to
*/
-inline void store_le(u32bit in, byte out[4])
+inline void store_le(uint32_t in, uint8_t out[4])
{
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u32bit o = BOTAN_ENDIAN_L2N(in);
+ uint32_t o = BOTAN_ENDIAN_L2N(in);
std::memcpy(out, &o, sizeof(o));
#else
out[0] = get_byte(3, in);
@@ -502,14 +502,14 @@ inline void store_le(u32bit in, byte out[4])
}
/**
-* Store a big-endian u64bit
-* @param in the input u64bit
+* Store a big-endian uint64_t
+* @param in the input uint64_t
* @param out the byte array to write to
*/
-inline void store_be(u64bit in, byte out[8])
+inline void store_be(uint64_t in, uint8_t out[8])
{
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u64bit o = BOTAN_ENDIAN_B2N(in);
+ uint64_t o = BOTAN_ENDIAN_B2N(in);
std::memcpy(out, &o, sizeof(o));
#else
out[0] = get_byte(0, in);
@@ -524,14 +524,14 @@ inline void store_be(u64bit in, byte out[8])
}
/**
-* Store a little-endian u64bit
-* @param in the input u64bit
+* Store a little-endian uint64_t
+* @param in the input uint64_t
* @param out the byte array to write to
*/
-inline void store_le(u64bit in, byte out[8])
+inline void store_le(uint64_t in, uint8_t out[8])
{
#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK
- u64bit o = BOTAN_ENDIAN_L2N(in);
+ uint64_t o = BOTAN_ENDIAN_L2N(in);
std::memcpy(out, &o, sizeof(o));
#else
out[0] = get_byte(7, in);
@@ -552,7 +552,7 @@ inline void store_le(u64bit in, byte out[8])
* @param x1 the second word
*/
template<typename T>
-inline void store_le(byte out[], T x0, T x1)
+inline void store_le(uint8_t out[], T x0, T x1)
{
store_le(x0, out + (0 * sizeof(T)));
store_le(x1, out + (1 * sizeof(T)));
@@ -565,7 +565,7 @@ inline void store_le(byte out[], T x0, T x1)
* @param x1 the second word
*/
template<typename T>
-inline void store_be(byte out[], T x0, T x1)
+inline void store_be(uint8_t out[], T x0, T x1)
{
store_be(x0, out + (0 * sizeof(T)));
store_be(x1, out + (1 * sizeof(T)));
@@ -580,7 +580,7 @@ inline void store_be(byte out[], T x0, T x1)
* @param x3 the fourth word
*/
template<typename T>
-inline void store_le(byte out[], T x0, T x1, T x2, T x3)
+inline void store_le(uint8_t out[], T x0, T x1, T x2, T x3)
{
store_le(x0, out + (0 * sizeof(T)));
store_le(x1, out + (1 * sizeof(T)));
@@ -597,7 +597,7 @@ inline void store_le(byte out[], T x0, T x1, T x2, T x3)
* @param x3 the fourth word
*/
template<typename T>
-inline void store_be(byte out[], T x0, T x1, T x2, T x3)
+inline void store_be(uint8_t out[], T x0, T x1, T x2, T x3)
{
store_be(x0, out + (0 * sizeof(T)));
store_be(x1, out + (1 * sizeof(T)));
@@ -618,7 +618,7 @@ inline void store_be(byte out[], T x0, T x1, T x2, T x3)
* @param x7 the eighth word
*/
template<typename T>
-inline void store_le(byte out[], T x0, T x1, T x2, T x3,
+inline void store_le(uint8_t out[], T x0, T x1, T x2, T x3,
T x4, T x5, T x6, T x7)
{
store_le(x0, out + (0 * sizeof(T)));
@@ -644,7 +644,7 @@ inline void store_le(byte out[], T x0, T x1, T x2, T x3,
* @param x7 the eighth word
*/
template<typename T>
-inline void store_be(byte out[], T x0, T x1, T x2, T x3,
+inline void store_be(uint8_t out[], T x0, T x1, T x2, T x3,
T x4, T x5, T x6, T x7)
{
store_be(x0, out + (0 * sizeof(T)));
@@ -658,7 +658,7 @@ inline void store_be(byte out[], T x0, T x1, T x2, T x3,
}
template<typename T>
-void copy_out_be(byte out[], size_t out_bytes, const T in[])
+void copy_out_be(uint8_t out[], size_t out_bytes, const T in[])
{
while(out_bytes >= sizeof(T))
{
@@ -673,13 +673,13 @@ void copy_out_be(byte out[], size_t out_bytes, const T in[])
}
template<typename T, typename Alloc>
-void copy_out_vec_be(byte out[], size_t out_bytes, const std::vector<T, Alloc>& in)
+void copy_out_vec_be(uint8_t out[], size_t out_bytes, const std::vector<T, Alloc>& in)
{
copy_out_be(out, out_bytes, in.data());
}
template<typename T>
-void copy_out_le(byte out[], size_t out_bytes, const T in[])
+void copy_out_le(uint8_t out[], size_t out_bytes, const T in[])
{
while(out_bytes >= sizeof(T))
{
@@ -694,7 +694,7 @@ void copy_out_le(byte out[], size_t out_bytes, const T in[])
}
template<typename T, typename Alloc>
-void copy_out_vec_le(byte out[], size_t out_bytes, const std::vector<T, Alloc>& in)
+void copy_out_vec_le(uint8_t out[], size_t out_bytes, const std::vector<T, Alloc>& in)
{
copy_out_le(out, out_bytes, in.data());
}
diff --git a/src/lib/utils/locking_allocator/locking_allocator.cpp b/src/lib/utils/locking_allocator/locking_allocator.cpp
index 5c87e006d..ce8270d68 100644
--- a/src/lib/utils/locking_allocator/locking_allocator.cpp
+++ b/src/lib/utils/locking_allocator/locking_allocator.cpp
@@ -144,7 +144,7 @@ bool mlock_allocator::deallocate(void* p, size_t num_elems, size_t elem_size)
lock_guard_type<mutex_type> lock(m_mutex);
- const size_t start = static_cast<byte*>(p) - m_pool;
+ const size_t start = static_cast<uint8_t*>(p) - m_pool;
auto comp = [](std::pair<size_t, size_t> x, std::pair<size_t, size_t> y){ return x.first < y.first; };
@@ -198,7 +198,7 @@ mlock_allocator::mlock_allocator()
if(mem_to_lock)
{
- m_pool = static_cast<byte*>(OS::allocate_locked_pages(mem_to_lock));
+ m_pool = static_cast<uint8_t*>(OS::allocate_locked_pages(mem_to_lock));
if(m_pool != nullptr)
{
diff --git a/src/lib/utils/locking_allocator/locking_allocator.h b/src/lib/utils/locking_allocator/locking_allocator.h
index 5c19852c0..806f9fa86 100644
--- a/src/lib/utils/locking_allocator/locking_allocator.h
+++ b/src/lib/utils/locking_allocator/locking_allocator.h
@@ -34,7 +34,7 @@ class BOTAN_DLL mlock_allocator
mutex_type m_mutex;
std::vector<std::pair<size_t, size_t>> m_freelist;
- byte* m_pool = nullptr;
+ uint8_t* m_pool = nullptr;
size_t m_poolsize = 0;
};
diff --git a/src/lib/utils/mem_ops.cpp b/src/lib/utils/mem_ops.cpp
index a0cd3124f..c81d4fac2 100644
--- a/src/lib/utils/mem_ops.cpp
+++ b/src/lib/utils/mem_ops.cpp
@@ -29,7 +29,7 @@ void secure_scrub_memory(void* ptr, size_t n)
static void* (*const volatile memset_ptr)(void*, int, size_t) = std::memset;
(memset_ptr)(ptr, 0, n);
#else
- volatile byte* p = reinterpret_cast<volatile byte*>(ptr);
+ volatile uint8_t* p = reinterpret_cast<volatile uint8_t*>(ptr);
for(size_t i = 0; i != n; ++i)
p[i] = 0;
diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h
index b4cf7f76c..13c987526 100644
--- a/src/lib/utils/mem_ops.h
+++ b/src/lib/utils/mem_ops.h
@@ -80,7 +80,7 @@ template<typename T> inline void copy_mem(T* out, const T* in, size_t n)
* @param val the value to set each byte to
*/
template<typename T>
-inline void set_mem(T* ptr, size_t n, byte val)
+inline void set_mem(T* ptr, size_t n, uint8_t val)
{
if(n > 0)
{
@@ -139,25 +139,25 @@ template<typename T> void xor_buf(T out[],
}
template<typename Alloc, typename Alloc2>
-void xor_buf(std::vector<byte, Alloc>& out,
- const std::vector<byte, Alloc2>& in,
+void xor_buf(std::vector<uint8_t, Alloc>& out,
+ const std::vector<uint8_t, Alloc2>& in,
size_t n)
{
xor_buf(out.data(), in.data(), n);
}
template<typename Alloc>
-void xor_buf(std::vector<byte, Alloc>& out,
- const byte* in,
+void xor_buf(std::vector<uint8_t, Alloc>& out,
+ const uint8_t* in,
size_t n)
{
xor_buf(out.data(), in, n);
}
template<typename Alloc, typename Alloc2>
-void xor_buf(std::vector<byte, Alloc>& out,
- const byte* in,
- const std::vector<byte, Alloc2>& in2,
+void xor_buf(std::vector<uint8_t, Alloc>& out,
+ const uint8_t* in,
+ const std::vector<uint8_t, Alloc2>& in2,
size_t n)
{
xor_buf(out.data(), in, in2.data(), n);
diff --git a/src/lib/utils/mul128.h b/src/lib/utils/mul128.h
index fe533c720..d5c89e0dd 100644
--- a/src/lib/utils/mul128.h
+++ b/src/lib/utils/mul128.h
@@ -80,7 +80,7 @@ namespace Botan {
/**
* Perform a 64x64->128 bit multiplication
*/
-inline void mul64x64_128(u64bit a, u64bit b, u64bit* lo, u64bit* hi)
+inline void mul64x64_128(uint64_t a, uint64_t b, uint64_t* lo, uint64_t* hi)
{
#if defined(BOTAN_FAST_64X64_MUL)
BOTAN_FAST_64X64_MUL(a, b, lo, hi);
@@ -92,17 +92,17 @@ inline void mul64x64_128(u64bit a, u64bit b, u64bit* lo, u64bit* hi)
* 64-bit registers/ALU, but no 64x64->128 multiply) or 32-bit CPUs.
*/
const size_t HWORD_BITS = 32;
- const u32bit HWORD_MASK = 0xFFFFFFFF;
+ const uint32_t HWORD_MASK = 0xFFFFFFFF;
- const u32bit a_hi = (a >> HWORD_BITS);
- const u32bit a_lo = (a & HWORD_MASK);
- const u32bit b_hi = (b >> HWORD_BITS);
- const u32bit b_lo = (b & HWORD_MASK);
+ const uint32_t a_hi = (a >> HWORD_BITS);
+ const uint32_t a_lo = (a & HWORD_MASK);
+ const uint32_t b_hi = (b >> HWORD_BITS);
+ const uint32_t b_lo = (b & HWORD_MASK);
- u64bit x0 = static_cast<u64bit>(a_hi) * b_hi;
- u64bit x1 = static_cast<u64bit>(a_lo) * b_hi;
- u64bit x2 = static_cast<u64bit>(a_hi) * b_lo;
- u64bit x3 = static_cast<u64bit>(a_lo) * b_lo;
+ uint64_t x0 = static_cast<uint64_t>(a_hi) * b_hi;
+ uint64_t x1 = static_cast<uint64_t>(a_lo) * b_hi;
+ uint64_t x2 = static_cast<uint64_t>(a_hi) * b_lo;
+ uint64_t x3 = static_cast<uint64_t>(a_lo) * b_lo;
// this cannot overflow as (2^32-1)^2 + 2^32-1 < 2^64-1
x2 += x3 >> HWORD_BITS;
@@ -111,7 +111,7 @@ inline void mul64x64_128(u64bit a, u64bit b, u64bit* lo, u64bit* hi)
x2 += x1;
// propagate the carry if any
- x0 += static_cast<u64bit>(static_cast<bool>(x2 < x1)) << HWORD_BITS;
+ x0 += static_cast<uint64_t>(static_cast<bool>(x2 < x1)) << HWORD_BITS;
*hi = x0 + (x2 >> HWORD_BITS);
*lo = ((x2 & HWORD_MASK) << HWORD_BITS) + (x3 & HWORD_MASK);
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index d072b2c2b..46ce2a056 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -53,13 +53,13 @@ uint64_t get_processor_timestamp()
{
uint32_t rtc_low = 0, rtc_high = 0;
asm volatile("rdtsc" : "=d" (rtc_high), "=a" (rtc_low));
- return (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
+ return (static_cast<uint64_t>(rtc_high) << 32) | rtc_low;
}
#elif defined(BOTAN_USE_GCC_INLINE_ASM) && defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY)
uint32_t rtc_low = 0, rtc_high = 0;
asm volatile("mftbu %0; mftb %1" : "=r" (rtc_high), "=r" (rtc_low));
- return (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
+ return (static_cast<uint64_t>(rtc_high) << 32) | rtc_low;
#elif defined(BOTAN_USE_GCC_INLINE_ASM) && defined(BOTAN_TARGET_ARCH_IS_ALPHA)
uint64_t rtc = 0;
diff --git a/src/lib/utils/parsing.cpp b/src/lib/utils/parsing.cpp
index e5c8562b5..8fd2ccc52 100644
--- a/src/lib/utils/parsing.cpp
+++ b/src/lib/utils/parsing.cpp
@@ -15,7 +15,7 @@
namespace Botan {
-u32bit to_u32bit(const std::string& str)
+uint32_t to_u32bit(const std::string& str)
{
try
{
@@ -32,7 +32,7 @@ u32bit to_u32bit(const std::string& str)
const auto integerValue = std::stoul(str);
// integerValue might be uint64
- if (integerValue > std::numeric_limits<u32bit>::max())
+ if (integerValue > std::numeric_limits<uint32_t>::max())
{
throw Invalid_Argument("Integer value exceeds 32 bit range: " + std::to_string(integerValue));
}
@@ -51,7 +51,7 @@ u32bit to_u32bit(const std::string& str)
/*
* Convert a string into a time duration
*/
-u32bit timespec_to_u32bit(const std::string& timespec)
+uint32_t timespec_to_u32bit(const std::string& timespec)
{
if(timespec.empty())
return 0;
@@ -59,7 +59,7 @@ u32bit timespec_to_u32bit(const std::string& timespec)
const char suffix = timespec[timespec.size()-1];
std::string value = timespec.substr(0, timespec.size()-1);
- u32bit scale = 1;
+ uint32_t scale = 1;
if(Charset::is_digit(suffix))
value += suffix;
@@ -186,10 +186,10 @@ std::string string_join(const std::vector<std::string>& strs, char delim)
/*
* Parse an ASN.1 OID string
*/
-std::vector<u32bit> parse_asn1_oid(const std::string& oid)
+std::vector<uint32_t> parse_asn1_oid(const std::string& oid)
{
std::string substring;
- std::vector<u32bit> oid_elems;
+ std::vector<uint32_t> oid_elems;
for(auto i = oid.begin(); i != oid.end(); ++i)
{
@@ -258,18 +258,18 @@ bool x500_name_cmp(const std::string& name1, const std::string& name2)
/*
* Convert a decimal-dotted string to binary IP
*/
-u32bit string_to_ipv4(const std::string& str)
+uint32_t string_to_ipv4(const std::string& str)
{
std::vector<std::string> parts = split_on(str, '.');
if(parts.size() != 4)
throw Decoding_Error("Invalid IP string " + str);
- u32bit ip = 0;
+ uint32_t ip = 0;
for(auto part = parts.begin(); part != parts.end(); ++part)
{
- u32bit octet = to_u32bit(*part);
+ uint32_t octet = to_u32bit(*part);
if(octet > 255)
throw Decoding_Error("Invalid IP string " + str);
@@ -283,7 +283,7 @@ u32bit string_to_ipv4(const std::string& str)
/*
* Convert an IP address to decimal-dotted string
*/
-std::string ipv4_to_string(u32bit ip)
+std::string ipv4_to_string(uint32_t ip)
{
std::string str;
diff --git a/src/lib/utils/parsing.h b/src/lib/utils/parsing.h
index c609e821d..71f349126 100644
--- a/src/lib/utils/parsing.h
+++ b/src/lib/utils/parsing.h
@@ -86,7 +86,7 @@ BOTAN_DLL std::string string_join(const std::vector<std::string>& strs,
* @param oid the OID in string form
* @return OID components
*/
-BOTAN_DLL std::vector<u32bit> parse_asn1_oid(const std::string& oid);
+BOTAN_DLL std::vector<uint32_t> parse_asn1_oid(const std::string& oid);
/**
* Compare two names using the X.509 comparison algorithm
@@ -102,28 +102,28 @@ BOTAN_DLL bool x500_name_cmp(const std::string& name1,
* @param str the string to convert
* @return number value of the string
*/
-BOTAN_DLL u32bit to_u32bit(const std::string& str);
+BOTAN_DLL uint32_t to_u32bit(const std::string& str);
/**
* Convert a time specification to a number
* @param timespec the time specification
* @return number of seconds represented by timespec
*/
-BOTAN_DLL u32bit timespec_to_u32bit(const std::string& timespec);
+BOTAN_DLL uint32_t timespec_to_u32bit(const std::string& timespec);
/**
* Convert a string representation of an IPv4 address to a number
* @param ip_str the string representation
* @return integer IPv4 address
*/
-BOTAN_DLL u32bit string_to_ipv4(const std::string& ip_str);
+BOTAN_DLL uint32_t string_to_ipv4(const std::string& ip_str);
/**
* Convert an IPv4 address to a string
* @param ip_addr the IPv4 address to convert
* @return string representation of the IPv4 address
*/
-BOTAN_DLL std::string ipv4_to_string(u32bit ip_addr);
+BOTAN_DLL std::string ipv4_to_string(uint32_t ip_addr);
std::map<std::string, std::string> BOTAN_DLL read_cfg(std::istream& is);
diff --git a/src/lib/utils/simd/simd_32.h b/src/lib/utils/simd/simd_32.h
index c29c55c7a..591e0e9c9 100644
--- a/src/lib/utils/simd/simd_32.h
+++ b/src/lib/utils/simd/simd_32.h
@@ -46,7 +46,7 @@ class SIMD_4x32
#endif
}
- explicit SIMD_4x32(const u32bit B[4])
+ explicit SIMD_4x32(const uint32_t B[4])
{
#if defined(BOTAN_SIMD_USE_SSE2)
m_reg = _mm_loadu_si128(reinterpret_cast<const __m128i*>(B));
@@ -60,7 +60,7 @@ class SIMD_4x32
#endif
}
- SIMD_4x32(u32bit B0, u32bit B1, u32bit B2, u32bit B3)
+ SIMD_4x32(uint32_t B0, uint32_t B1, uint32_t B2, uint32_t B3)
{
#if defined(BOTAN_SIMD_USE_SSE2)
m_reg = _mm_set_epi32(B0, B1, B2, B3);
@@ -74,7 +74,7 @@ class SIMD_4x32
#endif
}
- explicit SIMD_4x32(u32bit B)
+ explicit SIMD_4x32(uint32_t B)
{
#if defined(BOTAN_SIMD_USE_SSE2)
m_reg = _mm_set1_epi32(B);
@@ -93,7 +93,7 @@ class SIMD_4x32
#if defined(BOTAN_SIMD_USE_SSE2)
return SIMD_4x32(_mm_loadu_si128(reinterpret_cast<const __m128i*>(in)));
#elif defined(BOTAN_SIMD_USE_ALTIVEC)
- const u32bit* in_32 = static_cast<const u32bit*>(in);
+ const uint32_t* in_32 = static_cast<const uint32_t*>(in);
__vector unsigned int R0 = vec_ld(0, in_32);
__vector unsigned int R1 = vec_ld(12, in_32);
@@ -119,7 +119,7 @@ class SIMD_4x32
#if defined(BOTAN_SIMD_USE_SSE2)
return load_le(in).bswap();
#elif defined(BOTAN_SIMD_USE_ALTIVEC)
- const u32bit* in_32 = static_cast<const u32bit*>(in);
+ const uint32_t* in_32 = static_cast<const uint32_t*>(in);
__vector unsigned int R0 = vec_ld(0, in_32);
__vector unsigned int R1 = vec_ld(12, in_32);
@@ -146,7 +146,7 @@ class SIMD_4x32
#if defined(BOTAN_SIMD_USE_SSE2)
_mm_storeu_si128(reinterpret_cast<__m128i*>(out), m_reg);
#elif defined(BOTAN_SIMD_USE_ALTIVEC)
- __vector unsigned char perm = vec_lvsl(0, static_cast<u32bit*>(nullptr));
+ __vector unsigned char perm = vec_lvsl(0, static_cast<uint32_t*>(nullptr));
#if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
perm = vec_xor(perm, vec_splat_u8(3)); // bswap vector
@@ -154,7 +154,7 @@ class SIMD_4x32
union {
__vector unsigned int V;
- u32bit R[4];
+ uint32_t R[4];
} vec;
vec.V = vec_perm(m_reg, m_reg, perm);
@@ -174,7 +174,7 @@ class SIMD_4x32
union {
__vector unsigned int V;
- u32bit R[4];
+ uint32_t R[4];
} vec;
vec.V = m_reg;
@@ -415,7 +415,7 @@ class SIMD_4x32
#elif defined(BOTAN_SIMD_USE_ALTIVEC)
- __vector unsigned char perm = vec_lvsl(0, static_cast<u32bit*>(nullptr));
+ __vector unsigned char perm = vec_lvsl(0, static_cast<uint32_t*>(nullptr));
perm = vec_xor(perm, vec_splat_u8(3));
diff --git a/src/lib/utils/sqlite3/sqlite3.cpp b/src/lib/utils/sqlite3/sqlite3.cpp
index 251cbcdf5..09a964a46 100644
--- a/src/lib/utils/sqlite3/sqlite3.cpp
+++ b/src/lib/utils/sqlite3/sqlite3.cpp
@@ -92,21 +92,21 @@ void Sqlite3_Database::Sqlite3_Statement::bind(int column, std::chrono::system_c
bind(column, timeval);
}
-void Sqlite3_Database::Sqlite3_Statement::bind(int column, const std::vector<byte>& val)
+void Sqlite3_Database::Sqlite3_Statement::bind(int column, const std::vector<uint8_t>& val)
{
int rc = ::sqlite3_bind_blob(m_stmt, column, val.data(), val.size(), SQLITE_TRANSIENT);
if(rc != SQLITE_OK)
throw SQL_DB_Error("sqlite3_bind_text failed, code " + std::to_string(rc));
}
-void Sqlite3_Database::Sqlite3_Statement::bind(int column, const byte* p, size_t len)
+void Sqlite3_Database::Sqlite3_Statement::bind(int column, const uint8_t* p, size_t len)
{
int rc = ::sqlite3_bind_blob(m_stmt, column, p, len, SQLITE_TRANSIENT);
if(rc != SQLITE_OK)
throw SQL_DB_Error("sqlite3_bind_text failed, code " + std::to_string(rc));
}
-std::pair<const byte*, size_t> Sqlite3_Database::Sqlite3_Statement::get_blob(int column)
+std::pair<const uint8_t*, size_t> Sqlite3_Database::Sqlite3_Statement::get_blob(int column)
{
BOTAN_ASSERT(::sqlite3_column_type(m_stmt, 0) == SQLITE_BLOB,
"Return value is a blob");
@@ -116,7 +116,7 @@ std::pair<const byte*, size_t> Sqlite3_Database::Sqlite3_Statement::get_blob(int
BOTAN_ASSERT(session_blob_size >= 0, "Blob size is non-negative");
- return std::make_pair(static_cast<const byte*>(session_blob),
+ return std::make_pair(static_cast<const uint8_t*>(session_blob),
static_cast<size_t>(session_blob_size));
}
diff --git a/src/lib/utils/sqlite3/sqlite3.h b/src/lib/utils/sqlite3/sqlite3.h
index 659e1c487..5f262d8e6 100644
--- a/src/lib/utils/sqlite3/sqlite3.h
+++ b/src/lib/utils/sqlite3/sqlite3.h
@@ -34,10 +34,10 @@ class BOTAN_DLL Sqlite3_Database : public SQL_Database
void bind(int column, const std::string& val) override;
void bind(int column, size_t val) override;
void bind(int column, std::chrono::system_clock::time_point time) override;
- void bind(int column, const std::vector<byte>& val) override;
- void bind(int column, const byte* data, size_t len) override;
+ void bind(int column, const std::vector<uint8_t>& val) override;
+ void bind(int column, const uint8_t* data, size_t len) override;
- std::pair<const byte*, size_t> get_blob(int column) override;
+ std::pair<const uint8_t*, size_t> get_blob(int column) override;
size_t get_size_t(int column) override;
size_t spin() override;
diff --git a/src/lib/utils/stl_util.h b/src/lib/utils/stl_util.h
index 12b749c3c..c05f934c8 100644
--- a/src/lib/utils/stl_util.h
+++ b/src/lib/utils/stl_util.h
@@ -17,12 +17,12 @@
namespace Botan {
-inline std::vector<byte> to_byte_vector(const std::string& s)
+inline std::vector<uint8_t> to_byte_vector(const std::string& s)
{
- return std::vector<byte>(s.cbegin(), s.cend());
+ return std::vector<uint8_t>(s.cbegin(), s.cend());
}
-inline std::string to_string(const secure_vector<byte> &bytes)
+inline std::string to_string(const secure_vector<uint8_t> &bytes)
{
return std::string(bytes.cbegin(), bytes.cend());
}
diff --git a/src/lib/utils/types.h b/src/lib/utils/types.h
index f5754983d..459d8447f 100644
--- a/src/lib/utils/types.h
+++ b/src/lib/utils/types.h
@@ -28,6 +28,11 @@ using std::int32_t;
using std::int64_t;
using std::size_t;
+/*
+* These typedefs are no longer used within the library headers
+* or code. They are kept only for compatability with software
+* written against older versions.
+*/
using byte = std::uint8_t;
using u16bit = std::uint16_t;
using u32bit = std::uint32_t;
diff --git a/src/lib/utils/version.cpp b/src/lib/utils/version.cpp
index 308bf76ab..166e75678 100644
--- a/src/lib/utils/version.cpp
+++ b/src/lib/utils/version.cpp
@@ -52,18 +52,18 @@ const char* version_cstr()
#undef QUOTE
}
-u32bit version_datestamp() { return BOTAN_VERSION_DATESTAMP; }
+uint32_t version_datestamp() { return BOTAN_VERSION_DATESTAMP; }
/*
* Return parts of the version as integers
*/
-u32bit version_major() { return BOTAN_VERSION_MAJOR; }
-u32bit version_minor() { return BOTAN_VERSION_MINOR; }
-u32bit version_patch() { return BOTAN_VERSION_PATCH; }
+uint32_t version_major() { return BOTAN_VERSION_MAJOR; }
+uint32_t version_minor() { return BOTAN_VERSION_MINOR; }
+uint32_t version_patch() { return BOTAN_VERSION_PATCH; }
-std::string runtime_version_check(u32bit major,
- u32bit minor,
- u32bit patch)
+std::string runtime_version_check(uint32_t major,
+ uint32_t minor,
+ uint32_t patch)
{
std::ostringstream oss;
diff --git a/src/lib/utils/version.h b/src/lib/utils/version.h
index 6e9e231bc..834b719af 100644
--- a/src/lib/utils/version.h
+++ b/src/lib/utils/version.h
@@ -34,25 +34,25 @@ BOTAN_DLL const char* version_cstr();
*
* @return release date, or zero if unreleased
*/
-BOTAN_DLL u32bit version_datestamp();
+BOTAN_DLL uint32_t version_datestamp();
/**
* Get the major version number.
* @return major version number
*/
-BOTAN_DLL u32bit version_major();
+BOTAN_DLL uint32_t version_major();
/**
* Get the minor version number.
* @return minor version number
*/
-BOTAN_DLL u32bit version_minor();
+BOTAN_DLL uint32_t version_minor();
/**
* Get the patch number.
* @return patch number
*/
-BOTAN_DLL u32bit version_patch();
+BOTAN_DLL uint32_t version_patch();
/**
* Usable for checking that the DLL version loaded at runtime exactly
@@ -61,9 +61,9 @@ BOTAN_DLL u32bit version_patch();
* appropriate message. Added with 1.11.26.
*/
BOTAN_DLL std::string
-runtime_version_check(u32bit major,
- u32bit minor,
- u32bit patch);
+runtime_version_check(uint32_t major,
+ uint32_t minor,
+ uint32_t patch);
/*
* Macros for compile-time version checks
diff --git a/src/lib/x509/certstor.cpp b/src/lib/x509/certstor.cpp
index 1f7275675..10178a526 100644
--- a/src/lib/x509/certstor.cpp
+++ b/src/lib/x509/certstor.cpp
@@ -48,14 +48,14 @@ std::vector<X509_DN> Certificate_Store_In_Memory::all_subjects() const
std::shared_ptr<const X509_Certificate>
Certificate_Store_In_Memory::find_cert(const X509_DN& subject_dn,
- const std::vector<byte>& key_id) const
+ const std::vector<uint8_t>& key_id) const
{
for(size_t i = 0; i != m_certs.size(); ++i)
{
// Only compare key ids if set in both call and in the cert
if(key_id.size())
{
- std::vector<byte> skid = m_certs[i]->subject_key_id();
+ std::vector<uint8_t> skid = m_certs[i]->subject_key_id();
if(skid.size() && skid != key_id) // no match
continue;
@@ -70,14 +70,14 @@ Certificate_Store_In_Memory::find_cert(const X509_DN& subject_dn,
std::shared_ptr<const X509_Certificate>
-Certificate_Store_In_Memory::find_cert_by_pubkey_sha1(const std::vector<byte>& key_hash) const
+Certificate_Store_In_Memory::find_cert_by_pubkey_sha1(const std::vector<uint8_t>& key_hash) const
{
if(key_hash.size() != 20)
throw Invalid_Argument("Certificate_Store_In_Memory::find_cert_by_pubkey_sha1 invalid hash");
for(size_t i = 0; i != m_certs.size(); ++i)
{
- const std::vector<byte> hash_i = m_certs[i]->subject_public_key_bitstring_sha1();
+ const std::vector<uint8_t> hash_i = m_certs[i]->subject_public_key_bitstring_sha1();
if(key_hash == hash_i)
{
return m_certs[i];
@@ -114,14 +114,14 @@ void Certificate_Store_In_Memory::add_crl(std::shared_ptr<const X509_CRL> crl)
std::shared_ptr<const X509_CRL> Certificate_Store_In_Memory::find_crl_for(const X509_Certificate& subject) const
{
- const std::vector<byte>& key_id = subject.authority_key_id();
+ const std::vector<uint8_t>& key_id = subject.authority_key_id();
for(size_t i = 0; i != m_crls.size(); ++i)
{
// Only compare key ids if set in both call and in the CRL
if(key_id.size())
{
- std::vector<byte> akid = m_crls[i]->authority_key_id();
+ std::vector<uint8_t> akid = m_crls[i]->authority_key_id();
if(akid.size() && akid != key_id) // no match
continue;
diff --git a/src/lib/x509/certstor.h b/src/lib/x509/certstor.h
index ba71334c5..3ac357767 100644
--- a/src/lib/x509/certstor.h
+++ b/src/lib/x509/certstor.h
@@ -28,7 +28,7 @@ class BOTAN_DLL Certificate_Store
* @return a matching certificate or nullptr otherwise
*/
virtual std::shared_ptr<const X509_Certificate>
- find_cert(const X509_DN& subject_dn, const std::vector<byte>& key_id) const = 0;
+ find_cert(const X509_DN& subject_dn, const std::vector<uint8_t>& key_id) const = 0;
/**
* Find a certificate by searching for one with a matching SHA-1 hash of
@@ -37,7 +37,7 @@ class BOTAN_DLL Certificate_Store
* @return a matching certificate or nullptr otherwise
*/
virtual std::shared_ptr<const X509_Certificate>
- find_cert_by_pubkey_sha1(const std::vector<byte>& key_hash) const = 0;
+ find_cert_by_pubkey_sha1(const std::vector<uint8_t>& key_hash) const = 0;
/**
* Finds a CRL for the given certificate
@@ -115,10 +115,10 @@ class BOTAN_DLL Certificate_Store_In_Memory : public Certificate_Store
*/
std::shared_ptr<const X509_Certificate> find_cert(
const X509_DN& subject_dn,
- const std::vector<byte>& key_id) const override;
+ const std::vector<uint8_t>& key_id) const override;
std::shared_ptr<const X509_Certificate>
- find_cert_by_pubkey_sha1(const std::vector<byte>& key_hash) const override;
+ find_cert_by_pubkey_sha1(const std::vector<uint8_t>& key_hash) const override;
/**
* Finds a CRL for the given certificate
diff --git a/src/lib/x509/certstor_sql/certstor_sql.cpp b/src/lib/x509/certstor_sql/certstor_sql.cpp
index 4dceae305..06e0fda1b 100644
--- a/src/lib/x509/certstor_sql/certstor_sql.cpp
+++ b/src/lib/x509/certstor_sql/certstor_sql.cpp
@@ -46,7 +46,7 @@ Certificate_Store_In_SQL::Certificate_Store_In_SQL(std::shared_ptr<SQL_Database>
// Certificate handling
std::shared_ptr<const X509_Certificate>
-Certificate_Store_In_SQL::find_cert(const X509_DN& subject_dn, const std::vector<byte>& key_id) const
+Certificate_Store_In_SQL::find_cert(const X509_DN& subject_dn, const std::vector<uint8_t>& key_id) const
{
DER_Encoder enc;
std::shared_ptr<SQL_Database::Statement> stmt;
@@ -71,7 +71,7 @@ Certificate_Store_In_SQL::find_cert(const X509_DN& subject_dn, const std::vector
{
auto blob = stmt->get_blob(0);
cert = std::make_shared<X509_Certificate>(
- std::vector<byte>(blob.first,blob.first + blob.second));
+ std::vector<uint8_t>(blob.first,blob.first + blob.second));
}
@@ -79,7 +79,7 @@ Certificate_Store_In_SQL::find_cert(const X509_DN& subject_dn, const std::vector
}
std::shared_ptr<const X509_Certificate>
-Certificate_Store_In_SQL::find_cert_by_pubkey_sha1(const std::vector<byte>& /*key_hash*/) const
+Certificate_Store_In_SQL::find_cert_by_pubkey_sha1(const std::vector<uint8_t>& /*key_hash*/) const
{
// TODO!
return nullptr;
@@ -137,7 +137,7 @@ bool Certificate_Store_In_SQL::insert_cert(const X509_Certificate& cert)
cert.subject_dn().encode_into(enc);
stmt->bind(2,enc.get_contents_unlocked());
stmt->bind(3,cert.subject_key_id());
- stmt->bind(4,std::vector<byte>());
+ stmt->bind(4,std::vector<uint8_t>());
enc = DER_Encoder();
cert.encode_into(enc);
stmt->bind(5,enc.get_contents_unlocked());
@@ -193,7 +193,7 @@ Certificate_Store_In_SQL::find_certs_for_key(const Private_Key& key) const
{
auto blob = stmt->get_blob(0);
certs.push_back(std::make_shared<X509_Certificate>(
- std::vector<byte>(blob.first,blob.first + blob.second)));
+ std::vector<uint8_t>(blob.first,blob.first + blob.second)));
}
return certs;
@@ -279,7 +279,7 @@ std::vector<X509_CRL> Certificate_Store_In_SQL::generate_crls() const
{
auto blob = stmt->get_blob(0);
auto cert = X509_Certificate(
- std::vector<byte>(blob.first,blob.first + blob.second));
+ std::vector<uint8_t>(blob.first,blob.first + blob.second));
auto code = static_cast<CRL_Code>(stmt->get_size_t(1));
auto ent = CRL_Entry(cert,code);
diff --git a/src/lib/x509/certstor_sql/certstor_sql.h b/src/lib/x509/certstor_sql/certstor_sql.h
index 0f493c56b..91d8d5c00 100644
--- a/src/lib/x509/certstor_sql/certstor_sql.h
+++ b/src/lib/x509/certstor_sql/certstor_sql.h
@@ -39,10 +39,10 @@ class BOTAN_DLL Certificate_Store_In_SQL : public Certificate_Store
* Returns the first certificate with matching subject DN and optional key ID.
*/
virtual std::shared_ptr<const X509_Certificate>
- find_cert(const X509_DN& subject_dn, const std::vector<byte>& key_id) const override;
+ find_cert(const X509_DN& subject_dn, const std::vector<uint8_t>& key_id) const override;
std::shared_ptr<const X509_Certificate>
- find_cert_by_pubkey_sha1(const std::vector<byte>& key_hash) const override;
+ find_cert_by_pubkey_sha1(const std::vector<uint8_t>& key_hash) const override;
/**
* Returns all subject DNs known to the store instance.
diff --git a/src/lib/x509/crl_ent.cpp b/src/lib/x509/crl_ent.cpp
index 7074f0609..f717e7b07 100644
--- a/src/lib/x509/crl_ent.cpp
+++ b/src/lib/x509/crl_ent.cpp
@@ -93,7 +93,7 @@ void CRL_Entry::decode_from(BER_Decoder& source)
entry.decode(extensions);
Data_Store info;
extensions.contents_to(info, info);
- m_reason = CRL_Code(info.get1_u32bit("X509v3.CRLReasonCode"));
+ m_reason = CRL_Code(info.get1_uint32("X509v3.CRLReasonCode"));
}
entry.end_cons();
diff --git a/src/lib/x509/crl_ent.h b/src/lib/x509/crl_ent.h
index 6600621e5..233781826 100644
--- a/src/lib/x509/crl_ent.h
+++ b/src/lib/x509/crl_ent.h
@@ -47,7 +47,7 @@ class BOTAN_DLL CRL_Entry final : public ASN1_Object
* Get the serial number of the certificate associated with this entry.
* @return certificate's serial number
*/
- std::vector<byte> serial_number() const { return m_serial; }
+ std::vector<uint8_t> serial_number() const { return m_serial; }
/**
* Get the revocation date of the certificate associated with this entry
@@ -78,7 +78,7 @@ class BOTAN_DLL CRL_Entry final : public ASN1_Object
private:
bool m_throw_on_unknown_critical;
- std::vector<byte> m_serial;
+ std::vector<uint8_t> m_serial;
X509_Time m_time;
CRL_Code m_reason;
};
diff --git a/src/lib/x509/name_constraint.cpp b/src/lib/x509/name_constraint.cpp
index e4d69c6ac..703c6770c 100644
--- a/src/lib/x509/name_constraint.cpp
+++ b/src/lib/x509/name_constraint.cpp
@@ -79,10 +79,10 @@ void GeneralName::decode_from(class BER_Decoder& ber)
{
if(obj.value.size() == 8)
{
- const std::vector<byte> ip(obj.value.begin(), obj.value.begin() + 4);
- const std::vector<byte> net(obj.value.begin() + 4, obj.value.end());
+ const std::vector<uint8_t> ip(obj.value.begin(), obj.value.begin() + 4);
+ const std::vector<uint8_t> net(obj.value.begin() + 4, obj.value.end());
m_type = "IP";
- m_name = ipv4_to_string(load_be<u32bit>(ip.data(), 0)) + "/" + ipv4_to_string(load_be<u32bit>(net.data(), 0));
+ m_name = ipv4_to_string(load_be<uint32_t>(ip.data(), 0)) + "/" + ipv4_to_string(load_be<uint32_t>(net.data(), 0));
}
else if(obj.value.size() == 32)
{
@@ -210,14 +210,14 @@ bool GeneralName::matches_dn(const std::string& nam) const
bool GeneralName::matches_ip(const std::string& nam) const
{
- u32bit ip = string_to_ipv4(nam);
+ uint32_t ip = string_to_ipv4(nam);
std::vector<std::string> p = split_on(name(), '/');
if(p.size() != 2)
throw Decoding_Error("failed to parse IPv4 address");
- u32bit net = string_to_ipv4(p.at(0));
- u32bit mask = string_to_ipv4(p.at(1));
+ uint32_t net = string_to_ipv4(p.at(0));
+ uint32_t mask = string_to_ipv4(p.at(1));
return (ip & mask) == net;
}
diff --git a/src/lib/x509/ocsp.cpp b/src/lib/x509/ocsp.cpp
index bd3f1855e..964299f64 100644
--- a/src/lib/x509/ocsp.cpp
+++ b/src/lib/x509/ocsp.cpp
@@ -60,7 +60,7 @@ Request::Request(const X509_Certificate& issuer_cert,
throw Invalid_Argument("Invalid cert pair to OCSP::Request (mismatched issuer,subject args?)");
}
-std::vector<byte> Request::BER_encode() const
+std::vector<uint8_t> Request::BER_encode() const
{
return DER_Encoder().start_cons(SEQUENCE)
.start_cons(SEQUENCE)
@@ -175,7 +175,7 @@ Certificate_Status_Code Response::check_signature(const std::vector<Certificate_
if(!m_signer_name.empty())
{
- signing_cert = trusted_roots[i]->find_cert(m_signer_name, std::vector<byte>());
+ signing_cert = trusted_roots[i]->find_cert(m_signer_name, std::vector<uint8_t>());
if(signing_cert)
{
break;
diff --git a/src/lib/x509/ocsp.h b/src/lib/x509/ocsp.h
index 05f194392..ff6a19567 100644
--- a/src/lib/x509/ocsp.h
+++ b/src/lib/x509/ocsp.h
@@ -34,7 +34,7 @@ class BOTAN_DLL Request
/**
* @return BER-encoded OCSP request
*/
- std::vector<byte> BER_encode() const;
+ std::vector<uint8_t> BER_encode() const;
/**
* @return Base64-encoded OCSP request
@@ -51,7 +51,7 @@ class BOTAN_DLL Request
*/
const X509_Certificate& subject() const { return m_subject; }
- const std::vector<byte>& issuer_key_hash() const
+ const std::vector<uint8_t>& issuer_key_hash() const
{ return m_certid.issuer_key_hash(); }
private:
X509_Certificate m_issuer, m_subject;
@@ -75,7 +75,7 @@ class BOTAN_DLL Response
* Parses an OCSP response.
* @param response_bits response bits received
*/
- Response(const std::vector<byte>& response_bits) :
+ Response(const std::vector<uint8_t>& response_bits) :
Response(response_bits.data(), response_bits.size())
{}
@@ -119,9 +119,9 @@ class BOTAN_DLL Response
/**
* @return key hash, if provided in response (may be empty)
*/
- const std::vector<byte>& signer_key_hash() const { return m_key_hash; }
+ const std::vector<uint8_t>& signer_key_hash() const { return m_key_hash; }
- const std::vector<byte>& raw_bits() const { return m_response_bits; }
+ const std::vector<uint8_t>& raw_bits() const { return m_response_bits; }
/**
* Searches the OCSP response for issuer and subject certificate.
@@ -141,13 +141,13 @@ class BOTAN_DLL Response
std::chrono::system_clock::time_point ref_time = std::chrono::system_clock::now()) const;
private:
- std::vector<byte> m_response_bits;
+ std::vector<uint8_t> m_response_bits;
X509_Time m_produced_at;
X509_DN m_signer_name;
- std::vector<byte> m_key_hash;
- std::vector<byte> m_tbs_bits;
+ std::vector<uint8_t> m_key_hash;
+ std::vector<uint8_t> m_tbs_bits;
AlgorithmIdentifier m_sig_algo;
- std::vector<byte> m_signature;
+ std::vector<uint8_t> m_signature;
std::vector<X509_Certificate> m_certs;
std::vector<SingleResponse> m_responses;
diff --git a/src/lib/x509/ocsp_types.h b/src/lib/x509/ocsp_types.h
index 40fbb85a8..1cbf207b8 100644
--- a/src/lib/x509/ocsp_types.h
+++ b/src/lib/x509/ocsp_types.h
@@ -31,12 +31,12 @@ class BOTAN_DLL CertID final : public ASN1_Object
void decode_from(class BER_Decoder& from) override;
- const std::vector<byte>& issuer_key_hash() const { return m_issuer_key_hash; }
+ const std::vector<uint8_t>& issuer_key_hash() const { return m_issuer_key_hash; }
private:
AlgorithmIdentifier m_hash_id;
- std::vector<byte> m_issuer_dn_hash;
- std::vector<byte> m_issuer_key_hash;
+ std::vector<uint8_t> m_issuer_dn_hash;
+ std::vector<uint8_t> m_issuer_key_hash;
BigInt m_subject_serial;
};
diff --git a/src/lib/x509/pkcs10.cpp b/src/lib/x509/pkcs10.cpp
index 22508f131..a9cec86ee 100644
--- a/src/lib/x509/pkcs10.cpp
+++ b/src/lib/x509/pkcs10.cpp
@@ -39,7 +39,7 @@ PKCS10_Request::PKCS10_Request(const std::string& fsname) :
/*
* PKCS10_Request Constructor
*/
-PKCS10_Request::PKCS10_Request(const std::vector<byte>& in) :
+PKCS10_Request::PKCS10_Request(const std::vector<uint8_t>& in) :
X509_Object(in, "CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST")
{
do_decode();
@@ -143,7 +143,7 @@ X509_DN PKCS10_Request::subject_dn() const
/*
* Return the public key of the requestor
*/
-std::vector<byte> PKCS10_Request::raw_public_key() const
+std::vector<uint8_t> PKCS10_Request::raw_public_key() const
{
DataSource_Memory source(m_info.get1("X509.Certificate.public_key"));
return unlock(PEM_Code::decode_check_label(source, "PUBLIC KEY"));
diff --git a/src/lib/x509/pkcs10.h b/src/lib/x509/pkcs10.h
index 2202b92a4..3e0c37950 100644
--- a/src/lib/x509/pkcs10.h
+++ b/src/lib/x509/pkcs10.h
@@ -36,7 +36,7 @@ class BOTAN_DLL PKCS10_Request final : public X509_Object
* Get the raw DER encoded public key.
* @return raw DER encoded public key
*/
- std::vector<byte> raw_public_key() const;
+ std::vector<uint8_t> raw_public_key() const;
/**
* Get the subject DN.
@@ -107,7 +107,7 @@ class BOTAN_DLL PKCS10_Request final : public X509_Object
* Create a PKCS#10 Request from binary data.
* @param vec a std::vector containing the DER value
*/
- explicit PKCS10_Request(const std::vector<byte>& vec);
+ explicit PKCS10_Request(const std::vector<uint8_t>& vec);
private:
void force_decode() override;
void handle_attribute(const Attribute&);
diff --git a/src/lib/x509/x509_ca.cpp b/src/lib/x509/x509_ca.cpp
index ec56abc92..692f837ae 100644
--- a/src/lib/x509/x509_ca.cpp
+++ b/src/lib/x509/x509_ca.cpp
@@ -96,7 +96,7 @@ X509_Certificate X509_CA::sign_request(const PKCS10_Request& req,
X509_Certificate X509_CA::make_cert(PK_Signer* signer,
RandomNumberGenerator& rng,
const AlgorithmIdentifier& sig_algo,
- const std::vector<byte>& pub_key,
+ const std::vector<uint8_t>& pub_key,
const X509_Time& not_before,
const X509_Time& not_after,
const X509_DN& issuer_dn,
@@ -144,7 +144,7 @@ X509_Certificate X509_CA::make_cert(PK_Signer* signer,
* Create a new, empty CRL
*/
X509_CRL X509_CA::new_crl(RandomNumberGenerator& rng,
- u32bit next_update) const
+ uint32_t next_update) const
{
std::vector<CRL_Entry> empty;
return make_crl(empty, 1, next_update, rng);
@@ -156,7 +156,7 @@ X509_CRL X509_CA::new_crl(RandomNumberGenerator& rng,
X509_CRL X509_CA::update_crl(const X509_CRL& crl,
const std::vector<CRL_Entry>& new_revoked,
RandomNumberGenerator& rng,
- u32bit next_update) const
+ uint32_t next_update) const
{
std::vector<CRL_Entry> revoked = crl.get_revoked();
@@ -170,7 +170,7 @@ X509_CRL X509_CA::update_crl(const X509_CRL& crl,
* Create a CRL
*/
X509_CRL X509_CA::make_crl(const std::vector<CRL_Entry>& revoked,
- u32bit crl_number, u32bit next_update,
+ uint32_t crl_number, uint32_t next_update,
RandomNumberGenerator& rng) const
{
const size_t X509_CRL_VERSION = 2;
@@ -188,7 +188,7 @@ X509_CRL X509_CA::make_crl(const std::vector<CRL_Entry>& revoked,
extensions.add(new Cert_Extension::CRL_Number(crl_number));
// clang-format off
- const std::vector<byte> crl = X509_Object::make_signed(
+ const std::vector<uint8_t> crl = X509_Object::make_signed(
m_signer, rng, m_ca_sig_algo,
DER_Encoder().start_cons(SEQUENCE)
.encode(X509_CRL_VERSION-1)
diff --git a/src/lib/x509/x509_ca.h b/src/lib/x509/x509_ca.h
index 5b5eb6fc8..0448e109b 100644
--- a/src/lib/x509/x509_ca.h
+++ b/src/lib/x509/x509_ca.h
@@ -54,7 +54,7 @@ class BOTAN_DLL X509_CA
* @return new CRL
*/
X509_CRL new_crl(RandomNumberGenerator& rng,
- u32bit next_update = 0) const;
+ uint32_t next_update = 0) const;
/**
* Create a new CRL by with additional entries.
@@ -67,7 +67,7 @@ class BOTAN_DLL X509_CA
X509_CRL update_crl(const X509_CRL& last_crl,
const std::vector<CRL_Entry>& new_entries,
RandomNumberGenerator& rng,
- u32bit next_update = 0) const;
+ uint32_t next_update = 0) const;
/**
* Interface for creating new certificates
@@ -85,7 +85,7 @@ class BOTAN_DLL X509_CA
static X509_Certificate make_cert(PK_Signer* signer,
RandomNumberGenerator& rng,
const AlgorithmIdentifier& sig_algo,
- const std::vector<byte>& pub_key,
+ const std::vector<uint8_t>& pub_key,
const X509_Time& not_before,
const X509_Time& not_after,
const X509_DN& issuer_dn,
@@ -119,7 +119,7 @@ class BOTAN_DLL X509_CA
~X509_CA();
private:
X509_CRL make_crl(const std::vector<CRL_Entry>& entries,
- u32bit crl_number, u32bit next_update,
+ uint32_t crl_number, uint32_t next_update,
RandomNumberGenerator& rng) const;
AlgorithmIdentifier m_ca_sig_algo;
diff --git a/src/lib/x509/x509_crl.cpp b/src/lib/x509/x509_crl.cpp
index 8eb4c01db..65d426f20 100644
--- a/src/lib/x509/x509_crl.cpp
+++ b/src/lib/x509/x509_crl.cpp
@@ -35,7 +35,7 @@ X509_CRL::X509_CRL(const std::string& fsname, bool touc) :
}
#endif
-X509_CRL::X509_CRL(const std::vector<byte>& in, bool touc) :
+X509_CRL::X509_CRL(const std::vector<uint8_t>& in, bool touc) :
X509_Object(in, "CRL/X509 CRL"), m_throw_on_unknown_critical(touc)
{
do_decode();
@@ -62,14 +62,14 @@ bool X509_CRL::is_revoked(const X509_Certificate& cert) const
if(cert.issuer_dn() != issuer_dn())
return false;
- std::vector<byte> crl_akid = authority_key_id();
- std::vector<byte> cert_akid = cert.authority_key_id();
+ std::vector<uint8_t> crl_akid = authority_key_id();
+ std::vector<uint8_t> cert_akid = cert.authority_key_id();
if(!crl_akid.empty() && !cert_akid.empty())
if(crl_akid != cert_akid)
return false;
- std::vector<byte> cert_serial = cert.serial_number();
+ std::vector<uint8_t> cert_serial = cert.serial_number();
bool is_revoked = false;
@@ -170,7 +170,7 @@ X509_DN X509_CRL::issuer_dn() const
/*
* Return the key identifier of the issuer
*/
-std::vector<byte> X509_CRL::authority_key_id() const
+std::vector<uint8_t> X509_CRL::authority_key_id() const
{
return m_info.get1_memvec("X509v3.AuthorityKeyIdentifier");
}
@@ -178,9 +178,9 @@ std::vector<byte> X509_CRL::authority_key_id() const
/*
* Return the CRL number of this CRL
*/
-u32bit X509_CRL::crl_number() const
+uint32_t X509_CRL::crl_number() const
{
- return m_info.get1_u32bit("X509v3.CRLNumber");
+ return m_info.get1_uint32("X509v3.CRLNumber");
}
/*
diff --git a/src/lib/x509/x509_crl.h b/src/lib/x509/x509_crl.h
index e11ea8f48..ec0feb3d0 100644
--- a/src/lib/x509/x509_crl.h
+++ b/src/lib/x509/x509_crl.h
@@ -54,13 +54,13 @@ class BOTAN_DLL X509_CRL final : public X509_Object
* Get the AuthorityKeyIdentifier of this CRL.
* @return this CRLs AuthorityKeyIdentifier
*/
- std::vector<byte> authority_key_id() const;
+ std::vector<uint8_t> authority_key_id() const;
/**
* Get the serial number of this CRL.
* @return CRLs serial number
*/
- u32bit crl_number() const;
+ uint32_t crl_number() const;
/**
* Get the CRL's thisUpdate value.
@@ -99,7 +99,7 @@ class BOTAN_DLL X509_CRL final : public X509_Object
* @param throw_on_unknown_critical should we throw an exception
* if an unknown CRL extension marked as critical is encountered.
*/
- X509_CRL(const std::vector<byte>& vec,
+ X509_CRL(const std::vector<uint8_t>& vec,
bool throw_on_unknown_critical = false);
/**
diff --git a/src/lib/x509/x509_ext.cpp b/src/lib/x509/x509_ext.cpp
index 9ef14e88d..199ca6bcc 100644
--- a/src/lib/x509/x509_ext.cpp
+++ b/src/lib/x509/x509_ext.cpp
@@ -146,7 +146,7 @@ std::vector<std::pair<std::unique_ptr<Certificate_Extension>, bool>> Extensions:
return exts;
}
-std::map<OID, std::pair<std::vector<byte>, bool>> Extensions::extensions_raw() const
+std::map<OID, std::pair<std::vector<uint8_t>, bool>> Extensions::extensions_raw() const
{
return m_extensions_raw;
}
@@ -212,7 +212,7 @@ void Extensions::decode_from(BER_Decoder& from_source)
while(sequence.more_items())
{
OID oid;
- std::vector<byte> value;
+ std::vector<uint8_t> value;
bool critical;
sequence.start_cons(SEQUENCE)
@@ -278,7 +278,7 @@ size_t Basic_Constraints::get_path_limit() const
/*
* Encode the extension
*/
-std::vector<byte> Basic_Constraints::encode_inner() const
+std::vector<uint8_t> Basic_Constraints::encode_inner() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -294,7 +294,7 @@ std::vector<byte> Basic_Constraints::encode_inner() const
/*
* Decode the extension
*/
-void Basic_Constraints::decode_inner(const std::vector<byte>& in)
+void Basic_Constraints::decode_inner(const std::vector<uint8_t>& in)
{
BER_Decoder(in)
.start_cons(SEQUENCE)
@@ -313,20 +313,20 @@ void Basic_Constraints::decode_inner(const std::vector<byte>& in)
void Basic_Constraints::contents_to(Data_Store& subject, Data_Store&) const
{
subject.add("X509v3.BasicConstraints.is_ca", (m_is_ca ? 1 : 0));
- subject.add("X509v3.BasicConstraints.path_constraint", static_cast<u32bit>(m_path_limit));
+ subject.add("X509v3.BasicConstraints.path_constraint", static_cast<uint32_t>(m_path_limit));
}
/*
* Encode the extension
*/
-std::vector<byte> Key_Usage::encode_inner() const
+std::vector<uint8_t> Key_Usage::encode_inner() const
{
if(m_constraints == NO_CONSTRAINTS)
throw Encoding_Error("Cannot encode zero usage constraints");
const size_t unused_bits = low_bit(m_constraints) - 1;
- std::vector<byte> der;
+ std::vector<uint8_t> der;
der.push_back(BIT_STRING);
der.push_back(2 + ((unused_bits < 8) ? 1 : 0));
der.push_back(unused_bits % 8);
@@ -340,7 +340,7 @@ std::vector<byte> Key_Usage::encode_inner() const
/*
* Decode the extension
*/
-void Key_Usage::decode_inner(const std::vector<byte>& in)
+void Key_Usage::decode_inner(const std::vector<uint8_t>& in)
{
BER_Decoder ber(in);
@@ -358,7 +358,7 @@ void Key_Usage::decode_inner(const std::vector<byte>& in)
obj.value[obj.value.size()-1] &= (0xFF << obj.value[0]);
- u16bit usage = 0;
+ uint16_t usage = 0;
for(size_t i = 1; i != obj.value.size(); ++i)
{
usage = (obj.value[i] << 8*(sizeof(usage)-i)) | usage;
@@ -378,7 +378,7 @@ void Key_Usage::contents_to(Data_Store& subject, Data_Store&) const
/*
* Encode the extension
*/
-std::vector<byte> Subject_Key_ID::encode_inner() const
+std::vector<uint8_t> Subject_Key_ID::encode_inner() const
{
return DER_Encoder().encode(m_key_id, OCTET_STRING).get_contents_unlocked();
}
@@ -386,7 +386,7 @@ std::vector<byte> Subject_Key_ID::encode_inner() const
/*
* Decode the extension
*/
-void Subject_Key_ID::decode_inner(const std::vector<byte>& in)
+void Subject_Key_ID::decode_inner(const std::vector<uint8_t>& in)
{
BER_Decoder(in).decode(m_key_id, OCTET_STRING).verify_end();
}
@@ -402,13 +402,13 @@ void Subject_Key_ID::contents_to(Data_Store& subject, Data_Store&) const
/*
* Subject_Key_ID Constructor
*/
-Subject_Key_ID::Subject_Key_ID(const std::vector<byte>& pub_key) : m_key_id(unlock(SHA_160().process(pub_key)))
+Subject_Key_ID::Subject_Key_ID(const std::vector<uint8_t>& pub_key) : m_key_id(unlock(SHA_160().process(pub_key)))
{}
/*
* Encode the extension
*/
-std::vector<byte> Authority_Key_ID::encode_inner() const
+std::vector<uint8_t> Authority_Key_ID::encode_inner() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -420,7 +420,7 @@ std::vector<byte> Authority_Key_ID::encode_inner() const
/*
* Decode the extension
*/
-void Authority_Key_ID::decode_inner(const std::vector<byte>& in)
+void Authority_Key_ID::decode_inner(const std::vector<uint8_t>& in)
{
BER_Decoder(in)
.start_cons(SEQUENCE)
@@ -439,7 +439,7 @@ void Authority_Key_ID::contents_to(Data_Store&, Data_Store& issuer) const
/*
* Encode the extension
*/
-std::vector<byte> Alternative_Name::encode_inner() const
+std::vector<uint8_t> Alternative_Name::encode_inner() const
{
return DER_Encoder().encode(m_alt_name).get_contents_unlocked();
}
@@ -447,7 +447,7 @@ std::vector<byte> Alternative_Name::encode_inner() const
/*
* Decode the extension
*/
-void Alternative_Name::decode_inner(const std::vector<byte>& in)
+void Alternative_Name::decode_inner(const std::vector<uint8_t>& in)
{
BER_Decoder(in).decode(m_alt_name);
}
@@ -499,7 +499,7 @@ Issuer_Alternative_Name::Issuer_Alternative_Name(const AlternativeName& name) :
/*
* Encode the extension
*/
-std::vector<byte> Extended_Key_Usage::encode_inner() const
+std::vector<uint8_t> Extended_Key_Usage::encode_inner() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -511,7 +511,7 @@ std::vector<byte> Extended_Key_Usage::encode_inner() const
/*
* Decode the extension
*/
-void Extended_Key_Usage::decode_inner(const std::vector<byte>& in)
+void Extended_Key_Usage::decode_inner(const std::vector<uint8_t>& in)
{
BER_Decoder(in).decode_list(m_oids);
}
@@ -528,7 +528,7 @@ void Extended_Key_Usage::contents_to(Data_Store& subject, Data_Store&) const
/*
* Encode the extension
*/
-std::vector<byte> Name_Constraints::encode_inner() const
+std::vector<uint8_t> Name_Constraints::encode_inner() const
{
throw Not_Implemented("Name_Constraints encoding");
}
@@ -537,7 +537,7 @@ std::vector<byte> Name_Constraints::encode_inner() const
/*
* Decode the extension
*/
-void Name_Constraints::decode_inner(const std::vector<byte>& in)
+void Name_Constraints::decode_inner(const std::vector<uint8_t>& in)
{
std::vector<GeneralSubtree> permit, exclude;
BER_Decoder ber(in);
@@ -689,7 +689,7 @@ class Policy_Information : public ASN1_Object
/*
* Encode the extension
*/
-std::vector<byte> Certificate_Policies::encode_inner() const
+std::vector<uint8_t> Certificate_Policies::encode_inner() const
{
std::vector<Policy_Information> policies;
@@ -706,7 +706,7 @@ std::vector<byte> Certificate_Policies::encode_inner() const
/*
* Decode the extension
*/
-void Certificate_Policies::decode_inner(const std::vector<byte>& in)
+void Certificate_Policies::decode_inner(const std::vector<uint8_t>& in)
{
std::vector<Policy_Information> policies;
@@ -726,7 +726,7 @@ void Certificate_Policies::contents_to(Data_Store& info, Data_Store&) const
info.add("X509v3.CertificatePolicies", m_oids[i].as_string());
}
-std::vector<byte> Authority_Information_Access::encode_inner() const
+std::vector<uint8_t> Authority_Information_Access::encode_inner() const
{
ASN1_String url(m_ocsp_responder, IA5_STRING);
@@ -739,7 +739,7 @@ std::vector<byte> Authority_Information_Access::encode_inner() const
.end_cons().get_contents_unlocked();
}
-void Authority_Information_Access::decode_inner(const std::vector<byte>& in)
+void Authority_Information_Access::decode_inner(const std::vector<uint8_t>& in)
{
BER_Decoder ber = BER_Decoder(in).start_cons(SEQUENCE);
@@ -795,7 +795,7 @@ CRL_Number* CRL_Number::copy() const
/*
* Encode the extension
*/
-std::vector<byte> CRL_Number::encode_inner() const
+std::vector<uint8_t> CRL_Number::encode_inner() const
{
return DER_Encoder().encode(m_crl_number).get_contents_unlocked();
}
@@ -803,7 +803,7 @@ std::vector<byte> CRL_Number::encode_inner() const
/*
* Decode the extension
*/
-void CRL_Number::decode_inner(const std::vector<byte>& in)
+void CRL_Number::decode_inner(const std::vector<uint8_t>& in)
{
BER_Decoder(in).decode(m_crl_number);
}
@@ -813,13 +813,13 @@ void CRL_Number::decode_inner(const std::vector<byte>& in)
*/
void CRL_Number::contents_to(Data_Store& info, Data_Store&) const
{
- info.add("X509v3.CRLNumber", static_cast<u32bit>(m_crl_number));
+ info.add("X509v3.CRLNumber", static_cast<uint32_t>(m_crl_number));
}
/*
* Encode the extension
*/
-std::vector<byte> CRL_ReasonCode::encode_inner() const
+std::vector<uint8_t> CRL_ReasonCode::encode_inner() const
{
return DER_Encoder()
.encode(static_cast<size_t>(m_reason), ENUMERATED, UNIVERSAL)
@@ -829,7 +829,7 @@ std::vector<byte> CRL_ReasonCode::encode_inner() const
/*
* Decode the extension
*/
-void CRL_ReasonCode::decode_inner(const std::vector<byte>& in)
+void CRL_ReasonCode::decode_inner(const std::vector<uint8_t>& in)
{
size_t reason_code = 0;
BER_Decoder(in).decode(reason_code, ENUMERATED, UNIVERSAL);
@@ -844,12 +844,12 @@ void CRL_ReasonCode::contents_to(Data_Store& info, Data_Store&) const
info.add("X509v3.CRLReasonCode", m_reason);
}
-std::vector<byte> CRL_Distribution_Points::encode_inner() const
+std::vector<uint8_t> CRL_Distribution_Points::encode_inner() const
{
throw Not_Implemented("CRL_Distribution_Points encoding");
}
-void CRL_Distribution_Points::decode_inner(const std::vector<byte>& buf)
+void CRL_Distribution_Points::decode_inner(const std::vector<uint8_t>& buf)
{
BER_Decoder(buf).decode_list(m_distribution_points).verify_end();
}
@@ -882,12 +882,12 @@ void CRL_Distribution_Points::Distribution_Point::decode_from(class BER_Decoder&
.end_cons().end_cons();
}
-std::vector<byte> Unknown_Critical_Extension::encode_inner() const
+std::vector<uint8_t> Unknown_Critical_Extension::encode_inner() const
{
throw Not_Implemented("Unknown_Critical_Extension encoding");
}
-void Unknown_Critical_Extension::decode_inner(const std::vector<byte>&)
+void Unknown_Critical_Extension::decode_inner(const std::vector<uint8_t>&)
{
}
diff --git a/src/lib/x509/x509_ext.h b/src/lib/x509/x509_ext.h
index 1657613e7..f00535eb2 100644
--- a/src/lib/x509/x509_ext.h
+++ b/src/lib/x509/x509_ext.h
@@ -76,8 +76,8 @@ class BOTAN_DLL Certificate_Extension
protected:
friend class Extensions;
virtual bool should_encode() const { return true; }
- virtual std::vector<byte> encode_inner() const = 0;
- virtual void decode_inner(const std::vector<byte>&) = 0;
+ virtual std::vector<uint8_t> encode_inner() const = 0;
+ virtual void decode_inner(const std::vector<uint8_t>&) = 0;
};
/**
@@ -152,7 +152,7 @@ class BOTAN_DLL Extensions : public ASN1_Object
* together with the corresponding criticality flag.
* Contains all extensions, known as well as unknown extensions.
*/
- std::map<OID, std::pair<std::vector<byte>, bool>> extensions_raw() const;
+ std::map<OID, std::pair<std::vector<uint8_t>, bool>> extensions_raw() const;
Extensions& operator=(const Extensions&);
@@ -169,7 +169,7 @@ class BOTAN_DLL Extensions : public ASN1_Object
std::vector<std::pair<std::unique_ptr<Certificate_Extension>, bool>> m_extensions;
bool m_throw_on_unknown_critical;
- std::map<OID, std::pair<std::vector<byte>, bool>> m_extensions_raw;
+ std::map<OID, std::pair<std::vector<uint8_t>, bool>> m_extensions_raw;
};
namespace Cert_Extension {
@@ -195,8 +195,8 @@ class BOTAN_DLL Basic_Constraints final : public Certificate_Extension
std::string oid_name() const override
{ return "X509v3.BasicConstraints"; }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
bool m_is_ca;
@@ -220,8 +220,8 @@ class BOTAN_DLL Key_Usage final : public Certificate_Extension
bool should_encode() const override
{ return (m_constraints != NO_CONSTRAINTS); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
Key_Constraints m_constraints;
@@ -237,19 +237,19 @@ class BOTAN_DLL Subject_Key_ID final : public Certificate_Extension
{ return new Subject_Key_ID(m_key_id); }
Subject_Key_ID() {}
- explicit Subject_Key_ID(const std::vector<byte>&);
+ explicit Subject_Key_ID(const std::vector<uint8_t>&);
- std::vector<byte> get_key_id() const { return m_key_id; }
+ std::vector<uint8_t> get_key_id() const { return m_key_id; }
private:
std::string oid_name() const override
{ return "X509v3.SubjectKeyIdentifier"; }
bool should_encode() const override { return (m_key_id.size() > 0); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
- std::vector<byte> m_key_id;
+ std::vector<uint8_t> m_key_id;
};
/**
@@ -262,20 +262,20 @@ class BOTAN_DLL Authority_Key_ID final : public Certificate_Extension
{ return new Authority_Key_ID(m_key_id); }
Authority_Key_ID() {}
- explicit Authority_Key_ID(const std::vector<byte>& k) : m_key_id(k) {}
+ explicit Authority_Key_ID(const std::vector<uint8_t>& k) : m_key_id(k) {}
- std::vector<byte> get_key_id() const { return m_key_id; }
+ std::vector<uint8_t> get_key_id() const { return m_key_id; }
private:
std::string oid_name() const override
{ return "X509v3.AuthorityKeyIdentifier"; }
bool should_encode() const override { return (m_key_id.size() > 0); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
- std::vector<byte> m_key_id;
+ std::vector<uint8_t> m_key_id;
};
/**
@@ -295,8 +295,8 @@ class BOTAN_DLL Alternative_Name : public Certificate_Extension
std::string oid_name() const override { return m_oid_name_str; }
bool should_encode() const override { return m_alt_name.has_items(); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
std::string m_oid_name_str;
@@ -346,8 +346,8 @@ class BOTAN_DLL Extended_Key_Usage final : public Certificate_Extension
{ return "X509v3.ExtendedKeyUsage"; }
bool should_encode() const override { return (m_oids.size() > 0); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
std::vector<OID> m_oids;
@@ -375,8 +375,8 @@ class BOTAN_DLL Name_Constraints : public Certificate_Extension
{ return "X509v3.NameConstraints"; }
bool should_encode() const override { return true; }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
NameConstraints m_name_constraints;
@@ -401,8 +401,8 @@ class BOTAN_DLL Certificate_Policies final : public Certificate_Extension
{ return "X509v3.CertificatePolicies"; }
bool should_encode() const override { return (m_oids.size() > 0); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
std::vector<OID> m_oids;
@@ -425,8 +425,8 @@ class BOTAN_DLL Authority_Information_Access final : public Certificate_Extensio
bool should_encode() const override { return (!m_ocsp_responder.empty()); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
@@ -450,8 +450,8 @@ class BOTAN_DLL CRL_Number final : public Certificate_Extension
std::string oid_name() const override { return "X509v3.CRLNumber"; }
bool should_encode() const override { return m_has_value; }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
bool m_has_value;
@@ -475,8 +475,8 @@ class BOTAN_DLL CRL_ReasonCode final : public Certificate_Extension
std::string oid_name() const override { return "X509v3.ReasonCode"; }
bool should_encode() const override { return (m_reason != UNSPECIFIED); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
CRL_Code m_reason;
@@ -517,8 +517,8 @@ class BOTAN_DLL CRL_Distribution_Points final : public Certificate_Extension
bool should_encode() const override
{ return !m_distribution_points.empty(); }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
std::vector<Distribution_Point> m_distribution_points;
@@ -552,8 +552,8 @@ class BOTAN_DLL Unknown_Critical_Extension final : public Certificate_Extension
{ return "Unknown OID name"; }
bool should_encode() const override { return false; }
- std::vector<byte> encode_inner() const override;
- void decode_inner(const std::vector<byte>&) override;
+ std::vector<uint8_t> encode_inner() const override;
+ void decode_inner(const std::vector<uint8_t>&) override;
void contents_to(Data_Store&, Data_Store&) const override;
OID m_oid;
diff --git a/src/lib/x509/x509_obj.cpp b/src/lib/x509/x509_obj.cpp
index 3c5d2a9b4..cc97c1f15 100644
--- a/src/lib/x509/x509_obj.cpp
+++ b/src/lib/x509/x509_obj.cpp
@@ -39,7 +39,7 @@ X509_Object::X509_Object(const std::string& file, const std::string& labels)
/*
* Create a generic X.509 object
*/
-X509_Object::X509_Object(const std::vector<byte>& vec, const std::string& labels)
+X509_Object::X509_Object(const std::vector<uint8_t>& vec, const std::string& labels)
{
DataSource_Memory stream(vec.data(), vec.size());
init(stream, labels);
@@ -112,7 +112,7 @@ void X509_Object::decode_from(BER_Decoder& from)
/*
* Return a BER encoded X.509 object
*/
-std::vector<byte> X509_Object::BER_encode() const
+std::vector<uint8_t> X509_Object::BER_encode() const
{
DER_Encoder der;
encode_into(der);
@@ -130,7 +130,7 @@ std::string X509_Object::PEM_encode() const
/*
* Return the TBS data
*/
-std::vector<byte> X509_Object::tbs_data() const
+std::vector<uint8_t> X509_Object::tbs_data() const
{
return ASN1::put_in_sequence(m_tbs_bits);
}
@@ -138,7 +138,7 @@ std::vector<byte> X509_Object::tbs_data() const
/*
* Return the signature of this object
*/
-std::vector<byte> X509_Object::signature() const
+std::vector<uint8_t> X509_Object::signature() const
{
return m_sig;
}
@@ -212,10 +212,10 @@ bool X509_Object::check_signature(const Public_Key& pub_key) const
/*
* Apply the X.509 SIGNED macro
*/
-std::vector<byte> X509_Object::make_signed(PK_Signer* signer,
+std::vector<uint8_t> X509_Object::make_signed(PK_Signer* signer,
RandomNumberGenerator& rng,
const AlgorithmIdentifier& algo,
- const secure_vector<byte>& tbs_bits)
+ const secure_vector<uint8_t>& tbs_bits)
{
return DER_Encoder()
.start_cons(SEQUENCE)
diff --git a/src/lib/x509/x509_obj.h b/src/lib/x509/x509_obj.h
index 40324775c..c2bf7b9c2 100644
--- a/src/lib/x509/x509_obj.h
+++ b/src/lib/x509/x509_obj.h
@@ -26,12 +26,12 @@ class BOTAN_DLL X509_Object : public ASN1_Object
* The underlying data that is to be or was signed
* @return data that is or was signed
*/
- std::vector<byte> tbs_data() const;
+ std::vector<uint8_t> tbs_data() const;
/**
* @return signature on tbs_data()
*/
- std::vector<byte> signature() const;
+ std::vector<uint8_t> signature() const;
/**
* @return signature algorithm that was used to generate signature
@@ -51,10 +51,10 @@ class BOTAN_DLL X509_Object : public ASN1_Object
* @param tbs the tbs bits to be signed
* @return signed X509 object
*/
- static std::vector<byte> make_signed(class PK_Signer* signer,
+ static std::vector<uint8_t> make_signed(class PK_Signer* signer,
RandomNumberGenerator& rng,
const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& tbs);
+ const secure_vector<uint8_t>& tbs);
/**
* Check the signature on this data
@@ -86,7 +86,7 @@ class BOTAN_DLL X509_Object : public ASN1_Object
/**
* @return BER encoding of this
*/
- std::vector<byte> BER_encode() const;
+ std::vector<uint8_t> BER_encode() const;
/**
* @return PEM encoding of this
@@ -96,7 +96,7 @@ class BOTAN_DLL X509_Object : public ASN1_Object
virtual ~X509_Object() {}
protected:
X509_Object(DataSource& src, const std::string& pem_labels);
- X509_Object(const std::vector<byte>& vec, const std::string& labels);
+ X509_Object(const std::vector<uint8_t>& vec, const std::string& labels);
#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
X509_Object(const std::string& file, const std::string& pem_labels);
@@ -105,7 +105,7 @@ class BOTAN_DLL X509_Object : public ASN1_Object
void do_decode();
X509_Object() {}
AlgorithmIdentifier m_sig_algo;
- std::vector<byte> m_tbs_bits, m_sig;
+ std::vector<uint8_t> m_tbs_bits, m_sig;
private:
virtual void force_decode() = 0;
void init(DataSource&, const std::string&);
diff --git a/src/lib/x509/x509cert.cpp b/src/lib/x509/x509cert.cpp
index 52802a8e4..e53034dce 100644
--- a/src/lib/x509/x509cert.cpp
+++ b/src/lib/x509/x509cert.cpp
@@ -66,7 +66,7 @@ X509_Certificate::X509_Certificate(const std::string& fsname) :
/*
* X509_Certificate Constructor
*/
-X509_Certificate::X509_Certificate(const std::vector<byte>& in) :
+X509_Certificate::X509_Certificate(const std::vector<uint8_t>& in) :
X509_Object(in, "CERTIFICATE/X509 CERTIFICATE"),
m_self_signed(false),
m_v3_extensions(false)
@@ -116,7 +116,7 @@ void X509_Certificate::force_decode()
throw BER_Bad_Tag("X509_Certificate: Unexpected tag for public key",
public_key.type_tag, public_key.class_tag);
- std::vector<byte> v2_issuer_key_id, v2_subject_key_id;
+ std::vector<uint8_t> v2_issuer_key_id, v2_subject_key_id;
tbs_cert.decode_optional_string(v2_issuer_key_id, BIT_STRING, 1);
tbs_cert.decode_optional_string(v2_subject_key_id, BIT_STRING, 2);
@@ -135,7 +135,7 @@ void X509_Certificate::force_decode()
if(tbs_cert.more_items())
throw Decoding_Error("TBSCertificate has more items that expected");
- m_subject.add("X509.Certificate.version", static_cast<u32bit>(version));
+ m_subject.add("X509.Certificate.version", static_cast<uint32_t>(version));
m_subject.add("X509.Certificate.serial", BigInt::encode(serial_bn));
m_subject.add("X509.Certificate.start", start.to_string());
m_subject.add("X509.Certificate.end", end.to_string());
@@ -164,16 +164,16 @@ void X509_Certificate::force_decode()
const size_t limit = (x509_version() < 3) ?
Cert_Extension::NO_CERT_PATH_LIMIT : 0;
- m_subject.add("X509v3.BasicConstraints.path_constraint", static_cast<u32bit>(limit));
+ m_subject.add("X509v3.BasicConstraints.path_constraint", static_cast<uint32_t>(limit));
}
}
/*
* Return the X.509 version in use
*/
-u32bit X509_Certificate::x509_version() const
+uint32_t X509_Certificate::x509_version() const
{
- return (m_subject.get1_u32bit("X509.Certificate.version") + 1);
+ return (m_subject.get1_uint32("X509.Certificate.version") + 1);
}
/*
@@ -219,18 +219,18 @@ Public_Key* X509_Certificate::subject_public_key() const
ASN1::put_in_sequence(this->subject_public_key_bits()));
}
-std::vector<byte> X509_Certificate::subject_public_key_bits() const
+std::vector<uint8_t> X509_Certificate::subject_public_key_bits() const
{
return hex_decode(m_subject.get1("X509.Certificate.public_key"));
}
-std::vector<byte> X509_Certificate::subject_public_key_bitstring() const
+std::vector<uint8_t> X509_Certificate::subject_public_key_bitstring() const
{
// TODO: cache this
- const std::vector<byte> key_bits = subject_public_key_bits();
+ const std::vector<uint8_t> key_bits = subject_public_key_bits();
AlgorithmIdentifier public_key_algid;
- std::vector<byte> public_key_bitstr;
+ std::vector<uint8_t> public_key_bitstr;
BER_Decoder(key_bits)
.decode(public_key_algid)
@@ -239,7 +239,7 @@ std::vector<byte> X509_Certificate::subject_public_key_bitstring() const
return public_key_bitstr;
}
-std::vector<byte> X509_Certificate::subject_public_key_bitstring_sha1() const
+std::vector<uint8_t> X509_Certificate::subject_public_key_bitstring_sha1() const
{
// TODO: cache this value
std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-1"));
@@ -252,7 +252,7 @@ std::vector<byte> X509_Certificate::subject_public_key_bitstring_sha1() const
*/
bool X509_Certificate::is_CA_cert() const
{
- if(!m_subject.get1_u32bit("X509v3.BasicConstraints.is_ca"))
+ if(!m_subject.get1_uint32("X509v3.BasicConstraints.is_ca"))
return false;
return allowed_usage(Key_Constraints(KEY_CERT_SIGN));
@@ -333,9 +333,9 @@ bool X509_Certificate::has_ex_constraint(const std::string& ex_constraint) const
/*
* Return the path length constraint
*/
-u32bit X509_Certificate::path_limit() const
+uint32_t X509_Certificate::path_limit() const
{
- return m_subject.get1_u32bit("X509v3.BasicConstraints.path_constraint", 0);
+ return m_subject.get1_uint32("X509v3.BasicConstraints.path_constraint", 0);
}
/*
@@ -343,7 +343,7 @@ u32bit X509_Certificate::path_limit() const
*/
bool X509_Certificate::is_critical(const std::string& ex_name) const
{
- return !!m_subject.get1_u32bit(ex_name + ".is_critical",0);
+ return !!m_subject.get1_uint32(ex_name + ".is_critical",0);
}
/*
@@ -351,7 +351,7 @@ bool X509_Certificate::is_critical(const std::string& ex_name) const
*/
Key_Constraints X509_Certificate::constraints() const
{
- return Key_Constraints(m_subject.get1_u32bit("X509v3.KeyUsage",
+ return Key_Constraints(m_subject.get1_uint32("X509v3.KeyUsage",
NO_CONSTRAINTS));
}
@@ -409,7 +409,7 @@ std::string X509_Certificate::crl_distribution_point() const
/*
* Return the authority key id
*/
-std::vector<byte> X509_Certificate::authority_key_id() const
+std::vector<uint8_t> X509_Certificate::authority_key_id() const
{
return m_issuer.get1_memvec("X509v3.AuthorityKeyIdentifier");
}
@@ -417,7 +417,7 @@ std::vector<byte> X509_Certificate::authority_key_id() const
/*
* Return the subject key id
*/
-std::vector<byte> X509_Certificate::subject_key_id() const
+std::vector<uint8_t> X509_Certificate::subject_key_id() const
{
return m_subject.get1_memvec("X509v3.SubjectKeyIdentifier");
}
@@ -425,7 +425,7 @@ std::vector<byte> X509_Certificate::subject_key_id() const
/*
* Return the certificate serial number
*/
-std::vector<byte> X509_Certificate::serial_number() const
+std::vector<uint8_t> X509_Certificate::serial_number() const
{
return m_subject.get1_memvec("X509.Certificate.serial");
}
@@ -435,7 +435,7 @@ X509_DN X509_Certificate::issuer_dn() const
return create_dn(m_issuer);
}
-std::vector<byte> X509_Certificate::raw_issuer_dn() const
+std::vector<uint8_t> X509_Certificate::raw_issuer_dn() const
{
return m_issuer.get1_memvec("X509.Certificate.dn_bits");
}
@@ -445,7 +445,7 @@ X509_DN X509_Certificate::subject_dn() const
return create_dn(m_subject);
}
-std::vector<byte> X509_Certificate::raw_subject_dn() const
+std::vector<uint8_t> X509_Certificate::raw_subject_dn() const
{
return m_subject.get1_memvec("X509.Certificate.dn_bits");
}
diff --git a/src/lib/x509/x509cert.h b/src/lib/x509/x509cert.h
index 5cf7c81fa..c6887f4e5 100644
--- a/src/lib/x509/x509cert.h
+++ b/src/lib/x509/x509cert.h
@@ -46,20 +46,20 @@ class BOTAN_DLL X509_Certificate : public X509_Object
* Get the public key associated with this certificate.
* @return subject public key of this certificate
*/
- std::vector<byte> subject_public_key_bits() const;
+ std::vector<uint8_t> subject_public_key_bits() const;
/**
* Get the bit string of the public key associated with this certificate
* @return subject public key of this certificate
*/
- std::vector<byte> subject_public_key_bitstring() const;
+ std::vector<uint8_t> subject_public_key_bitstring() const;
/**
* Get the SHA-1 bit string of the public key associated with this certificate.
* This is used for OCSP among other protocols
* @return hash of subject public key of this certificate
*/
- std::vector<byte> subject_public_key_bitstring_sha1() const;
+ std::vector<uint8_t> subject_public_key_bitstring_sha1() const;
/**
* Get the certificate's issuer distinguished name (DN).
@@ -98,12 +98,12 @@ class BOTAN_DLL X509_Certificate : public X509_Object
/**
* Raw subject DN
*/
- std::vector<byte> raw_issuer_dn() const;
+ std::vector<uint8_t> raw_issuer_dn() const;
/**
* Raw issuer DN
*/
- std::vector<byte> raw_subject_dn() const;
+ std::vector<uint8_t> raw_subject_dn() const;
/**
* Get the notBefore of the certificate.
@@ -121,25 +121,25 @@ class BOTAN_DLL X509_Certificate : public X509_Object
* Get the X509 version of this certificate object.
* @return X509 version
*/
- u32bit x509_version() const;
+ uint32_t x509_version() const;
/**
* Get the serial number of this certificate.
* @return certificates serial number
*/
- std::vector<byte> serial_number() const;
+ std::vector<uint8_t> serial_number() const;
/**
* Get the DER encoded AuthorityKeyIdentifier of this certificate.
* @return DER encoded AuthorityKeyIdentifier
*/
- std::vector<byte> authority_key_id() const;
+ std::vector<uint8_t> authority_key_id() const;
/**
* Get the DER encoded SubjectKeyIdentifier of this certificate.
* @return DER encoded SubjectKeyIdentifier
*/
- std::vector<byte> subject_key_id() const;
+ std::vector<uint8_t> subject_key_id() const;
/**
* Check whether this certificate is self signed.
@@ -191,7 +191,7 @@ class BOTAN_DLL X509_Certificate : public X509_Object
* this certificate.
* @return path limit
*/
- u32bit path_limit() const;
+ uint32_t path_limit() const;
/**
* Check whenever a given X509 Extension is marked critical in this
@@ -293,7 +293,7 @@ class BOTAN_DLL X509_Certificate : public X509_Object
* Create a certificate from a buffer
* @param in the buffer containing the DER-encoded certificate
*/
- explicit X509_Certificate(const std::vector<byte>& in);
+ explicit X509_Certificate(const std::vector<uint8_t>& in);
X509_Certificate(const X509_Certificate& other) = default;
diff --git a/src/lib/x509/x509opt.cpp b/src/lib/x509/x509opt.cpp
index 2dd2098fe..79c735a0f 100644
--- a/src/lib/x509/x509opt.cpp
+++ b/src/lib/x509/x509opt.cpp
@@ -65,7 +65,7 @@ void X509_Cert_Options::CA_key(size_t limit)
* Initialize the certificate options
*/
X509_Cert_Options::X509_Cert_Options(const std::string& initial_opts,
- u32bit expiration_time)
+ uint32_t expiration_time)
{
is_CA = false;
path_limit = 0;
diff --git a/src/lib/x509/x509path.cpp b/src/lib/x509/x509path.cpp
index 5c1e94ff8..37314a154 100644
--- a/src/lib/x509/x509path.cpp
+++ b/src/lib/x509/x509path.cpp
@@ -443,7 +443,7 @@ PKIX::build_certificate_path(std::vector<std::shared_ptr<const X509_Certificate>
{
const X509_Certificate& last = *cert_path.back();
const X509_DN issuer_dn = last.issuer_dn();
- const std::vector<byte> auth_key_id = last.authority_key_id();
+ const std::vector<uint8_t> auth_key_id = last.authority_key_id();
std::shared_ptr<const X509_Certificate> issuer;
bool trusted_issuer = false;
diff --git a/src/lib/x509/x509self.cpp b/src/lib/x509/x509self.cpp
index fe0336014..b8f8fbdc8 100644
--- a/src/lib/x509/x509self.cpp
+++ b/src/lib/x509/x509self.cpp
@@ -50,7 +50,7 @@ X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts,
X509_DN subject_dn;
AlternativeName subject_alt;
- std::vector<byte> pub_key = X509::BER_encode(key);
+ std::vector<uint8_t> pub_key = X509::BER_encode(key);
std::unique_ptr<PK_Signer> signer(choose_sig_format(key, rng, hash_fn, sig_algo));
load_info(opts, subject_dn, subject_alt);
@@ -102,7 +102,7 @@ PKCS10_Request create_cert_req(const X509_Cert_Options& opts,
X509_DN subject_dn;
AlternativeName subject_alt;
- std::vector<byte> pub_key = X509::BER_encode(key);
+ std::vector<uint8_t> pub_key = X509::BER_encode(key);
std::unique_ptr<PK_Signer> signer(choose_sig_format(key, rng, hash_fn, sig_algo));
load_info(opts, subject_dn, subject_alt);
@@ -165,7 +165,7 @@ PKCS10_Request create_cert_req(const X509_Cert_Options& opts,
.end_explicit()
.end_cons();
- const std::vector<byte> req =
+ const std::vector<uint8_t> req =
X509_Object::make_signed(signer.get(), rng, sig_algo,
tbs_req.get_contents());
diff --git a/src/lib/x509/x509self.h b/src/lib/x509/x509self.h
index 008eece51..156e41f8a 100644
--- a/src/lib/x509/x509self.h
+++ b/src/lib/x509/x509self.h
@@ -163,7 +163,7 @@ class BOTAN_DLL X509_Cert_Options
* @param expire_time the expiration time (from the current clock in seconds)
*/
X509_Cert_Options(const std::string& opts = "",
- u32bit expire_time = 365 * 24 * 60 * 60);
+ uint32_t expire_time = 365 * 24 * 60 * 60);
};
namespace X509 {