#pragma once

#define CK_FALSE 0
#define CK_TRUE 1

/* RU TEAM ADDITIONAL VALUES */
#define NSSCK_VENDOR_PKSC11_RU_TEAM  0xd4321000 //0xd4321000  /* 0x80000000 | 0x54321000 */
#define NSSCK_VENDOR_PKCS11_RU_TEAM  NSSCK_VENDOR_PKSC11_RU_TEAM
/* LISSI ADDITIONAL VALUES */
#define NSSCK_VENDOR_PKSC11_RU_LISSI (NSSCK_VENDOR_PKSC11_RU_TEAM | 0x800) /* 0x80000000 | 0x54321000 | 0x800*/
#define NSSCK_VENDOR_PKCS11_RU_LISSI NSSCK_VENDOR_PKSC11_RU_LISSI

/* GOST KEY TYPES */
#define CKK_GOSTR3410   0x00000030
#define CKK_GOSTR3411   0x00000031
#define CKK_GOST28147   0x00000032

/* GOST OBJECT ATTRIBUTES */
#define CKA_GOSTR3410_PARAMS   0x00000250
#define CKA_GOSTR3411_PARAMS   0x00000251
#define CKA_GOST28147_PARAMS   0x00000252
#define CKA_GOSTR3410PARAMS    CKA_GOSTR3410_PARAMS
#define CKA_GOSTR3411PARAMS    CKA_GOSTR3411_PARAMS
#define CKA_GOST28147PARAMS    CKA_GOST28147_PARAMS

/* GOST MECHANISMS */
#define CKM_GOSTR3410_KEY_PAIR_GEN   0x00001200
#define CKM_GOSTR3410                0x00001201
#define CKM_GOSTR3410_WITH_GOSTR3411 0x00001202
#define CKM_GOSTR3410_KEY_WRAP       0x00001203
#define CKM_GOSTR3410_DERIVE         0x00001204

#define CKM_GOSTR3411                0x00001210
#define CKM_GOSTR3411_HMAC           0x00001211

#define CKM_GOST28147_KEY_GEN        0x00001220
#define CKM_GOST28147_ECB            0x00001221
#define CKM_GOST28147                0x00001222
#define CKM_GOST28147_MAC            0x00001223
#define CKM_GOST28147_KEY_WRAP       0x00001224

#define CKM_GOST28147_CNT            (NSSCK_VENDOR_PKSC11_RU_TEAM |0x025)
#define CKM_GOST28147_KEY_CPDIVERSIFY (NSSCK_VENDOR_PKSC11_RU_TEAM |0x026)

#define CKM_TLS_GOST_PRF             (NSSCK_VENDOR_PKSC11_RU_TEAM |0x030)
#define CKM_TLS_GOST_PRE_MASTER_KEY_GEN (NSSCK_VENDOR_PKSC11_RU_TEAM |0x031)
#define CKM_TLS_GOST_MASTER_KEY_DERIVE	(NSSCK_VENDOR_PKSC11_RU_TEAM |0x032)
#define CKM_TLS_GOST_KEY_AND_MAC_DERIVE (NSSCK_VENDOR_PKSC11_RU_TEAM |0x033)

/* new, 32-byte (256-bit) buffer */
#define CKM_PBA_GOSTR3411_WITH_GOSTR3411_HMAC \
                                               (NSSCK_VENDOR_PKSC11_RU_TEAM|0x035)
#define CKM_GOST28147_PKCS8_KEY_WRAP (NSSCK_VENDOR_PKSC11_RU_TEAM|0x036)
#define CKM_GOSTR3410_PUBLIC_KEY_DERIVE (NSSCK_VENDOR_PKSC11_RU_TEAM|0x037)

#define CKD_CPDIVERSIFY_KDF   0x00000009

#define CKN_LISSI_PIN_CALLBACK (NSSCK_VENDOR_PKSC11_RU_LISSI | 0x001)

#define CKP_PKCS5_PBKD2_HMAC_GOSTR3411 0x00000002

// Structure for CKM_PBA_GOSTR3411_WITH_GOSTR3411_HMAC
typedef struct CK_GOSTR3411_PBE_PARAMS {
    CK_BYTE_PTR     pOID;
    CK_ULONG        ulOIDLen;
    CK_UTF8CHAR_PTR pPassword;
    CK_ULONG        ulPasswordLen;
    CK_CHAR_PTR     pSalt;
    CK_ULONG        ulSaltLen;
    CK_ULONG        ulIteration;
} CK_GOSTR3411_PBE_PARAMS;

