/*  $Id: diCrPKI.h $ */

/*  For `CryptoSys PKI` Version 3.8.
  Requires `diCrPKI.lib` and `diCrPKI.dll` for Win32/64
  or `diCrPKI.a` for Linux.
*/

/*  Copyright (C) 2002-12 DI Management Services Pty Limited 
  All rights reserved.

  Last updated:
  $Date: 2012-01-14 06:56:00 $
  $Revision: 3.8.0 $
*/

#ifndef DICRPKI_H_
#define DICRPKI_H_ 1

/* GENERAL CONSTANTS */
#define PKI_DIR_ENCRYPT   1
#define PKI_DIR_DECRYPT   0
/* Synonyms for direction */
#define ENCRYPT 1
#define DECRYPT 0
/* Maximum number of bytes in hash digest byte array */
#define PKI_MAX_HASH_BYTES 64
#define PKI_SHA1_BYTES     20
#define PKI_SHA224_BYTES   28
#define PKI_SHA256_BYTES   32
#define PKI_SHA384_BYTES   48
#define PKI_SHA512_BYTES   64
#define PKI_MD5_BYTES      16
#define PKI_MD2_BYTES      16
/* Maximum number of hex characters in hash digest (excl null) */
#define PKI_MAX_HASH_CHARS (2*PKI_MAX_HASH_BYTES)
#define PKI_SHA1_CHARS     (2*PKI_SHA1_BYTES)
#define PKI_SHA224_CHARS   (2*PKI_SHA224_BYTES)
#define PKI_SHA256_CHARS   (2*PKI_SHA256_BYTES)
#define PKI_SHA384_CHARS   (2*PKI_SHA384_BYTES)
#define PKI_SHA512_CHARS   (2*PKI_SHA512_BYTES)
#define PKI_MD5_CHARS      (2*PKI_MD5_BYTES)
#define PKI_MD2_CHARS      (2*PKI_MD2_BYTES)
/* Synonym retained for backwards compatibility */
#define PKI_MAX_HASH_LEN   PKI_MAX_HASH_CHARS
/* Encryption block sizes in bytes */
#define PKI_BLK_TDEA_BYTES 8
#define PKI_BLK_AES_BYTES  16
/* Key size in bytes */
#define PKI_KEYSIZE_TDEA_BYTES 24
#define PKI_KEYSIZE_MAX_BYTES  32
/* Required size for RNG seed file */
#define PKI_RNG_SEED_BYTES 64

/* OPTIONS */
#define PKI_DEFAULT       0

/* Signature algorithms */
#define PKI_SIG_SHA1RSA   0
#define PKI_SIG_MD5RSA    1
#define PKI_SIG_MD2RSA    2
#define PKI_SIG_SHA256RSA 3   /* Added v3.2 */
#define PKI_SIG_SHA384RSA 4   /* Added v3.2 */
#define PKI_SIG_SHA512RSA 5   /* Added v3.2 */
#define PKI_SIG_SHA224RSA 6   /* Added v3.2 */

/* PKCS#5 Password-based encryption algorithms */
#define PKI_PBE_SHA_3DES  0
#define PKI_PBE_MD5_DES   1
#define PKI_PBE_MD2_DES   2
#define PKI_PBE_SHA_DES   3
#define PKI_PBES2_3DES    4   /* Deprecated as of v3.2 */
#define PKI_PBE_PBES2   0x1000L /* Added v3.2 */

/* Message digest hash algorithms */
#define PKI_HASH_SHA1     0
#define PKI_HASH_MD5      1
#define PKI_HASH_MD2      2
#define PKI_HASH_SHA256   3
#define PKI_HASH_SHA384   4
#define PKI_HASH_SHA512   5
#define PKI_HASH_SHA224   6
#define PKI_HASH_MODE_TEXT 0x10000L

/* nFermatExp values for RSA exponent */
#define PKI_RSAEXP_EQ_3     0
#define PKI_RSAEXP_EQ_5     1
#define PKI_RSAEXP_EQ_17    2
#define PKI_RSAEXP_EQ_257   3
#define PKI_RSAEXP_EQ_65537 4

