diff --git a/Crypto/Integer/Integer.h b/Crypto/Integer/Integer.h index e2a39ec..3cdb6b5 100644 --- a/Crypto/Integer/Integer.h +++ b/Crypto/Integer/Integer.h @@ -13,12 +13,16 @@ /* uint2048_t is a class that behaves similar to a regular built in type - however it can represent arbitarily large values, eg 1024 bit numbers + however it can represent arbitrarily large values, eg 1024 bit numbers which is commonly the case in cryptographic code or other special uses of maths. As its name suggests, it only holds integers, and positive ones at that. Treat it like you would an unsigned int that can't overflow, and in the case where it could go negative, it truncates to zero (this happens when subtracting a larger number from a smaller one). + + Note that this class has optimizations depending on the size of the + numbers used, so it could be susceptible to timing based side-channel + attacks. */ class uint2048_t { diff --git a/Crypto/Integer/Integer.h b/Crypto/Integer/Integer.h index e2a39ec..3cdb6b5 100644 --- a/Crypto/Integer/Integer.h +++ b/Crypto/Integer/Integer.h @@ -13,12 +13,16 @@ /* uint2048_t is a class that behaves similar to a regular built in type - however it can represent arbitarily large values, eg 1024 bit numbers + however it can represent arbitrarily large values, eg 1024 bit numbers which is commonly the case in cryptographic code or other special uses of maths. As its name suggests, it only holds integers, and positive ones at that. Treat it like you would an unsigned int that can't overflow, and in the case where it could go negative, it truncates to zero (this happens when subtracting a larger number from a smaller one). + + Note that this class has optimizations depending on the size of the + numbers used, so it could be susceptible to timing based side-channel + attacks. */ class uint2048_t { diff --git a/Crypto/Integer/main.cpp b/Crypto/Integer/main.cpp index ff34d43..0ce2dc6 100644 --- a/Crypto/Integer/main.cpp +++ b/Crypto/Integer/main.cpp @@ -39,24 +39,24 @@ T data(secretMessage); T exponent(publicExponent); T modulus(publicModulus); - T result = T::ExpMod(data, exponent, modulus); - size_t siz = result.Size(); - if (debug) - { - printf("\ndata: "); data.Print(); - printf("\nexponent: "); exponent.Print(); - printf("\nmodulus: "); modulus.Print(); - printf("\nresult: "); result.Print(); - printf("\nsize: %i", int(siz)); - } - printf("\nmessage: \n"); - for (size_t i = 0; i < siz; i++) - { - unsigned int val = result[siz-1-i]; - if (isprint(val) || isspace(val)) - printf("%c", val); - } - printf("\n"); + T result = T::ExpMod(data, exponent, modulus); + size_t siz = result.Size(); + if (debug) + { + printf("\ndata: "); data.Print(); + printf("\nexponent: "); exponent.Print(); + printf("\nmodulus: "); modulus.Print(); + printf("\nresult: "); result.Print(); + printf("\nsize: %i", int(siz)); + } + printf("\nmessage: \n"); + for (size_t i = 0; i < siz; i++) + { + unsigned int val = result[siz-1-i]; + if (isprint(val) || isspace(val)) + printf("%c", val); + } + printf("\n"); }