-/*----- Test rig ----------------------------------------------------------*/
-
-#ifdef TEST_RIG
-
-#include <mLib/testrig.h>
-
-#include "rmd160.h"
-#include "rmd160-mgf.h"
-
-typedef struct gctx {
- grand r;
- octet *buf;
-} gctx;
-
-static void rfill(grand *r, void *buf, size_t sz)
-{
- gctx *g = (gctx *)r;
- memcpy(buf, g->buf, sz);
-}
-
-static const grand_ops gops = {
- "const", 0, 0,
- 0, 0,
- 0, 0, 0, 0, rfill
-};
-
-static int verify(dstr *v)
-{
- gctx gr;
- dstr d = DSTR_INIT;
- oaep o;
- int ok = 1;
-
- dstr_ensure(&d, v[3].len);
- d.len = v[3].len;
- gr.r.ops = &gops;
- gr.buf = (octet *)v[2].buf;
-
- o.cc = &rmd160_mgf;
- o.ch = &rmd160;
- o.r = &gr.r;
- o.ep = v[1].buf;
- o.epsz = v[1].len;
-
- if (oaep_encode(v[0].buf, v[0].len, d.buf, d.len, &o) ||
- memcmp(d.buf, v[3].buf, d.len) != 0) {
- ok = 0;
- fputs("\nfailure in oaep_encode", stderr);
- fputs("\n message = ", stderr); type_hex.dump(&v[0], stderr);
- fputs("\n params = ", stderr); type_hex.dump(&v[1], stderr);
- fputs("\n salt = ", stderr); type_hex.dump(&v[2], stderr);
- fputs("\nexpected = ", stderr); type_hex.dump(&v[3], stderr);
- fputs("\n output = ", stderr); type_hex.dump(&d, stderr);
- fputc('\n', stderr);
- }
-
- DRESET(&d);
- if (oaep_decode(v[3].buf, v[3].len, &d, &o) < 0 ||
- d.len != v[0].len || memcmp(d.buf, v[0].buf, d.len) != 0) {
- ok = 0;
- fputs("\nfailure in oaep_decode", stderr);
- fputs("\n goop = ", stderr); type_hex.dump(&v[3], stderr);
- fputs("\n params = ", stderr); type_hex.dump(&v[1], stderr);
- fputs("\n salt = ", stderr); type_hex.dump(&v[2], stderr);
- fputs("\nexpected = ", stderr); type_hex.dump(&v[0], stderr);
- fputs("\n output = ", stderr); type_hex.dump(&d, stderr);
- fputc('\n', stderr);
- }
-
- dstr_destroy(&d);
- return (ok);
-}
-
-static test_chunk tests[] = {
- { "oaep", verify, { &type_hex, &type_hex, &type_hex, &type_hex, 0 } },
- { 0, 0, { 0 } }
-};
-
-int main(int argc, char *argv[])
-{
- test_run(argc, argv, tests, SRCDIR "/tests/oaep");
- return (0);
-}
-
-#endif
-