/* Return values for RSA_CheckKey */
#define PKI_VALID_PUBLICKEY  1
#define PKI_VALID_PRIVATEKEY 0

/* BIT FLAGS */

/* RSA key generation */
#define PKI_KEYGEN_INDICATE  0x1000000L /* Changed from 0x10 in v3.3 */
/* PKI_KEY_NODELAY removed in v3.3 */

#define PKI_KEY_FORMAT_PEM   0x10000L
#define PKI_KEY_FORMAT_SSL   0x20000L

#define PKI_PFX_NO_PRIVKEY   0x10L    /* Obsolete as of v3.8 */
#define PKI_PFX_PLAIN_CERT   0x2000000L /* New in v3.8 */
#define PKI_PFX_CLONE_KEY    0x4000000L /* New in v3.8 */
#define PKI_PFX_ALT_FORMAT   0x100000L  /* New in v3.8 */

#define PKI_CMS_FORMAT_BASE64     0x10000L
#define PKI_CMS_EXCLUDE_CERTS      0x0100L
#define PKI_CMS_EXCLUDE_DATA       0x0200L
#define PKI_CMS_INCLUDE_ATTRS      0x0800L
#define PKI_CMS_ADD_SIGNTIME       0x1000L
#define PKI_CMS_ADD_SMIMECAP       0x2000L
#define PKI_CMS_CERTS_ONLY         0x0400L
#define PKI_CMS_NO_OUTER        0x2000000L
#define PKI_CMS_ALT_ALGID       0x4000000L
#define PKI_CMS_BIGFILE         0x8000000L  /* New in v3.7 */

#ifndef PKI_XML_DEFINED_
#define PKI_XML_RSAKEYVALUE   0x0001L
#define PKI_XML_EXCLPRIVATE   0x0010L
#define PKI_XML_HEXBINARY     0x0100L
#define PKI_XML_DEFINED_
#endif  /* PKI_XML_DEFINED_ */

#ifndef PKI_ENCOD_DEFINED_
#define PKI_EME_DEFAULT         0x00L
#define PKI_EME_PKCSV1_5        0x00L
#define PKI_EME_OAEP            0x10L
#define PKI_EMSIG_DEFAULT       0x20L
#define PKI_EMSIG_PKCSV1_5      0x20L
#define PKI_EMSIG_DIGESTONLY  0x1000L
#define PKI_EMSIG_DIGINFO     0x2000L
#define PKI_EMSIG_ISO9796   0x100000L   /* New in v3.3 */
#define PKI_ENCOD_DEFINED_
#endif  /* PKI_ENCOD_DEFINED_ */

#ifndef PKI_X509_DEFINED_
/* Option flags */
#define PKI_X509_FORMAT_PEM                0x10000L
#define PKI_X509_FORMAT_BIN                0x20000L
#define PKI_X509_REQ_KLUDGE               0x100000L
#define PKI_X509_NO_TIMECHECK             0x200000L /* New in v3.5 */
#define PKI_X509_LATIN1                   0x400000L
#define PKI_X509_UTF8                     0x800000L
#define PKI_X509_AUTHKEYID               0x1000000L /* New in v3.3 */   
#define PKI_X509_NO_BASIC                0x2000000L       
#define PKI_X509_CA_TRUE                 0x4000000L
#define PKI_X509_VERSION1                0x8000000L
/* Flags for Key Usage */
#define PKI_X509_KEYUSAGE_DIGITALSIGNATURE  0x0001L
#define PKI_X509_KEYUSAGE_NONREPUDIATION    0x0002L
#define PKI_X509_KEYUSAGE_KEYENCIPHERMENT   0x0004L
#define PKI_X509_KEYUSAGE_DATAENCIPHERMENT  0x0008L
#define PKI_X509_KEYUSAGE_KEYAGREEMENT      0x0010L
#define PKI_X509_KEYUSAGE_KEYCERTSIGN       0x0020L
#define PKI_X509_KEYUSAGE_CRLSIGN           0x0040L
#define PKI_X509_KEYUSAGE_ENCIPHERONLY      0x0080L
#define PKI_X509_KEYUSAGE_DECIPHERONLY      0x0100L
/* Specific return values */
#define PKI_X509_EXPIRED        -1
#define PKI_X509_VALID_NOW       0
#define PKI_X509_VERIFY_SUCCESS  0
#define PKI_X509_VERIFY_FAILURE -1
#define PKI_X509_REVOKED         1
#define PKI_X509_INVALID         1
#define PKI_X509_DEFINED_
#endif

