1*12720SWyllys.Ingersoll@Sun.COM /* 2*12720SWyllys.Ingersoll@Sun.COM * CDDL HEADER START 3*12720SWyllys.Ingersoll@Sun.COM * 4*12720SWyllys.Ingersoll@Sun.COM * The contents of this file are subject to the terms of the 5*12720SWyllys.Ingersoll@Sun.COM * Common Development and Distribution License (the "License"). 6*12720SWyllys.Ingersoll@Sun.COM * You may not use this file except in compliance with the License. 7*12720SWyllys.Ingersoll@Sun.COM * 8*12720SWyllys.Ingersoll@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*12720SWyllys.Ingersoll@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*12720SWyllys.Ingersoll@Sun.COM * See the License for the specific language governing permissions 11*12720SWyllys.Ingersoll@Sun.COM * and limitations under the License. 12*12720SWyllys.Ingersoll@Sun.COM * 13*12720SWyllys.Ingersoll@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*12720SWyllys.Ingersoll@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*12720SWyllys.Ingersoll@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*12720SWyllys.Ingersoll@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*12720SWyllys.Ingersoll@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*12720SWyllys.Ingersoll@Sun.COM * 19*12720SWyllys.Ingersoll@Sun.COM * CDDL HEADER END 20*12720SWyllys.Ingersoll@Sun.COM */ 21*12720SWyllys.Ingersoll@Sun.COM 22*12720SWyllys.Ingersoll@Sun.COM /* 23*12720SWyllys.Ingersoll@Sun.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24*12720SWyllys.Ingersoll@Sun.COM */ 25*12720SWyllys.Ingersoll@Sun.COM 26*12720SWyllys.Ingersoll@Sun.COM /** @file KMSAgentDataUnitCache.h 27*12720SWyllys.Ingersoll@Sun.COM * @defgroup EncryptionAgent Encryption Agent API 28*12720SWyllys.Ingersoll@Sun.COM * 29*12720SWyllys.Ingersoll@Sun.COM */ 30*12720SWyllys.Ingersoll@Sun.COM #ifndef KMSAGENT_DATA_UNIT_CACHE_H 31*12720SWyllys.Ingersoll@Sun.COM #define KMSAGENT_DATA_UNIT_CACHE_H 32*12720SWyllys.Ingersoll@Sun.COM 33*12720SWyllys.Ingersoll@Sun.COM #define DATA_UNIT_CACHE_MAX_SIZE 128 34*12720SWyllys.Ingersoll@Sun.COM 35*12720SWyllys.Ingersoll@Sun.COM typedef struct DataUnitCacheEntry 36*12720SWyllys.Ingersoll@Sun.COM { 37*12720SWyllys.Ingersoll@Sun.COM utf8char m_wsApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS+1]; 38*12720SWyllys.Ingersoll@Sun.COM unsigned char m_aDataUnitID[KMS_DATA_UNIT_ID_SIZE]; 39*12720SWyllys.Ingersoll@Sun.COM unsigned char m_aDataUnitKeyID[KMS_KEY_ID_SIZE]; 40*12720SWyllys.Ingersoll@Sun.COM 41*12720SWyllys.Ingersoll@Sun.COM } DataUnitCacheEntry; 42*12720SWyllys.Ingersoll@Sun.COM 43*12720SWyllys.Ingersoll@Sun.COM /** 44*12720SWyllys.Ingersoll@Sun.COM * Maintains an affinity list between KMAs and DUs and KeyIDs. 45*12720SWyllys.Ingersoll@Sun.COM */ 46*12720SWyllys.Ingersoll@Sun.COM class CDataUnitCache 47*12720SWyllys.Ingersoll@Sun.COM { 48*12720SWyllys.Ingersoll@Sun.COM 49*12720SWyllys.Ingersoll@Sun.COM public: 50*12720SWyllys.Ingersoll@Sun.COM CDataUnitCache(int i_iMaxSize = DATA_UNIT_CACHE_MAX_SIZE); 51*12720SWyllys.Ingersoll@Sun.COM ~CDataUnitCache(); 52*12720SWyllys.Ingersoll@Sun.COM 53*12720SWyllys.Ingersoll@Sun.COM /** 54*12720SWyllys.Ingersoll@Sun.COM * insert a new DataUnitCacheEntry into the cache list, either i_pDataUnitID or 55*12720SWyllys.Ingersoll@Sun.COM * i_pDataUnitKeyID must be specified for affinity with the specified i_wsApplianceNetworkAddress 56*12720SWyllys.Ingersoll@Sun.COM * @param i_pDataUnitID optional, specifies a DU ID cache entry if specified 57*12720SWyllys.Ingersoll@Sun.COM * @param i_iDataUnitIDMaxLen ignored if i_pDataUnitID not specified, otherwise 58*12720SWyllys.Ingersoll@Sun.COM * specifies the length of i_pDataUnitID 59*12720SWyllys.Ingersoll@Sun.COM * @param i_pDataUnitKeyID optional, specifies a Key ID cache entry if specified 60*12720SWyllys.Ingersoll@Sun.COM * @param i_iDataUnitKeyIDMaxLen ignored if i_pDataUnitKeyID is not specified, 61*12720SWyllys.Ingersoll@Sun.COM * otherwise specifies the length of i_pDataUnitKeyID 62*12720SWyllys.Ingersoll@Sun.COM * @param i_wsApplianceNetworkAddress required and specifies the KMA affiliated 63*12720SWyllys.Ingersoll@Sun.COM * with the DU ID or Key ID 64*12720SWyllys.Ingersoll@Sun.COM * @return True if successfully inserted into the cache 65*12720SWyllys.Ingersoll@Sun.COM */ 66*12720SWyllys.Ingersoll@Sun.COM bool Insert( 67*12720SWyllys.Ingersoll@Sun.COM const unsigned char* const i_pDataUnitID, 68*12720SWyllys.Ingersoll@Sun.COM int i_iDataUnitIDMaxLen, 69*12720SWyllys.Ingersoll@Sun.COM const unsigned char* const i_pDataUnitKeyID , 70*12720SWyllys.Ingersoll@Sun.COM int i_iDataUnitKeyIDMaxLen, 71*12720SWyllys.Ingersoll@Sun.COM const utf8char* const i_wsApplianceNetworkAddress ); 72*12720SWyllys.Ingersoll@Sun.COM 73*12720SWyllys.Ingersoll@Sun.COM bool GetApplianceByDataUnitID( 74*12720SWyllys.Ingersoll@Sun.COM const unsigned char* const i_pDataUnitID, 75*12720SWyllys.Ingersoll@Sun.COM int i_iDataUnitIDMaxLen, 76*12720SWyllys.Ingersoll@Sun.COM utf8char* const o_wsApplianceNetworkAddress, 77*12720SWyllys.Ingersoll@Sun.COM int i_iMaxApplianceNetworkAddressLen ); 78*12720SWyllys.Ingersoll@Sun.COM 79*12720SWyllys.Ingersoll@Sun.COM bool GetApplianceByDataUnitKeyID( 80*12720SWyllys.Ingersoll@Sun.COM const unsigned char* const i_pDataUnitKeyID, 81*12720SWyllys.Ingersoll@Sun.COM int i_iDataUnitKeyIDMaxLen, 82*12720SWyllys.Ingersoll@Sun.COM utf8char* const o_wsApplianceNetworkAddress, 83*12720SWyllys.Ingersoll@Sun.COM int i_iMaxApplianceNetworkAddressLen ); 84*12720SWyllys.Ingersoll@Sun.COM 85*12720SWyllys.Ingersoll@Sun.COM protected: 86*12720SWyllys.Ingersoll@Sun.COM void Lock(); 87*12720SWyllys.Ingersoll@Sun.COM void Unlock(); 88*12720SWyllys.Ingersoll@Sun.COM 89*12720SWyllys.Ingersoll@Sun.COM private: 90*12720SWyllys.Ingersoll@Sun.COM K_MUTEX_HANDLE m_Lock; 91*12720SWyllys.Ingersoll@Sun.COM 92*12720SWyllys.Ingersoll@Sun.COM int m_iIndex; 93*12720SWyllys.Ingersoll@Sun.COM int m_iSize; 94*12720SWyllys.Ingersoll@Sun.COM int m_iMaxSize; 95*12720SWyllys.Ingersoll@Sun.COM DataUnitCacheEntry *m_pCache; 96*12720SWyllys.Ingersoll@Sun.COM 97*12720SWyllys.Ingersoll@Sun.COM }; 98*12720SWyllys.Ingersoll@Sun.COM 99*12720SWyllys.Ingersoll@Sun.COM #endif 100