Beispiel #1
0
/*
 * If PeerChallenge is NULL, one is generated and the PeerChallenge
 * field of response is filled in.  Call this way when generating a response.
 * If PeerChallenge is supplied, it is copied into the PeerChallenge field.
 * Call this way when verifying a response (or debugging).
 * Do not call with PeerChallenge = response.
 *
 * The PeerChallenge field of response is then used for calculation of the
 * Authenticator Response.
 */
static void ChapMS2(ppp_pcb *pcb, const u_char *rchallenge, const u_char *PeerChallenge,
	const char *user, const char *secret, int secret_len, unsigned char *response,
	u_char authResponse[], int authenticator) {
    /* ARGSUSED */
    LWIP_UNUSED_ARG(authenticator);
#if !MPPE_SUPPORT
    LWIP_UNUSED_ARG(pcb);
#endif /* !MPPE_SUPPORT */

    BZERO(response, MS_CHAP2_RESPONSE_LEN);

    /* Generate the Peer-Challenge if requested, or copy it if supplied. */
    if (!PeerChallenge)
	magic_random_bytes(&response[MS_CHAP2_PEER_CHALLENGE], MS_CHAP2_PEER_CHAL_LEN);
    else
	MEMCPY(&response[MS_CHAP2_PEER_CHALLENGE], PeerChallenge,
	      MS_CHAP2_PEER_CHAL_LEN);

    /* Generate the NT-Response */
    ChapMS2_NT(rchallenge, &response[MS_CHAP2_PEER_CHALLENGE], user,
	       secret, secret_len, &response[MS_CHAP2_NTRESP]);

    /* Generate the Authenticator Response. */
    GenerateAuthenticatorResponsePlain(secret, secret_len,
				       &response[MS_CHAP2_NTRESP],
				       &response[MS_CHAP2_PEER_CHALLENGE],
				       rchallenge, user, authResponse);

#if MPPE_SUPPORT
    SetMasterKeys(pcb, secret, secret_len,
		  &response[MS_CHAP2_NTRESP], authenticator);
#endif /* MPPE_SUPPORT */
}
Beispiel #2
0
/*
 * If PeerChallenge is NULL, one is generated and response->PeerChallenge
 * is filled in.  Call this way when generating a response.
 * If PeerChallenge is supplied, it is copied into response->PeerChallenge.
 * Call this way when verifying a response (or debugging).
 * Do not call with PeerChallenge = response->PeerChallenge.
 *
 * response->PeerChallenge is then used for calculation of the
 * Authenticator Response.
 */
void ChapMS2(chap_state *cstate, u_char *rchallenge, u_char *PeerChallenge,
             char *user, char *secret, int secret_len, MS_Chap2Response *response,
             u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1], int authenticator)
{
    /* ARGSUSED */
    u_char *p = response->PeerChallenge;
    int i;

    BZERO(response, sizeof(*response));

    /* Generate the Peer-Challenge if requested, or copy it if supplied. */
    if (!PeerChallenge)
    {
        for (i = 0; i < sizeof(response->PeerChallenge); i++)
        {
            *p++ = (u_char) (lrand48() & 0xff);
        }
    }
    else
    {
        BCOPY(PeerChallenge, response->PeerChallenge, sizeof(response->PeerChallenge));
    }

    /* Generate the NT-Response */
    ChapMS2_NT(rchallenge, response->PeerChallenge, user, secret, secret_len, response->NTResp);

    /* Generate the Authenticator Response. */
    GenerateAuthenticatorResponse(secret, secret_len, response->NTResp,
                                  response->PeerChallenge, rchallenge, user, authResponse);

    cstate->resp_length = MS_CHAP2_RESPONSE_LEN;

#ifdef MPPE
    SetMasterKeys(secret, secret_len, response->NTResp, authenticator);
    mppe_keys_set = 1;
#endif
}
Beispiel #3
0
CCryptBlowfish::CCryptBlowfish( unsigned int masterKey1, unsigned int masterKey2 )
{
  SetMasterKeys( masterKey1, masterKey2 );
}
Beispiel #4
0
CCrypt12536::CCrypt12536( unsigned int masterKey1, unsigned int masterKey2 )
{
  SetMasterKeys( masterKey1, masterKey2 );
}