Permalink
Browse files

Make test cleaner

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/fortuna@24396 dc483132-0cff-0310-8789-dd5450dbe970
  • Loading branch information...
1 parent 8275c06 commit 70e6a34ee53a9a4f5a8020c9671e6618757c5d10 tsitkova committed Sep 30, 2010
@@ -43,7 +43,7 @@ else
endif
clean::
- $(RM) t_fortuna$(EXEEXT) t_fortuna.$(OBJEXT)
+ $(RM) t_fortuna$(EXEEXT) t_fortuna.$(OBJEXT) t_fortuna_make_oct.result t_fortuna_make_oct$(EXEEXT) t_fortuna_make_oct.$(OBJEXT)
clean-unix:: clean-libobjs
@@ -13,7 +13,6 @@ k5_entropy_from_device(krb5_context context, const char *device, unsigned char*
{
struct stat sb;
int fd;
- //unsigned char buf[ENTROPY_BUFSIZE], *bp;
unsigned char *bp;
size_t left;
fd = open(device, O_RDONLY);
@@ -42,12 +41,14 @@ k5_entropy_from_device(krb5_context context, const char *device, unsigned char*
krb5_error_code
k5_entropy_dev_random(krb5_context context, unsigned char* buf, int buflen)
{
+ memset(buf, 0, buflen);
return k5_entropy_from_device(context,"/dev/random", buf, buflen);
}
krb5_error_code
k5_entropy_dev_urandom(krb5_context context, unsigned char* buf, int buflen)
{
+ memset(buf, 0, buflen);
return k5_entropy_from_device(context,"/dev/urandom", buf, buflen);
}
@@ -56,6 +57,7 @@ k5_entropy_pid(krb5_context context, unsigned char* buf, int buflen)
{
pid_t pid = getpid();
int pidlen = min(buflen,(int)sizeof(&pid));
+ memset(buf, 0, buflen);
memcpy(buf, &pid, pidlen);
return 0;
}
@@ -65,6 +67,7 @@ k5_entropy_uid(krb5_context context, unsigned char* buf, int buflen)
{
pid_t uid = getuid();
int uidlen=min(buflen,(int)sizeof(&uid));
+ memset(buf, 0, buflen);
memcpy(buf, &uid, uidlen);
return 0;
}
@@ -73,9 +76,9 @@ k5_entropy_uid(krb5_context context, unsigned char* buf, int buflen)
int
test_entr(krb5_context context, unsigned char* buf, int buflen)
{
- char buf1[4] = "abc";
+ char buf1[26] = "Seed To Test Fortuna PRNG";
memset(buf, 0, buflen);
- memcpy(buf, buf1, min(buflen,4));
+ memcpy(buf, buf1, min(buflen, 26));
return 0;
}
#endif
@@ -312,16 +312,16 @@ reseed(FState * st)
break;
n >>= 1;
}
-
/* add old key into mix too */
md_update(&key_md, st->key, BLOCK);
+#ifndef TEST_FORTUNA
/* add pid to make output diverse after fork() */
md_update(&key_md, (const unsigned char *)&st->pid, sizeof(st->pid));
+#endif
/* now we have new key */
md_result(&key_md, st->key);
-
/* use new key */
ciph_init(&st->ciph, st->key, BLOCK);
@@ -428,14 +428,11 @@ extract_data(FState * st, unsigned count, unsigned char *dst)
unsigned block_nr = 0;
pid_t pid = getpid();
-#ifndef TEST_FORTUNA
/* Should we reseed? */
if (st->pool0_bytes >= POOL0_FILL || st->reseed_count == 0)
if (enough_time_passed(st))
reseed(st);
-#else
- ciph_init(&st->ciph, st->key, BLOCK);
-#endif
+
/* Do some randomization on first call */
if (!st->tricks_done)
startup_tricks(st);
@@ -35,7 +35,7 @@
#include "fortuna.h"
#include <k5-int.h>
-#define LEN_TEST_BUF 4096
+#define LEN_TEST_BUF 1024
static int len = LEN_TEST_BUF;
static void hex_print( FILE* f, const char* var, void* data, size_t size );
@@ -52,7 +52,15 @@ main(int argc, char **argv)
krb5_c_random_make_octets(NULL, &data);
- hex_print( stdout, "random", data.data, data.length );
+ hex_print( stdout, "random1", data.data, data.length );
+
+ /* To target FORTUNA_RESEED_BYTE */
+ i = 0;
+ while (i++ < 11){
+ krb5_c_random_make_octets(NULL, &data);
+ }
+
+ hex_print( stdout, "random2", data.data, data.length );
return 0;
}
@@ -1 +1,2 @@
-random = 2a435cb9434359328c3e7d98aa12efe6d63ae6525176a5ac2a362d5343298aaa019b8a3c7e4278ad77b770702404da1c9463983a5dd1dfa6075577f572d10c94f53c3feae648916f738c7466aa6dd33a8d4c921e182c9020bcc758568e7a3d571ec67ca7a38783db2200c3fce81478aac0e0ef9ef1c2b2b5e7555bffe3f10bd24e9b7d876e68a41ebd40b473199121e811c20f4f27d6a148aed1fdd03bbb413208b7cd67672ab0e830ab33de5ce6fd597346eaf1695100006e53d2ab3b13207cd274bc33b872967c8e6fdbf3f1b49720a5c82f68dfe06381a2b7eabde81ffb6e31d1a607043a1d5dc3ab6158d059582670eb79a897597d74f57ace23690597cc836d6d3c50be4ababedfe648625d1dde8184d038ef8eb70694c5f462ecc76bd50014104199ece93e5e2b0220508f1d1cb637bdb5722bfa996e60709c6ef704d1d90a93fe40a94700d4f27639ae42a11a8b2a84ff5630eb6f899c0b69b96c9c82c498b8f972ac762631da8ba68e4c9816cc80b48e731f4c6fa8d2d68b3e8be706d6aae4782431b3e688f26251ff8e8947569243a0a75e1319bf49cd81fc33a60a74f4c17ef08621339b4fb1f9b8e140034fdae274f49fbbfbb51c2935f883cd6826e506b05456d3abb116b11cdb4f5ef769f327418d6db7fe5ad766d5be52df697c50e08949e87d1804388d00a84ceb88fa28abe5c21d6573db4d245d7eb9fe6b761506d838be5f7022191a80edce2796a9dd548d5c76272c7fbe510dd397781d1cded3c3666f44db3cc15ae003cd972c97cb62c7aba79279e3664dd3c114d4f80fe925e929697c3b85794a5b5d542b6591f3cc67e5fcca424d9f12639894da36063c429a8b9159984836c752b1d0d00933f50fd9a6f00f6c63d87dc76b135f65f09de261115dd30525a551d88430ee4c131e4f074997ebb96fecabf6c6c84afc1d6008920ccb88c980cbe7591894944cd6e10a4d00c76555be4515f0ee4c19d5bbc4083a687987173b4b0b39591003fdeee7de6e7c81f817a568d068cb624e343aead5b5de5522190db601ec5ec6e8b6289bc308356fc2d63b876fb5aef36e0aaaf0dda0eb494d1f45d97e39f6f38530523063b09041df8fc7894ecdedf3dc2498cbfea8cdefd7f62e05dec0b17b947698e74ebb22c10d97270af484b04659ad1bd1661b05c1189b1265b7c3c8672d298a1d33c131034a122c99eb8139bca0debff687b7600f26447cce8648085ea52caff77d9d431a039f3c6d261534b4256f0284d9b191cc1b306682323cf42996b4f716a69a9585a07c17450de4bf8ca0ef13f097ea1b78e270fbbd532e8e5f1cc3e71f3090f496f53cb9033793347c496e32243f30065bdecd130b76955a2d6bfd8543c11759a0347e19e18312fa0dfd36797bec5d31d78b5a1ff05d67c9d353b03eab939e15ba83a31e51b0d9611c2f2fe4d5108ca86d5e1a2c916f1c7632d65531caf1e753969d8177d3a048a5ca406d8c7e2e52a554ae6c266b964dd471bbd8e948530fb3b7093052289ce369dc0ed166e7c165fa1a4b8fa1a7c7e123bc7e00c687245fb036e07622efbcb2ff8a6115cb8b502db6cc874392e19317150bebc8238ef676e1cd8174d72073a30fa008a22803001ad491c05e202c3d978412bb32eb9ec89ee20b64f191285e5392ba66da2e7a34b7cd8f8de7e3ab0f76a568ddb6509d949085135c4749b241bce3761ccbf65a07ef31c551558fbe61f3b19cd4e2245985cf5b44ae88bbb80514460c2552bdbcdb4555b5b1c56ad76f9ded47f632eff0e46817990318b3c04ff825c5af47aab8316eb8e66c013011772bd46bfe4e79b9a3fed7f2ecc06244b9a724621c1ab5d862ad649cc941df9a6102aee42491b2c22e1876cf70216d31904e6cb7de96d25a5fbb360e1f38a663f2f288d54be2882e9dcfceca405701ca1ec4f8b456d6d91e126c6bafb7c66de08c4072a3b965b5a1c5f8ace5e49bad1480669d9b08a9c3e3c071d534e5957e7783069b5bbe1a60ad5847aef687b3c62d7d84687cc72eb1af7853d42084e13491678f6f9211ac444f1da3955e0d92befffbfa622f48246bf5b8130ed2f8abbde16d1c686c9ea95a3062933b788567e23c9826e5f1472ce241b0743ea3e509c10468d3ceff77a68a82b4d2bbc4bea628de816a6ef34bdc5e4124c7f6fb20763574dc68699509dc36540d48c9612edb560806bc8e4b75093a9881bd1800a014831273c1683e04eb916410d51a6b56e5e79a5e6f67a53bce51d1a2fc10daefd7f2814521fe2a4e622cda4dfd8106db99a3068cd39a0d1b9266303b56f98f86f1b92b91d2bee24c93220aab8669ca722f7a7a3b88d44c6c6dac5d6bf3b309af6dd48dec24e75c8a5044061632c263dac427f5528c23226c422255f9cbac076865203fbe262ac53a1fe1bbf6f62d5fa097ebe62c74a5b9a07c6afa4f78191e4692e9ee387d48e43df4bc9d33672dae2c93cbf0535293afbc74d05643cb16ecf487795976791c58079a79fc794acf018903174e5d4f2ed0ece87067fef10d4b3fed737190fa418f1b943c668b857e42039dc73bf1f21cfb071d7e37feaa2895f602d6b75015e9def1d1fd2e1ba5d6d1fa00ae780a0c4baddecd0bc9edd6420ccac883831756694f5a7857664d833a6a6965d07983411e3502386bac312f0e558d00d708fa87506e2efd4b40641a532a8947fda1b3753daaca0bd7cab46c221163bbacb4ec13ee757c86727340238a10366cdbc086ae26e16c6b11379ffb6412637f1634c11bc2b01803690e31400435aa1f094f22d95cc9edde47cac0fe38d3be8e8bbdeb91d2f42c72b57ab08684677489b013fcf16227adfd683122b4ce15e66aff4c1fd1f5b07c1294b3e54072e5199bf7fbdbbf3b7ded5626cb78e6a9f631895be224d3a52ea2fc467e90c24aa83f5565c97c0c69dc9cf0f69534629d1248957286d4ee861c21ef954652791f1bb8943400703de4cdfd93aaa4b969294144b94fdd94c12b67601d571d898eef48c2381edccc0fbd5e2a245f937aa4aef009e7d5ed5cab069f1c28c8f8e82143b73bde30e1debc06f3c0be1c562521662577ead0ea30e95e4a4d8d3fa3ed4ca5e6dfb155ed47637ce614fc24e427b19e997427d2d3bb451aa9b21091c51031d5b152fb6e09b34baf0e7321a66333fcdb848d8b11ca33911c60a9e984aa703a9d1339b0e30d67e31a30a190c7a0c66d35a377e10aa051e73b4a037dba857944765117f023dfcf587fd0af7957e3f6a2440522bc3448611c49d3e2bec58c21d78775e39bbe31b0259f3a77bbf8b93bd44b872c1ed5a7d161ce2447ca4845a3f3217ce5b3e651a4792d1f7d89dd45f6108e03de89bd1e2e2dcadfc3c02356f42f78b2b249a1453818344f18eacaec4b8b0ac9109e56e653f6c304c25a7e2ca8a17b34917aba38ff2ecad00523c94e9b95a13fdd117f7bb2ff5b337c702bbc7db3afe8ce1fb7866dab03c71dba24974d33b6fc2465c0901048c7d0565a6e90cd77913e911eabfdd2e000d19ee2299095526cc151949cedff2e8746a5ea4af7672c67691b18df58df2c3275d11f4e74d595b5ccc78a87d2fec0976e60dfa2090090e02ad83e2cedb556328e932836c57c266a05f2eea0e5651e9fb489f437db9d70b771b29b226c6ea3f4508e6b593faaac0673f7938c1011eec95168d17fe4175ef83bd32ea947faba088ce4ec5d42019250f0c82c04cc1dcfcc8a138bb5fbfcdd48a0ae8256ff8879083d637ace4d61eceb60b059a8ca8eb6e64f0d889cf41e7179c8f7b607039bbfceade21915df7a8b47a4b4f54ed90fb44813e94f38ef6ebc0f64afe91761f1afc2c7467298d0c3fe157c0efda1050cad096e1897092da83948773c8910d9bc21e5ccb5b9882ef3adb68bb2356cf6928662721635a54e362a91a30ac1938bf31539328e9cc4812d0e39370e384a37d4eb3d3c7ad1491817f80e79bb2d7ed192748bd3991463a7caf0d46fa3705fa552c7eaa0d1164a198867e8d335a3390f836518ac44e2ab6699e5ec5edccdb51c184aa3733f75a2473dbd64dc31b85cebd8fd26b062be651be4350524e9396b2554efdc42a2c340e1452e7249742f29f9a9820c9c373fbe8bedd1c8abcce4ee647722cf7c88f81747b23be845ffb2dd4405b18c13e7044be3bd71775f014b3dd0c61de970d4f70a269538f4fd849966b68ba110be1c9b087ba02d3b9822ae39e00bb592d66b6adf400d2c207262b152c9263085e60f69fd323a4136837441fee8b257c48c858075bcc5391c3e9d90f1d2d6590dc471cea4bd9e9328d5ba0f1e5616b7657ea45c59843c174d2125bfe4c81a8bf79dc986c3b69f438df030428794eab302af532da67a4e8db4a67046dbb4c12f47f6d52c04b45778a4e5d8179e389586d05c543ba9e7e365cd7b6b4a7d863ac135d048c1c710070193f7dd627b9e6eb959c6cdc09c59d5986055882241329119b52c16667d54500a1262670bbfc727c622daa75a3efb8573bea19ce2512fa0d90dfca9d5951b1d05a4cb01c26299f213f0cf1264b8321c0bcd7bde8e6e27f5edbc385e545f7513c3a842ac0a7cb60a2b565ab0a0984193f4ba2f2e32bbbba7355b301f632cc4ba870433605f9ec236207cd50fcdf63c6a79feac547442b83d14242ddfebd10801c6165fdebd58d88bdbe8b3a3eb47abf9db916b7a3b1633e0e1d987c9404a5e17aa2241c3535c8e41c7e1dc09dbf134ccdf469a05bc9fe119203429f222024a5ffc707a5929e15472185a15e7ae50fa70c4f7010540772180e66b5df16b4ac8d3049be4d84b867dac3f0832bcb647a4bdd03c78d17a9a72c8775085128e2dc487aec7fb18fc8ebc91c40598b8ef39b61d774a1456110fa348eb7390713505a7af1a3fdd1da46cd61282c3fdebdfd7e4345b580346bd13a46170380d6f797e493f1e6a98f3e801be00aabfdb635fc1c6ff527550971a88ab3fdec75571416d520209555b02589a3624543825f41b807a6679fe13f20b8d6e06ab88eb8f55b89c6aa54581a22353cf9c3e7f9b41d7c9741b7c671255324564f3480f13e471e6788bc712ce4cf44024691bb50a7de836df0473e06039db88a90015b7b5106d273b5440323eea9fccb0053a3c89d8ec927d025bc388a4e20cd88b2c7ea98497b5337a6a98651487499c93f56b859544105977b6cedd7256aa1b6c2880ca413fc38c5d8c1e0c36fdaa7be43a153c69eb3035af8628e7f294fd40169f1120ac9e7154dea2245032ce1e961347a3e794457745542ebd50da30c7c79ae4f2aa311166688415581961059ded90a5b29379b0de4a6f250fe9a9829af090b3b8bb4abbf29ecec8f8ea6e635fccb04b71d1aec4fdaaace63845245801e6d28c8e6c7d31c204ba0a7963b1ff95d73c39c31bd162f25c52703925633765a6a1d688d47a0577f0d4fa1f5ef3ab3bf64ae9afafcb4ea16712dd3c1fa7bc043deb0d67f9564539ae8581efce709c2218be1d8636120c59e2b24217dd48eeb3553e6b696551b09e00bba7ff560790550b7bbf49ddbdd22c68727b614f309d6732948a6721c50e70c1140f5ecb67bb32203e75d310452d8a4ceac773c8fc1de604a7d3233c0c9c35c33fa1d923862be5273113ef938bc3749931fe435811a5093a13ad83ace22e80e061a58bd4b27e69284a031a322bc2a8f8cce4cb667a8561e18708a00f2757a363fbd13f50e176268d5b4fe200691b491168fd03ae99737562ad743c7f8119d6375d88ab07dee53aa743d26c0c28c0034da68f3509835f4174ecb1b8895863
+random1 = c27d031fce09ad26525e107021c1038062c9e05672065bce1139a9ae583d9cd70319e9a68d1f4da2cf24099af05ab1a910c781035864ab7e45337199cfa7ece05111d3604215feac555e847148dcf47fa8361746ce162201edbb83f4f753ad9933f9c618f86e15ff28eecdddbcaacd2ff212c236141b2edc5e5b91f2a95f89af5070eed9652f2857963801cff9f21d6a08f8c1480270009ebde555a00dcc60b0688cba89950aeeac8a0806922ea1baae494e1bc1be7920fa6c9b980a80f374a5ea53f3e10ffeef047bea388949fc0b66252d25c8775dd01a03a27528a4c801993129e581e3c4d77ecca9efaf27047d7eec025f6f0601d469a93f5be5cbac10b773a392a3d0a167ec76637014974fe6808e88b9b8fbd51dfbad7192d1edad971b11404f96849cc88dab07b21ff14d5d528d60c3bb7ad4b1ddc3e6b082df9d89b020d276db81676ffcf6521b2bab33c404b27f15f5547ee4a37654680fb331afb256a6cd83146a5baf70a6a5a455c7ead49493f7aa85d4afde951f33f44a99c49ea1e3f568b70735c46dce20460150d2c96aa0849cd5b7062253fdb11ba4a7e046fe24ccd3c87bbebe3351c10a8b6fb4b1e2dd46803782982970cf9805fa2a8540d9f910ea4e360a342a320cce34101472fdc258ba339038e464da6bc20b79df5fc6ae27762a7315d3b342d99eca5d23c5ce2f1ba800bdb68882a6b520e31037e8c1e1ea3444334ed6ec3913994344b714009b9cc816d57d5a74e1cbfe3f038f0def48f43ef81983a872068f60e808ed75997d23e4896faba5542738bd403b3d5fc33f64d606d376e936f89a60cf0ad417ba0f9cd4bb70287437e9f7d63572432d859473dadd9b8c51a8813e3e734968288afdb22a5779c1f6ccc681cf2332f634096f4d40088bdee97270a7d7c04d7b367001b7c154da3f69734fd91590710e54af97f4e03b80c800ccef3282b519aaa4a76f9cb06d6746211be6ca8ac910b3b0bb799ae185dbc92c8ac2d91f0c6e5bc7095e41ebd2b3217648ba62616a3820f282154ab2787f26c47c47bb099810b65e862ed44b9d47ac87d693d2f87295834274310f337b15a4d7b33d91ffefa7b3dfec270327db4b46a5e0e1cdc072e5d0a2e8392a2bede194ee715070785f1d1cb6a5bcd2f13b4aa644541b9e6336bbb87d88bead71858dfc4c211589865faf08c8cc9ba47728dc8d2ebc3fb6d9c434b8ad7f99fbc14124fb5ffaa24fb0c7650bb19e5e17379fb58579d3b41a007e3783f68cf523a9b1fbbbab2e40c9aa8049f4e2a609c4adc528b904792121e139bbf340980adc38ac32f9538790cad55351b46faae28a0c8d5a995d55e254694102901556c9ce648da6803c6480d5ad0e567ace44d88f5d45cc02e55f81b011d2c2188cd6e89aa6a7cffed6a14a8dbb592e4f386b5a7204d6a0d56cb0844c8df76f7697
+random2 = 9d87e8e1b4b74803357d0cc36ca668584c2bba571cb38f66fba3a2d03f897fcf392fd2f88184d330ca03e85b7c4531269849864ee6bc61d81501b7a5796377a73aa6c594b9b37f0e7c130acfac926a329d742ca0bf9edbc39d5bb64dffbbd81467be1fab250eaedbeff79bb2a697584a0b14626833d06f92dbdddd6bc12d6caba725d1eae4a899b4fd75b9bbd9ed05cca9f96c7cc41ae236f3c904f0d9ee4c83111e8dc2bf520a30bcfb2afb8943f61cfd4ef9364dab069276b282f831e1abad31048926ca3cccaa7406998620c941b1ded73d623c0659462e13bf68c0ceafbd5a23afb402b2477297e431182d964cd57cc494b26886af5037964467df5b2f0f981a5aaac9a1718b5b00c174adb0d4de383eb46ffb0ecffc4a432822b9af3d21e7b5b10b7e221978ffb47d058f33456518bc647f78d5e3f5e2850957a12f83b9a0c5a8736b509336eced539c9c0faeb37285f90bb12e3499ef9aaae8c5de67ac2e5b374dffe4e1c5c3f14c4cd8905c7a7db03ac69dbdcf627c2bd4f98dda671dd0da9b70495e476fdba17894665ee2c3f8bb9e5d015b0ee727ddf85115d5833fd13633afd2dd4d5bfa751c9a4b7e937c77939cb72f057714ad94a112d28b578ce265306b415339280748fd20977967f5b04ff92d93e994fe3fd4b887bb8fb7c8cd16af9877532e49df4ee3b7132fed5920d5fc5aeda6784f4371af614d1502f036c1519c53bec2a79303050562b1b929cf705254607486c550fbb40fb7445262929bb4ef8ed658c9e4a825ca0d3e796e5e681a5ce19c2c8880a44c78f205add4c8092a790f7a8d2fbae663d32ac0640317a9735e43369ed680247789330a372910a7ce356f8eafd8776972315bb83794589f22f21770cb1b7c17f25861da3fd142398a85ba357865da0684e916eade4d078deb78ccd5442c27d4e4973eb582d2d55fd5877c64f234a61dcc11a828afa5a52ddea02ad8001c09a60fc7a14bd7118486722db6bf3a54dded4691a7937c3cb546395fc99e49954216f203aaee05985a25ea284022c72dd0a156f030c6a2604b9332ab5324c35f77674836321bcd263f8c2176558d83e23cc00d0fa4d438e9536ab7e574067baeeaeda20b2af5f8ee0821e5ff7949a50c286da61b19d8c32cca7ce1459989731cedd2852a297a6b65637413747b47286a62cf4eabfb5308acbf2d593769f0e8d148945556f1fcfdc7cadd8a6e0c0e174ddb301610d201c7b78b079c2270ac5737fe4771d9bab5257dcf5cca173af2f374c6f68e4658189f1aff3bb81c99e56dc69d14249b07d36c2f73adcb5fa1b71b629a0957b571bf6af13c12983056b6263c9c484b0778c3c1eb1261399644e942eb54479461af9397d7413822a4f267304b1dafc32744ef543a3f3442e05d70c727ac1afb846454aa50d2d979349c508f46981c297672ee78a1

0 comments on commit 70e6a34

Please sign in to comment.