From aa244fe2abbea40457ae1b75bcae12a7ed419bca Mon Sep 17 00:00:00 2001 From: Jim Norman Date: Fri, 29 Sep 2006 20:04:50 +0000 Subject: [PATCH] Add Write\ReadBinaryKey to sample --- CASA/test/c_sample/cSample.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/CASA/test/c_sample/cSample.c b/CASA/test/c_sample/cSample.c index 44c13864..9e88a6c8 100644 --- a/CASA/test/c_sample/cSample.c +++ b/CASA/test/c_sample/cSample.c @@ -44,6 +44,7 @@ /////////////////////////////////////////////////////////////////////// +unsigned char UTF8Value[] = {0xED, 0x98, 0x9C, 0xED, 0x98, 0xA4, 0xED, 0x95, 0xAB, 0xED, 0x9B, 0xA7, 0xED, 0x9D, 0x8F, 00}; void Pause() { @@ -228,7 +229,7 @@ void ReadBinaryKey() appSecretId.len = sscs_Utf8Strlen(inputID) + 1; sscs_Utf8Strcpy(appSecretId.id, inputID); - printf("SAMPLE: Calling miCASAReadKey\r\n"); + printf("SAMPLE: Calling miCASAReadBinaryKey\r\n"); // open secretStore sscs_Utf8Strcpy(store.ssName, SSCS_DEFAULT_SECRETSTORE_ID); @@ -266,7 +267,15 @@ void ReadBinaryKey() { //set null //memcpy(inputValue[valueLen + 1], - printf("KeyValue is %s\r\n", inputValue); + //printf("KeyValue is %s\r\n", inputValue); + if (!memcmp(inputValue, UTF8Value, valueLen)) + { + printf("Matched\r\n"); + } + else + { + printf("did not match\r\n"); + } } } } @@ -361,17 +370,17 @@ void WriteBinaryKey() printf("Enter Key: "); gets(inputKey); - printf("Enter Value: "); - gets(inputValue); + //printf("Enter Value: "); + //gets(inputValue); if ((sscs_Utf8Strlen(inputID) > 0) && - (sscs_Utf8Strlen(inputKey) > 0) && - (sscs_Utf8Strlen(inputValue) > 0)) + (sscs_Utf8Strlen(inputKey) > 0)) + { appSecretId.len = sscs_Utf8Strlen(inputID) + 1; sscs_Utf8Strcpy(appSecretId.id, inputID); - printf("SAMPLE: Calling miCASAWriteKey\r\n"); + printf("SAMPLE: Calling miCASAWriteBinaryKey\r\n"); // open secretStore sscs_Utf8Strcpy(store.ssName, SSCS_DEFAULT_SECRETSTORE_ID); @@ -386,15 +395,15 @@ void WriteBinaryKey() sscs_Utf8Strcpy(kc.keychainID, SSCS_SESSION_KEY_CHAIN_ID); kc.len = SSCS_S_KC_ID_CHARS; - valueLen = sscs_strlen(inputValue) + 1; + valueLen = strlen(UTF8Value) + 1; - miCASAWriteBinaryKey(context, + rcode = miCASAWriteBinaryKey(context, 0, &kc, &appSecretId, inputKey, strlen(inputKey)+1, - inputValue, + UTF8Value, &valueLen, NULL, &ext);