@@ -72,7 +72,7 @@ void pow_mod_faster(_Ptr<struct bn> a, _Ptr<struct bn> b, _Ptr<struct bn> n, _Pt
7272static void test_rsa_1 (void )
7373{
7474 /* Testing with very small and simple terms */
75- char buf _Nt_checked [8192 ];
75+ char buf _Nt_checked [8193 ];
7676 struct bn M = {};
7777struct bn C = {};
7878struct bn E = {};
@@ -109,7 +109,7 @@ struct bn N = {};
109109 bignum_from_int (& N , n );
110110 pow_mod_faster (& M , & E , & N , & C );
111111 c_result = bignum_to_int (& C );
112- bignum_to_string (& C , buf , sizeof (buf ));
112+ bignum_to_string (& C , buf , sizeof (buf )- 1 );
113113 printf (" %d ^ %d mod %d = %d \n" , m , e , n , c_result );
114114 printf (" %d ^ %d mod %d = %s \n" , m , e , n , buf );
115115
@@ -119,7 +119,7 @@ struct bn N = {};
119119 printf (" %d ^ %d mod %d = %d ? \n" , c , d , n , m );
120120 pow_mod_faster (& C , & D , & N , & M );
121121 m_result = bignum_to_int (& M );
122- bignum_to_string (& M , buf , sizeof (buf ));
122+ bignum_to_string (& M , buf , sizeof (buf )- 1 );
123123 printf (" %d ^ %d mod %d = %d \n" , c , d , n , m_result );
124124 printf (" %d ^ %d mod %d = %s \n" , c , d , n , buf );
125125
@@ -132,7 +132,7 @@ struct bn N = {};
132132
133133void test_rsa_2 (void )
134134{
135- char buf _Nt_checked [8192 ];
135+ char buf _Nt_checked [8193 ];
136136 struct bn M = {};
137137struct bn C = {};
138138struct bn E = {};
@@ -169,7 +169,7 @@ struct bn N = {};
169169 bignum_from_int (& N , n );
170170 pow_mod_faster (& M , & E , & N , & C );
171171 c_result = bignum_to_int (& C );
172- bignum_to_string (& C , buf , sizeof (buf ));
172+ bignum_to_string (& C , buf , sizeof (buf )- 1 );
173173 printf (" %d ^ %d mod %d = %d \n" , m , e , n , c_result );
174174 printf (" %d ^ %d mod %d = %s \n" , m , e , n , buf );
175175
@@ -179,7 +179,7 @@ struct bn N = {};
179179 printf (" %d ^ %d mod %d = %d ? \n" , c , d , n , m );
180180 pow_mod_faster (& C , & D , & N , & M );
181181 m_result = bignum_to_int (& M );
182- bignum_to_string (& M , buf , sizeof (buf ));
182+ bignum_to_string (& M , buf , sizeof (buf )- 1 );
183183 printf (" %d ^ %d mod %d = %s \n" , c , d , n , buf );
184184 printf (" %d ^ %d mod %d = %d \n" , c , d , n , m_result );
185185
@@ -189,7 +189,7 @@ struct bn N = {};
189189
190190void test_rsa_3 (void )
191191{
192- char buf _Nt_checked [8192 ];
192+ char buf _Nt_checked [8193 ];
193193 struct bn M = {};
194194struct bn C = {};
195195struct bn E = {};
@@ -226,7 +226,7 @@ struct bn N = {};
226226 bignum_from_int (& N , n );
227227 pow_mod_faster (& M , & E , & N , & C );
228228 c_result = bignum_to_int (& C );
229- bignum_to_string (& C , buf , sizeof (buf ));
229+ bignum_to_string (& C , buf , sizeof (buf )- 1 );
230230 printf (" %d ^ %d mod %d = %d \n" , m , e , n , c_result );
231231 printf (" %d ^ %d mod %d = %s \n" , m , e , n , buf );
232232
@@ -236,7 +236,7 @@ struct bn N = {};
236236 printf (" %d ^ %d mod %d = %d ? \n" , c , d , n , m );
237237 pow_mod_faster (& C , & D , & N , & M );
238238 m_result = bignum_to_int (& M );
239- bignum_to_string (& M , buf , sizeof (buf ));
239+ bignum_to_string (& M , buf , sizeof (buf )- 1 );
240240 printf (" %d ^ %d mod %d = %s \n" , c , d , n , buf );
241241 printf (" %d ^ %d mod %d = %d \n" , c , d , n , m_result );
242242
@@ -250,7 +250,7 @@ static void test_rsa1024(void)
250250{
251251 char public _Nt_checked [] = "a15f36fc7f8d188057fc51751962a5977118fa2ad4ced249c039ce36c8d1bd275273f1edd821892fa75680b1ae38749fff9268bf06b3c2af02bbdb52a0d05c2ae2384aa1002391c4b16b87caea8296cfd43757bb51373412e8fe5df2e56370505b692cf8d966e3f16bc62629874a0464a9710e4a0718637a68442e0eb1648ec5" ;
252252 char private _Nt_checked [] = "3f5cc8956a6bf773e598604faf71097e265d5d55560c038c0bdb66ba222e20ac80f69fc6f93769cb795440e2037b8d67898d6e6d9b6f180169fc6348d5761ac9e81f6b8879529bc07c28dc92609eb8a4d15ac4ba3168a331403c689b1e82f62518c38601d58fd628fcb7009f139fb98e61ef7a23bee4e3d50af709638c24133d" ;
253- char buf _Nt_checked [8192 ];
253+ char buf _Nt_checked [8193 ];
254254
255255 struct bn n = {}; /* public key */
256256 struct bn d = {}; /* private key */
@@ -276,7 +276,7 @@ static void test_rsa1024(void)
276276 bignum_init (& c );
277277
278278 bignum_from_int (& m , x );
279- bignum_to_string (& m , buf , sizeof (buf ));
279+ bignum_to_string (& m , buf , sizeof (buf )- 1 );
280280 printf ("m = %s \n" , buf );
281281
282282//printf(" Copied %d bytes into m\n", i);
@@ -285,7 +285,7 @@ static void test_rsa1024(void)
285285 pow_mod_faster (& m , & e , & n , & c );
286286 printf (" Done...\n\n" );
287287
288- bignum_to_string (& c , buf , sizeof (buf ));
288+ bignum_to_string (& c , buf , sizeof (buf )- 1 );
289289 printf (" Decrypting cipher text '" );
290290 int i = 0 ;
291291 while (buf [i ] != 0 )
@@ -302,7 +302,7 @@ static void test_rsa1024(void)
302302 printf (" Done...\n\n" );
303303
304304
305- bignum_to_string (& m , buf , sizeof (buf ));
305+ bignum_to_string (& m , buf , sizeof (buf )- 1 );
306306 printf ("m = %s \n" , buf );
307307}
308308
0 commit comments