/* Return values for CNV_CheckUTF */
#define PKI_CHRS_NOT_UTF8    0L
#define PKI_CHRS_ALL_ASCII   1L
#define PKI_CHRS_ANSI8       2L
#define PKI_CHRS_MULTIBYTE   3L
#define PKI_CHRS_DEFINED_

/* Options for CNV_ByteEncoding [New in v3.6] */
#define PKI_CNV_UTF8_FROM_LATIN1 1L
#define PKI_CNV_LATIN1_FROM_UTF8 2L

/* Flags and return values for X.509 and CMS query functions */
#ifndef PKI_QUERY_DEFINED_
#define PKI_QUERY_GETTYPE    0x100000L
#define PKI_QUERY_NUMBER     1L
#define PKI_QUERY_STRING     2L
#define PKI_QUERY_DEFINED_
#endif

/* Options for RNG functions */
#define PKI_RNG_STRENGTH_112        0x00L
#define PKI_RNG_STRENGTH_128        0x01L

/* Block cipher (BC) algorithm options */
#define PKI_BC_TDEA    0x10L  // (
#define PKI_BC_3DES    0x10L  // ( equiv. synonyms for Triple DES
#define PKI_BC_DESEDE3 0x10L  // (
#define PKI_BC_AES128  0x20L
#define PKI_BC_AES192  0x30L
#define PKI_BC_AES256  0x40L

/* Block cipher mode options */
#define PKI_MODE_ECB  0x000L
#define PKI_MODE_CBC  0x100L
#define PKI_MODE_OFB  0x200L
#define PKI_MODE_CFB  0x300L
#define PKI_MODE_CTR  0x400L

/* Cipher file option flags - added [v3.7] */
#define PKI_IV_PREFIX 0x1000
#define PKI_PAD_LEAVE 0x2000

/* Key transport algorithms */
#define PKI_KT_RSAES_PKCS   0x0000L
// --0x1000L Reserved for PKI_KT_RSAES_OEAP
// --0x2000L Reserved for PKI_KT_RSA_KEM    // added v3.2; withdrawn v3.4

/* Key derivation functions */
#define PKI_KDF_KDF2    0x000L
// --0x300L Reserved for PKI_KDF_KDF3

/* General */
#define PKI_GEN_PLATFORM 0x40    

/* __stdcall convention required for Win32 DLL only */
#if defined(unix) || defined (linux) || defined(__linux)
#define _stdcall
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* GENERAL FUNCTIONS */
long _stdcall PKI_Version(void *reserved1, void *reserved2);
long _stdcall PKI_LicenceType(long reserved);
long _stdcall PKI_LastError(char *szErrMsg, long nMsgLen);
long _stdcall PKI_ErrorCode(void);
long _stdcall PKI_ErrorLookup(char *szErrMsg, long nMsgLen, long nErrCode);
long _stdcall PKI_CompileTime(char *szOutput, long nOutputLen);
long _stdcall PKI_ModuleName(char *szOutput, long nOutputLen, long reserved);
long _stdcall PKI_PowerUpTests(long nOptions);

