#ifndef __PPS_H__
#define __PPS_H__
#include <stdio.h>
#include <string.h>
#include <openssl/aes.h>
#include <sasl/sasl.h>
#include <CommonCrypto/CommonDigest.h>
#include <CommonCrypto/CommonCryptor.h>
#include <DirectoryService/DirServicesTypes.h>
#include "digestmd5.h"
typedef struct CommonAuthDataBlock {
int step;
char *outPtr;
unsigned char *salt;
int saltLen;
char *serverChallenge;
char *peerChallenge;
int encryptedChallengeLen;
int hashType;
unsigned char sessionKey[CC_MD5_DIGEST_LENGTH];
unsigned char response[CC_SHA256_DIGEST_LENGTH];
unsigned long nonce;
int encryptedNonceLen;
AES_KEY sessionEncryptKey;
AES_KEY sessionDecryptKey;
unsigned char encrypt_ivec[kCCBlockSizeAES128];
unsigned char decrypt_ivec[kCCBlockSizeAES128];
buffer_info_t *enc_in_buf;
unsigned int encode_buf_len;
char *encode_buf;
char *decode_buf;
char *decode_once_buf;
unsigned int decode_buf_len;
unsigned int decode_once_buf_len;
} CommonAuthDataBlock, *CommonAuthDataBlockPtr;
typedef struct ServerAuthDataBlock {
CommonAuthDataBlock c;
char *userName;
unsigned char *saltedHash;
int saltedHashLen;
unsigned char saltedHashHash[CC_MD5_DIGEST_LENGTH];
unsigned char *encryptedChallenge;
int peerChallengeLen;
char encryptedNonce[64];
char *proxyNode;
tDirReference dsRef;
tDirNodeReference nodeRef;
tDataBufferPtr authBuff;
tDataBufferPtr authStepBuff;
tContextData continueData;
tDataNodePtr typeBuff;
} ServerAuthDataBlock, *ServerAuthDataBlockPtr;
typedef struct ClientAuthDataBlock {
CommonAuthDataBlock c;
const char *authenticatorName;
const char *userName;
sasl_secret_t *password;
unsigned int free_password;
int serverChallengeLen;
char *encryptedPeerChallenge;
int encryptedPeerChallengeLen;
char *encryptedNonce;
} ClientAuthDataBlock, *ClientAuthDataBlockPtr;
__BEGIN_DECLS
void
server_step_0_set_hash(const unsigned char *inSaltedSHA1Hash, ServerAuthDataBlockPtr inOutAuthData);
int
server_step_1(const char *inClientData, ServerAuthDataBlockPtr inOutAuthData);
int
server_step_2(const char *inClientData, ServerAuthDataBlockPtr inOutAuthData);
int
pps_server_mech_step(
ServerAuthDataBlockPtr contextPtr,
const char *clientin,
unsigned clientinlen,
const char **serverout,
unsigned *serveroutlen );
void
pps_server_mech_dispose(ServerAuthDataBlockPtr contextPtr);
__END_DECLS
#endif