Tidy up error handling in get_creds()

Change-Id: I38f875252ed01ccf40b5edc0d5a4b6edacf794cc
Tighten up error handling for mic_startparams

Also remove unneeded temporary variable.

Change-Id: I1d95d335141e98ef892dde37b6ebcbad8a84ebea
Tighten up error handling for pack_clientinfo

Always be sure to set the minor status to a reasonable value,
and release the buffer allocated by gss_wrap appropriately.

Change-Id: I5d9b9a8de6e9849e2707302bf2b83a57b3331aae
Tighten up error handling for make_pack_token

Split the two XDR-encoding steps off into separate subroutines and
use an RX error code instead of a fake GSSAPI one.
Don't leak memory from the rx_opaque in the local TokenContainer.

Change-Id: I261d47270c145e1302aad2db195ba6d62ba75b29
Tighten up error handling for fill_token_identity

Don't let our unconditional cleanup corrupt the minor status.

Change-Id: I092440e82f18ae7486fe49db4d2abfe36a209e59
Factor out rxgk_nonce

Produce a random nonce in an RXGK_Data, of the specified length.
Use to produce the client and server nonce for key negotiation.

Change-Id: Ibd80f4e496bfccafa0bde8ca6a4d6025469c52ea
Do not pretend to support multi-hop mechs

We don't really have a way to maintain an acceptor GSS context across
RPC calls at the moment, and this makes the code simpler.

Change-Id: I17cb0fa7f4c5d0821d18cdeb9b31c01897f3a44a
Remove the local opaque

It was a hack to pretend to support multi-hop mechs, but we should
really use a proper XDR type for that purpose when we do support it.

Change-Id: I32e93071709edba0b70e48b73d9ebe8ec822a540
Use a struct instead of separate variables

We have an RXGK_TokenInfo structure that describes the parameters
of a token.  Use it, instead of separate variables for enctype,
level, lifetime, and bytelife.  This will make factoring out helper
routines easier.

Change-Id: Icf89ead53754a4b2f9570d99719434dc9b060df9
Make localinfo the authority for expiration/errorcode

All other users should be seeded from it.

Change-Id: Ic5eb510327560ce0018676e615081a35b1bd5345
Wrap TokenInfo->ClientInfo propagation in a function

No need to use multiple lines in the main code for this.

Change-Id: Ibf9b50b118e297cc94bcb0373859fb1745111505
Factor out determining the expiration time

Shorten up the main routine, and give us a place to put further
administrative checks.

Change-Id: Ib2213b6dc0eacc2ca9a1a630a040f514cc6653b6
Condense token creation from tokeninfo fields

Use a function call instead of a bunch of assignments.

Change-Id: I5a6635d5fb009d364861e9be54dc3f35bd3bbb34
Factor out token creation

First create the single identity that we'll produce for a token
from GSSNegotiate, then make the token from a tokeninfo and key and such.

We no longer need a token local in SRXGK_GSSNegotiate, as make_token()
returns the token already encrypted.

Change-Id: I7a9a9a768eb602a0df75079afdc09372ef0c5eaf
s/make_wrap_token/pack_wrap_token

It's packing/encoding the token, not filling its contents.

Change-Id: If6e9d5b36fddc289a6445509e6077aa6cd1b4ba2
Tighten up SRXGK_GSSNegotiate error handling

Always free everything we allocate (or at least try to).
Be sure to initialize them so we don't try to free stack garbage.
Use the GSS error code fields as appropriate.

Change-Id: Iad26fa3c36df6a6a928951bc0428010127a8752a
Enforce the tokeninfo errorcode

Do not make a token if there is a policy error.
(There are not currently any places where a policy error is set.)

Change-Id: I774afa31abe1b9ec383164ce3b5410501e0e92d4
Don't leak a bogus minor status from GSSNegotiate

Change-Id: Idff8dc00c4ad82229af62eb0e2206a9a0f6ea43e
Tidy up fill_start_params

Change-Id: I5834c57ef11101161c7203c87539f058665e97d4
Tidy up get_server_name

Change-Id: Ic69d36426d1ddb42c35269ccc301adce79240e26