/* RFC3369 CRYPTOGRAPHIC MESSAGE SYNTAX FUNCTIONS */
long _stdcall CMS_MakeEnvData(const char *szFileOut, const char *szFileIn, const char *szCertList, const char *sSeed, long nSeedLen, long nOptions);
long _stdcall CMS_MakeEnvDataFromString(const char *szFileOut, const char *szDataIn, const char *szCertList, const char *sSeed, long nSeedLen, long nOptions);
long _stdcall CMS_ReadEnvData(const char *szFileOut, const char *szFileIn, const char *szX509File, const char *szRSAPrivateKey, long nOptions);
long _stdcall CMS_ReadEnvDataToString(char *szDataOut, long nDataOutLen, const char *szFileIn, const char *szX509File, const char *szRSAPrivateKey, long nOptions);
long _stdcall CMS_MakeSigData(const char *szFileOut, const char *szFileIn, const char *szCertList, const char *szRSAPrivateKey, long nOptions);
long _stdcall CMS_MakeSigDataFromString(const char *szFileOut, const char *szDataIn, const char *szCertList, const char *szRSAPrivateKey, long nOptions);
long _stdcall CMS_MakeSigDataFromSigValue(const char *szFileOut, const unsigned char *pSigValue, long nSigLen, const unsigned char *pData, long nDataLen, const char *szCertList, long nOptions);
long _stdcall CMS_MakeDetachedSig(const char *szFileOut, const char *szHexDigest, const char *szCertList, const char *szRSAPrivateKey, long nOptions);
long _stdcall CMS_ReadSigData(const char *szFileOut, const char *szFileIn, long nOptions);
long _stdcall CMS_ReadSigDataToString(char *szDataOut, long nDataOutLen, const char *szFileIn, long nOptions);
long _stdcall CMS_GetSigDataDigest(char *szHexDigestOut, long nDigestLen, const char *szFileIn, const char *szX509File, long nOptions);
long _stdcall CMS_VerifySigData(const char *szFileIn, const char *szX509File, const char *szHexDigest, long nOptions);
long _stdcall CMS_QuerySigData(char *szDataOut, long nDataOutLen, const char *szFileIn, const char *szQuery, long nOptions);
long _stdcall CMS_QueryEnvData(char *szDataOut, long nDataOutLen, const char *szFileIn, const char *szQuery, long nOptions);

/* RSA KEY FUNCTIONS */
long _stdcall RSA_MakeKeys(const char *szPubKeyFile, const char *szPVKFile, long nBits, long nExpFermat, long nTests, long nCount, const char *szPassword, const void *lpSeed, long nSeedLen, long nOptions);
long _stdcall RSA_ReadEncPrivateKey(char *szOutput, long nOutputLen, const char *szPVKFile, const char *szPassword, long nOptions);
long _stdcall RSA_ReadPrivateKeyInfo(char *szOutput, long nOutputLen, const char *szKeyFile, long nOptions);
long _stdcall RSA_GetPrivateKeyFromPFX(const char *szOutputFile, const char *szPFXFile, long nOptions);
long _stdcall RSA_ReadPublicKey(char *szOutput, long nOutputLen, const char *szKeyFile, long nOptions);
long _stdcall RSA_GetPublicKeyFromCert(char *szOutput, long nOutputLen, const char *szCertFile, long nOptions);
long _stdcall RSA_SavePublicKey(const char *szFileOut, const char *szKeyString, long nOptions);
long _stdcall RSA_SavePrivateKeyInfo(const char *szFileOut, const char *szKeyString, long nOptions);
long _stdcall RSA_SaveEncPrivateKey(const char *szFileOut, const char *szKeyString, long nCount, const char *szPassword, long nOptions);
long _stdcall RSA_KeyBits(const char *szKeyString);
long _stdcall RSA_KeyBytes(const char *szKeyString);
long _stdcall RSA_ToXMLString(char *szOutput, long nOutputLen, const char *szKeyString, long nOptions);
long _stdcall RSA_FromXMLString(char *szOutput, long nOutputLen, const char *szXmlString, long nOptions);
long _stdcall RSA_CheckKey(const char *szKeyString, long nOptions);
long _stdcall RSA_KeyHashCode(const char *szKeyString);
long _stdcall RSA_KeyMatch(const char *szPrivateKey, const char *szPublicKey);
/* New in v3.8 */
long _stdcall RSA_ReadPrivateKeyFromPFX(char *szOutput, long nOutChars, const char *szPfxFile, const char *szPassword, long nOptions);
long _stdcall RSA_PublicKeyFromPrivate(char *szOutput, long nOutChars, const char *szKeyString, long nOptions);