typedef CK_GOSTR3411_PBE_PARAMS CK_PTR CK_GOSTR3411_PBE_PARAMS_PTR;


typedef struct CK_GOSTR3410_KEY_WRAP_PARAMS {
	CK_BYTE_PTR      pWrapOID;
	CK_ULONG         ulWrapOIDLen;
	CK_BYTE_PTR      pUKM;
	CK_ULONG         ulUKMLen;
	CK_OBJECT_HANDLE hKey;
} CK_GOSTR3410_KEY_WRAP_PARAMS;
typedef CK_GOSTR3410_KEY_WRAP_PARAMS CK_PTR  CK_GOSTR3410_KEY_WRAP_PARAMS_PTR;  

typedef struct CK_GOST28147_PKCS8_KEY_WRAP_PARAMS {
    CK_UTF8CHAR_PTR  pPassword;
    CK_ULONG         ulPasswordLen;
	CK_BYTE_PTR      pHashParOID;
	CK_ULONG         ulHashParOIDLen;
	CK_BYTE_PTR      pSalt;
	CK_ULONG         ulSaltLen;
    CK_ULONG         ulIterCount;
	CK_BYTE_PTR      pCipherParOID;
	CK_ULONG         ulCipherParOIDLen;
	CK_BYTE_PTR      pIV;
	CK_ULONG         ulIVLen;
} CK_GOST28147_PKCS8_KEY_WRAP_PARAMS;
typedef CK_GOST28147_PKCS8_KEY_WRAP_PARAMS CK_PTR  CK_GOST28147_PKCS8_KEY_WRAP_PARAMS_PTR;  

typedef struct CK_GOSTR3410_DERIVE_PARAMS {
    CK_EC_KDF_TYPE   kdf;
    CK_BYTE_PTR      pPublicData;
    CK_ULONG         ulPublicDataLen;
    CK_BYTE_PTR      pUKM;
    CK_ULONG         ulUKMLen;
} CK_GOSTR3410_DERIVE_PARAMS; 
typedef CK_GOSTR3410_DERIVE_PARAMS CK_PTR CK_GOSTR3410_DERIVE_PARAMS_PTR;

typedef struct CK_TLS_PRF_PARAMS {
  CK_BYTE_PTR pSeed;
  CK_ULONG ulSeedLen;
  CK_UTF8CHAR_PTR pLabel;
  CK_ULONG ulLabelLen;
  CK_BYTE_PTR pOutput;
  CK_ULONG_PTR pulOutputLen;
} CK_TLS_PRF_PARAMS;

typedef CK_TLS_PRF_PARAMS CK_PTR CK_TLS_PRF_PARAMS_PTR;

typedef struct CK_TLS_GOST_PRF_PARAMS {
	CK_TLS_PRF_PARAMS  TlsPrfParams;
	CK_BYTE_PTR        pHashParamsOid;
	CK_ULONG           ulHashParamsOidLen;
} CK_TLS_GOST_PRF_PARAMS;
typedef CK_TLS_GOST_PRF_PARAMS CK_PTR CK_TLS_GOST_PRF_PARAMS_PTR;

typedef struct CK_TLS_GOST_MASTER_KEY_DERIVE_PARAMS {
	CK_SSL3_RANDOM_DATA RandomInfo;
	CK_BYTE_PTR         pHashParamsOid;
	CK_ULONG            ulHashParamsOidLen;
} CK_TLS_GOST_MASTER_KEY_DERIVE_PARAMS;
typedef CK_TLS_GOST_MASTER_KEY_DERIVE_PARAMS CK_PTR CK_TLS_GOST_MASTER_KEY_DERIVE_PARAMS_PTR;

typedef struct CK_TLS_GOST_KEY_MAT_PARAMS {
	CK_SSL3_KEY_MAT_PARAMS KeyMatParams;
	CK_BYTE_PTR           pHashParamsOid;
	CK_ULONG               ulHashParamsOidLen;
} CK_TLS_GOST_KEY_MAT_PARAMS;
typedef CK_TLS_GOST_KEY_MAT_PARAMS CK_PTR CK_TLS_GOST_KEY_MAT_PARAMS_PTR;

