1 /* nonce.c --- Shishi nonce handling regression self tests.
2 * Copyright (C) 2006 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 const char *asreq
= "aoGQMIGNoQMCAQWiAwIBCqSBgDB+oAcDBQAAAAAAoRAwDqADAgEAoQcwBRsDamFzog8bDUpPU0VGU1NPTi5PUkejIjAgoAMCAQGhGTAXGwZrcmJ0Z3QbDUpPU0VGU1NPTi5PUkelERgPMjAwNjExMDEyMDMwMDVapwYCBAlXUoOoETAPAgESAgEQAgEDAgECAgEB";
23 const char *asreppart
= "eYGYMIGVoCMwIaADAgEQoRoEGPSJH0z06kWoouBUejc+L566tgEBAQEZDqECMACiBgIEf////6QHAwUAAEAAAKURGA8yMDA2MTEwMTEyMDkyNVqnERgPMjAwNjExMDEyMDA5MjVaqQ8bDUpPU0VGU1NPTi5PUkeqIjAgoAMCAQGhGTAXGwZrcmJ0Z3QbDUpPU0VGU1NPTi5PUkc=";
30 test (Shishi
* handle
)
33 char *reqder
, *repder
;
34 size_t reqderlen
, repderlen
;
38 if (!base64_decode_alloc (asreq
, strlen (asreq
), &reqder
, &reqderlen
))
39 fail ("base64 req\n");
41 if (!base64_decode_alloc (asreppart
, strlen (asreppart
), &repder
, &repderlen
))
42 fail ("base64 rep\n");
44 req
= shishi_der2asn1_asreq (handle
, reqder
, reqderlen
);
46 fail ("der2asn1 req\n");
48 rep
= shishi_der2asn1_encasreppart (handle
, repder
, repderlen
);
50 fail ("der2asn1 rep\n");
54 shishi_kdcreq_print (handle
, stdout
, req
);
55 shishi_enckdcreppart_print (handle
, stdout
, rep
);
58 /* Read and check req */
60 rc
= shishi_asn1_read_uint32 (handle
, req
, "req-body.nonce", &nonce
);
62 fail ("shishi_asn1_read_uint32\n");
64 printf ("req nonce: %x\n", nonce
);
66 if (nonce
!= 0x09575283)
67 fail ("nonce mismatch low\n");
69 rc
= shishi_kdcreq_nonce (handle
, req
, &nonce
);
71 fail ("shishi_kdcreq_nonce\n");
73 printf ("req nonce: %x\n", nonce
);
75 if (nonce
!= 0x09575283)
76 fail ("nonce mismatch high");
78 /* Read and check rep */
80 rc
= shishi_asn1_read_uint32 (handle
, rep
, "nonce", &nonce
);
82 fail ("read rep uint32");
84 printf ("old rep nonce: %x\n", nonce
);
86 if (nonce
!= 0x7fffffff)
87 fail ("nonce mismatch high");
91 rc
= shishi_kdc_copy_nonce (handle
, req
, rep
);
93 fail ("shishi_kdc_copy_nonce\n");
95 /* Read and check rep */
97 rc
= shishi_asn1_read_uint32 (handle
, rep
, "nonce", &nonce
);
99 fail ("read rep uint32");
101 printf ("new rep nonce: %x\n", nonce
);
103 if (nonce
!= 0x09575283)
104 fail ("nonce mismatch high");
109 shishi_asn1_done (handle
, req
);
110 shishi_asn1_done (handle
, rep
);