/* 'RAW' RSA ENCRYPTION/DECRYPTION FUNCTIONS */
long _stdcall RSA_RawPublic(unsigned char *lpData, long nDataLen, const char *szPublicKey64, long nOptions);
long _stdcall RSA_RawPrivate(unsigned char *lpData, long nDataLen, const char *szPrivateKey64, long nOptions);
long _stdcall RSA_EncodeMsg(unsigned char *lpOutput, long nOutputLen, const unsigned char *abMessage, long nMsgLen, long nOptions);
long _stdcall RSA_DecodeMsg(unsigned char *lpOutput, long nOutputLen, const unsigned char *abInput, long nInputLen, long nOptions);

/* PKCS12 FILE FUNCTIONS */
long _stdcall PFX_MakeFile(const char *szFileOut, const char *szCertFile, const char *szKeyFile, const char *szPassword, const char *szFriendlyName, long options);
long _stdcall PFX_VerifySig(const char *szFileName, const char *szPassword, long options);

/* X509 CERTIFICATE FUNCTIONS */
long _stdcall X509_MakeCert(const char *certfile, const char *issuerCert, const char *subjectPubkeyFile, const char *issuerPvkInfoFile, long certnum, long yearsvalid, const char *distName, const char *extensions, long keyUsageFlags, const char *password, long optionFlags);
long _stdcall X509_MakeCertSelf(const char *certfile, const char *epkfile, long certnum, long yearsvalid, const char *distName, const char *extensions, long keyUsageFlags, const char *password, long optionFlags);
long _stdcall X509_CertRequest(const char *reqfile, const char *epkfile, const char *distName, const char *reserved, const char *password, long optionFlags);
long _stdcall X509_VerifyCert(const char *szCertToVerify, const char *szIssuerCert, long nOptions);
long _stdcall X509_CertThumb(const char *szCertFile, char *szHash, long nHashLen, long nOptions);
long _stdcall X509_CertIsValidNow(const char *szCertFile, long nOptions);
long _stdcall X509_CertIssuedOn(const char *szCertFile, char *szOutput, long nOutChars, long nOptions);
long _stdcall X509_CertExpiresOn(const char *szCertFile, char *szOutput, long nOutChars, long nOptions);
long _stdcall X509_CertSerialNumber(const char *szCertFile, char *szOutput, long nOutChars, long nOptions);
long _stdcall X509_HashIssuerAndSN(const char *szCertFile, char *szOutput, long nOutChars, long nOptions);
long _stdcall X509_CertIssuerName(const char *szCertFile, char *szOutput, long nOutChars, const char *szDelim, long nOptions);
long _stdcall X509_CertSubjectName(const char *szCertFile, char *szOutput, long nOutChars, const char *szDelim, long nOptions);
long _stdcall X509_GetCertFromP7Chain(const char *szNewCertFile, const char *szP7cFile, long nIndex, long nOptions);
long _stdcall X509_GetCertFromPFX(const char *szNewCertFile, const char *szPfxFile, const char *szPassword, long nOptions);
long _stdcall X509_KeyUsageFlags(const char *szCertFile);
long _stdcall X509_QueryCert(char *szOutput, long nOutChars, const char *szCertFile, const char *szQuery, long nOptions);
long _stdcall X509_ReadStringFromFile(char *szOutput, long nOutChars, const char *szCertFile, long nOptions);
long _stdcall X509_SaveFileFromString(const char *szNewCertFile, const char *szCertString, long nOptions);
/* [new in v3.5] */
long _stdcall X509_TextDump(const char *szFileOut, const char *szCertFile, long nOptions);
long _stdcall X509_ValidatePath(const char *szCertListOrP7File, const char *szTrustedCert, long nOptions);

