int shishi_kdcreq_nonce (Shishi * handle, Shishi_asn1 kdcreq, uint32_t * nonce) { int res; res = shishi_asn1_read_uint32 (handle, kdcreq, "req-body.nonce", nonce); if (res != SHISHI_OK) return res; return SHISHI_OK; }
/** * shishi_encapreppart_cusec_get: * @handle: shishi handle as allocated by shishi_init(). * @encapreppart: EncAPRepPart as allocated by shishi_encapreppart(). * @cusec: output integer with client microseconds field. * * Extract client microseconds field from EncAPRepPart. * * Return value: Returns SHISHI_OK iff successful. **/ int shishi_encapreppart_cusec_get (Shishi * handle, Shishi_asn1 encapreppart, uint32_t * cusec) { int res; res = shishi_asn1_read_uint32 (handle, encapreppart, "cusec", cusec); if (res != SHISHI_OK) return res; return res; }
/** * shishi_authenticator_cusec_get: * @handle: shishi handle as allocated by shishi_init(). * @authenticator: Authenticator as allocated by shishi_authenticator(). * @cusec: output integer with client microseconds field. * * Extract client microseconds field from Authenticator. * * Return value: Returns SHISHI_OK iff successful. **/ int shishi_authenticator_cusec_get (Shishi * handle, Shishi_asn1 authenticator, uint32_t * cusec) { int res; res = shishi_asn1_read_uint32 (handle, authenticator, "cusec", cusec); if (res != SHISHI_OK) return res; return SHISHI_OK; }
/** * shishi_encapreppart_seqnumber_get: * @handle: shishi handle as allocated by shishi_init(). * @encapreppart: EncAPRepPart as allocated by shishi_encapreppart(). * @seqnumber: output integer with sequence number field. * * Extract sequence number field from EncAPRepPart. * * Return value: Returns SHISHI_OK iff successful. **/ int shishi_encapreppart_seqnumber_get (Shishi * handle, Shishi_asn1 encapreppart, uint32_t * seqnumber) { int res; res = shishi_asn1_read_uint32 (handle, encapreppart, "seq-number", seqnumber); if (res != SHISHI_OK) return res; return res; }
/** * shishi_authenticator_seqnumber_get: * @handle: shishi handle as allocated by shishi_init(). * @authenticator: authenticator as allocated by shishi_authenticator(). * @seqnumber: output integer with sequence number field. * * Extract sequence number field from Authenticator. * * Return value: Returns %SHISHI_OK iff successful. **/ int shishi_authenticator_seqnumber_get (Shishi * handle, Shishi_asn1 authenticator, uint32_t * seqnumber) { int res; res = shishi_asn1_read_uint32 (handle, authenticator, "seq-number", seqnumber); if (res != SHISHI_OK) return res; return res; }
void test (Shishi * handle) { Shishi_asn1 req, rep; char *reqder, *repder; size_t reqderlen, repderlen; int rc; uint32_t nonce; if (!base64_decode_alloc (asreq, strlen (asreq), &reqder, &reqderlen)) fail ("base64 req\n"); if (!base64_decode_alloc (asreppart, strlen (asreppart), &repder, &repderlen)) fail ("base64 rep\n"); req = shishi_der2asn1_asreq (handle, reqder, reqderlen); if (!req) fail ("der2asn1 req\n"); rep = shishi_der2asn1_encasreppart (handle, repder, repderlen); if (!rep) fail ("der2asn1 rep\n"); if (debug) { shishi_kdcreq_print (handle, stdout, req); shishi_enckdcreppart_print (handle, stdout, rep); } /* Read and check req */ rc = shishi_asn1_read_uint32 (handle, req, "req-body.nonce", &nonce); if (rc) fail ("shishi_asn1_read_uint32\n"); printf ("req nonce: %x\n", nonce); if (nonce != 0x09575283) fail ("nonce mismatch low\n"); rc = shishi_kdcreq_nonce (handle, req, &nonce); if (rc) fail ("shishi_kdcreq_nonce\n"); printf ("req nonce: %x\n", nonce); if (nonce != 0x09575283) fail ("nonce mismatch high"); /* Read and check rep */ rc = shishi_asn1_read_uint32 (handle, rep, "nonce", &nonce); if (rc) fail ("read rep uint32"); printf ("old rep nonce: %x\n", nonce); if (nonce != 0x7fffffff) fail ("nonce mismatch high"); /* Copy nonce. */ rc = shishi_kdc_copy_nonce (handle, req, rep); if (rc) fail ("shishi_kdc_copy_nonce\n"); /* Read and check rep */ rc = shishi_asn1_read_uint32 (handle, rep, "nonce", &nonce); if (rc) fail ("read rep uint32"); printf ("new rep nonce: %x\n", nonce); if (nonce != 0x09575283) fail ("nonce mismatch high"); free (reqder); free (repder); shishi_asn1_done (handle, req); shishi_asn1_done (handle, rep); }