/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
*/
#include "dh_gssapi.h"
#include "crypto.h"
/*
* This module implements the GSS-API entry points gss_sign,
* gss_verify, gss_seal, and gss_unseal.
*/
/*
* __dh_gss_sign: Sign (Caluculate a check sum as specified by the qop
* and encrypt it with a cipher also determined by the qop using the context
* session keys). the message with the given qop and return
* a Diffie-Hellman DH_MIC token pointed to by token.
*/
int qop_req, /* Requested qop */
{
/* context is a Diffie-Hellman context */
/* grap a pointer to the mic part of the token */
/*
* Make sure we can return the mechanism status an the token
* containning the MIC
*/
return (GSS_S_CALL_INACCESSIBLE_WRITE);
/* Make sure the context is valid */
return (GSS_S_NO_CONTEXT);
/* that it is established, */
return (GSS_S_NO_CONTEXT);
/* and that it has not expired */
return (GSS_S_CONTEXT_EXPIRED);
/* Package the context session keys in a key_set for __make_token */
/* Set the token version number and type */
/* Set the token qop, seq_number and client flag */
/*
* Build the the output token from the message the diffie-hellman
* non serialized tok and the context keys.
*/
!= DH_SUCCESS) {
return (GSS_S_FAILURE);
}
return (GSS_S_COMPLETE);
}
/*
* __dh_gss_verify: calculate the signature of the message and compare
* it to the signature represented by the DH_MIC token supplied. If the
* major return value is GSS_S_COMPLETE, then *qop will be the qop that
* was used in token.
*/
int *qop /* qop used */)
{
/* context is a Diffie-Hellman context */
/* Grab the mic of the token */
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
/* Validate the context */
return (GSS_S_NO_CONTEXT);
/* Check that the context is established */
return (GSS_S_NO_CONTEXT);
/* and that it has not expired */
return (GSS_S_CONTEXT_EXPIRED);
/* Package up the context session keys in to a key set */
/* Deserialize token into tok using messaget and keys */
switch (*minor) {
case DH_DECODE_FAILURE:
return (GSS_S_DEFECTIVE_TOKEN);
case DH_VERIFIER_MISMATCH:
return (GSS_S_BAD_SIG);
default:
return (GSS_S_FAILURE);
}
}
/* Check that the tok version is supported */
return (GSS_S_DEFECTIVE_TOKEN);
}
/* Set the return qop */
/* Sequence & Replay detection here */
/* free the deserialize token tok */
/*
* If client flag is the same as the initiator flag, we're talking
* to our selves or we're being spoofed. We return
* GSS_S_DUPLICATE_TOKEN since its the best return code in the
* supplementry group.
*/
return (stat);
}
/*
* __dh_gss_seal: Seal a message, i.e, it wraps or embeds a supplied message
* in a DH_WRAP token to be delivered to the other side. A message check
* over the whole message is include and is selected base on the supplied
* qop. If the qop supports privacy and confidentiality was requested, then
* the embedded message will be encrypted. A return flag will be set if
* the message was encrypted.
*
* NOTE: IN THE CURRENT PRODUCT NO QOP CAN SUPPORT PRIVACY. THE *conf_state
* FLAG WILL ALWAYS BE ZERO.
*/
int conf_req, /* True to request privacy */
int qop_req, /* Use the requested qop */
int *conf_state, /* True if message was encrypted */
{
/* context is a Diffie-Hellman context */
/* Get a pointer to the wrap protion of the token */
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
/* See if the context is valid */
return (GSS_S_NO_CONTEXT);
/* that it is established, */
return (GSS_S_NO_CONTEXT);
/* and that it has not expired */
return (GSS_S_CONTEXT_EXPIRED);
/* Package the session keys in a key_set */
/* Set the version and token type */
/* Set the qop, initiate flag, and sequence number */
/*
* Wrap the supplied message and encrypted if it is requested
* and allowed. The qop will have to have an associated cipher
* routine. NOTE: BECAUSE OF EXPORT CONTROLS, THE MECHANISM
* CURRENTLY WILL NOT DO ENCRYPTION AND conf_stat WILL ALWAY BE SET
* TO FALSE.
*/
return (GSS_S_FAILURE);
}
/* The body now contains the wrapped orignal message */
/*
* Tell the other side if encrypted.
* SEE NOTE ABOVE. THIS WILL ALWAYS BE FALSE.
*/
if (conf_state)
else
/* Serialize the token tok into output using the session keys */
return (GSS_S_FAILURE);
}
/* We're done with the wrapped body */
return (GSS_S_COMPLETE);
}
/*
* __dh_gss_unseal: Unwrap a supplied DH_WRAP token extracting the orginal
* message, qop_used, and whether privacy was used.
*
* NOTE: BECAUSE OF EXPORT CONTROLS, NO QOP IN THE MECHANISM SUPPORTS
* PRIVACY. *conf_state WILL ALWAY BE FALSE.
*/
int *conf_state, /* True if the message was encrypted */
int *qop_used /* QOP used in token */)
{
/* context is a Diffie-Hellman context */
/* Grap the wrap portion of the above token */
return (GSS_S_CALL_INACCESSIBLE_WRITE);
/* Validate context, */
return (GSS_S_NO_CONTEXT);
/* check if it is established, */
return (GSS_S_NO_CONTEXT);
/* and that it has not expired */
return (GSS_S_CONTEXT_EXPIRED);
/* Package up the session keys in to a key_set */
/* Deserialize the input in to tok using keys */
switch (*minor) {
case DH_DECODE_FAILURE:
case DH_UNKNOWN_QOP:
return (GSS_S_DEFECTIVE_TOKEN);
case DH_VERIFIER_MISMATCH:
return (GSS_S_BAD_SIG);
default:
return (GSS_S_FAILURE);
}
}
/* Set the qop_used and confidentiality state */
/* See if this is a version that we can support */
return (GSS_S_DEFECTIVE_TOKEN);
}
/* Put the unwrapped body in to a gss_buffer */
/*
* Unwrap the message putting the result in output. We use the
* qop from the token, the session keys, and set *conf_state if
* encryption was used.
*
* NOTE: THIS MECHANISM DOES NOT SUPPORT ENCRYPTION. *conf_state
* WILL ALWAY BE FALSE.
*/
!= DH_SUCCESS) {
return (*minor == DH_UNKNOWN_QOP ?
}
/* Sequence & Replay detection here */
/*
* If client flag is the same as the initiator flag, we're talking
* to our selves or we're being spoofed. We return
* GSS_S_DUPLICATE_TOKEN since its the best return code in the
* supplementry group.
*/
/* Were done with the deserialize token, tok */
return (stat);
}