/* X509 CRL FUNCTIONS [new in v3.5] */
long _stdcall X509_MakeCRL(const char *szCrlFile, const char *szIssuerCert, const char *szIssuerKeyFile, const char *szPassword, const char *szRevokedCertList, const char *szExtensions, long nOptions);
long _stdcall X509_CheckCertInCRL(const char *szCertFile, const char *szCrlFile, const char *szCRLIssuerCert, const char *szDate, long nOptions);

/* ONLINE CERTIFICATE STATUS PROTOCOL (OCSP) FUNCTIONS [new in v3.5] */
long _stdcall OCSP_MakeRequest(char *szOutput, long nOutChars, const char *szIssuerCert, const char *szCertFileOrSerialNum, const char *szExtensions, long nOptions);
long _stdcall OCSP_ReadResponse(char *szOutput, long nOutChars, const char *szResponseFile, const char *szIssuerCert, const char *szExtensions, long nOptions);

/* TRIPLE DES FUNCTIONS */
long _stdcall TDEA_HexMode(char *szOutput, const char *szInput, const char *szKey, long fEncrypt, const char *szMode, const char *szIV);
long _stdcall TDEA_B64Mode(char *szOutput, const char *szInput, const char *szKey, long fEncrypt, const char *szMode, const char *szIV);
long _stdcall TDEA_BytesMode(unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, long fEncrypt, const char *szMode, const unsigned char *lpIV);
long _stdcall TDEA_File(const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, long fEncrypt, const char *szMode, const unsigned char *lpIV);

/* GENERIC BLOCK CIPHER FUNCTIONS */
long _stdcall CIPHER_Bytes(long fEncrypt, unsigned char *lpOutput, const unsigned char *lpData, long nDataLen, const unsigned char *lpKey, const unsigned char *lpIV, const char *szAlgAndMode, long nOptions);
long _stdcall CIPHER_File(long fEncrypt, const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, const unsigned char *lpIV, const char *szAlgAndMode, long nOptions);
long _stdcall CIPHER_Hex(long fEncrypt, char *szOutput, long nOutChars, const char *szData, const char *szKey, const char *szIV, const char *szAlgAndMode, long nOptions);
long _stdcall CIPHER_KeyWrap(unsigned char *lpOutput, long nOutBytes, const unsigned char *lpData, long nDataLen, const unsigned char *lpKEK, long nKekLen, long nOptions);
long _stdcall CIPHER_KeyUnwrap(unsigned char *lpOutput, long nOutBytes, const unsigned char *lpData, long nDataLen, const unsigned char *lpKEK, long nKekLen, long nOptions);

/* MESSAGE DIGEST HASH FUNCTIONS */
long _stdcall HASH_Bytes(unsigned char *lpDigest, long nDigLen, const void *lpMessage, long nMsgLen, long nOptions);
long _stdcall HASH_File(unsigned char *lpDigest, long nDigLen, const char *szFileName, long nOptions);
long _stdcall HASH_HexFromBytes(char *szOutput, long nOutChars, const void *lpMessage, long nMsgLen, long nOptions);
long _stdcall HASH_HexFromFile(char *szOutput, long nOutChars, const char *szFileName, long nOptions);
long _stdcall HASH_HexFromHex(char *szOutput, long nOutChars, const char *szMsgHex, long nOptions);

/* HMAC FUNCTIONS */
long _stdcall HMAC_Bytes(unsigned char *lpDigest, long nDigLen, const void *lpMessage, long nMsgLen, const void *lpKey, long nKeyLen, long nOptions);
long _stdcall HMAC_HexFromBytes(char *szOutput, long nOutChars, const void *lpMessage, long nMsgLen, const void *lpKey, long nKeyLen, long nOptions);
long _stdcall HMAC_HexFromHex(char *szOutput, long nOutChars, const char *szMsgHex, const char *szKeyHex, long nOptions);

/* BASE64 AND HEX CONVERSION FUNCTIONS */
long _stdcall CNV_B64StrFromBytes(char *szOutput, long nOutChars, const unsigned char *input, long nBytes);
long _stdcall CNV_BytesFromB64Str(unsigned char *output, long out_len, const char *input);
long _stdcall CNV_B64Filter(char *szOutput, const char *input, long len);
long _stdcall CNV_HexStrFromBytes(char *szOutput, long nOutChars, const unsigned char *input, long nBytes);
long _stdcall CNV_BytesFromHexStr(unsigned char *output, long out_len, const char *input);
long _stdcall CNV_HexFilter(char *szOutput, const char *input, long len);

/* UTF-8 CONVERSION/CHECK FUNCTIONS */
/* [Note: the following three functions are deprecated as of v3.6] */
long _stdcall /* DEPRECATED */ CNV_UTF8FromLatin1(char *szOutput, long nOutChars, const char *szInput);
long _stdcall /* DEPRECATED */ CNV_Latin1FromUTF8(char *szOutput, long nOutChars, const char *szInput);
long _stdcall /* DEPRECATED */ CNV_CheckUTF8(const char *szInput);
/* [New in v3.6] */
long _stdcall CNV_UTF8BytesFromLatin1(unsigned char *lpOutput, long nOutBytes, const char *szInput);
long _stdcall CNV_Latin1FromUTF8Bytes(char *szOutput, long nOutChars, const unsigned char *lpInput, long nBytes);
long _stdcall CNV_CheckUTF8Bytes(const unsigned char *lpInput, long nBytes);
long _stdcall CNV_CheckUTF8File(const char *szFileName);
long _stdcall CNV_ByteEncoding(unsigned char *lpOutput, long nOutBytes, const unsigned char *lpInput, long nBytes, long nOptions);

/* PEM/BINARY FILE CONVERSIONS */
long _stdcall PEM_FileFromBinFile(const char *szOutputFile, const char *szFileIn, const char *szHeader, long nLineLen);
long _stdcall PEM_FileToBinFile(const char *szOutputFile, const char *szFileIn);

/* RNG FUNCTIONS */
long _stdcall RNG_Bytes(unsigned char *lpOutput, long nOutputLen, const void *lpSeed, long nSeedLen);
long _stdcall RNG_Number(long nLower, long nUpper);
long _stdcall RNG_BytesWithPrompt(unsigned char *lpOutput, long nOutputLen, const char *szPrompt, long nOptions);
long _stdcall RNG_Initialize(const char *szSeedFile, long nOptions);
long _stdcall RNG_MakeSeedFile( const char *szSeedFile, const char *szPrompt, long nOptions);
long _stdcall RNG_UpdateSeedFile(const char *szSeedFile, long nOptions);
long _stdcall RNG_Test(const char *szFileName, long nOptions);

/* PADDING FUNCTIONS [new in v3.6] */
long _stdcall PAD_BytesBlock(unsigned char *lpOutput, long nOutputLen, const unsigned char *lpInput, long nBytes, long nBlkLen, long nOptions);
long _stdcall PAD_UnpadBytes(unsigned char *lpOutput, long nOutputLen, const unsigned char *lpInput, long nBytes, long nBlkLen, long nOptions);
long _stdcall PAD_HexBlock(char *szOutput, long nMaxChars, const char *szInput, long nBlkLen, long nOptions);
long _stdcall PAD_UnpadHex(char *szOutput, long nMaxChars, const char *szInput, long nBlkLen, long nOptions);

/* MISC UTILITIES */
long _stdcall WIPE_File(const char *szFileName, long nOptions);
long _stdcall WIPE_Data(void *lpData, long nDataLen);
long _stdcall PWD_Prompt(char *szPassword, long nPwdLen, const char *szCaption);
long _stdcall PWD_PromptEx(char *szPassword, long nPwdLen, const char *szCaption, const char *szPrompt, long nOptions);


#ifdef __cplusplus
}
#endif

#endif /* end DICRPKI_H_ */