Enable Firefox support on Windows, and checkpoint Windows Project files.
This commit is contained in:
@@ -37,7 +37,9 @@
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <sscs_utf8.h>
|
||||
#include <micasa_mgmd.h>
|
||||
#include <micasa.h>
|
||||
#include <sscs_cache.h>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -51,6 +53,147 @@ void Pause()
|
||||
|
||||
|
||||
|
||||
void ReadKey()
|
||||
{
|
||||
int rcode = 0;
|
||||
char inputID[20];
|
||||
char inputKey[20];
|
||||
char inputValue[128] = {0};
|
||||
uint32_t valueLen = 128;
|
||||
uint32_t bytesRequired = 0;
|
||||
|
||||
SSCS_SECRETSTORE_T store = {0};
|
||||
SSCS_SECRET_ID_T appSecretId = {0};
|
||||
SSCS_SECRET_ID_T sharedSecretId = {0};
|
||||
void *context;
|
||||
SSCS_KEYCHAIN_ID_T kc = {0};
|
||||
|
||||
SSCS_EXT_T ext = {0};
|
||||
|
||||
printf("Enter secretID: ");
|
||||
gets(inputID);
|
||||
|
||||
printf("Enter Key: ");
|
||||
gets(inputKey);
|
||||
|
||||
if ((sscs_Utf8Strlen(inputID) > 0) &&
|
||||
(sscs_Utf8Strlen(inputKey) > 0))
|
||||
|
||||
{
|
||||
appSecretId.len = sscs_Utf8Strlen(inputID) + 1;
|
||||
sscs_Utf8Strcpy(appSecretId.id, inputID);
|
||||
|
||||
printf("SAMPLE: Calling miCASAReadKey\r\n");
|
||||
|
||||
// open secretStore
|
||||
sscs_Utf8Strcpy(store.ssName, SSCS_DEFAULT_SECRETSTORE_ID);
|
||||
store.version = 1;
|
||||
context = miCASAOpenSecretStoreCache(&store, 0, NULL);
|
||||
|
||||
if (context == NULL)
|
||||
{
|
||||
return; // NSSCS_E_SYSTEM_FAILURE;
|
||||
}
|
||||
|
||||
sscs_Utf8Strcpy(kc.keychainID, SSCS_SESSION_KEY_CHAIN_ID);
|
||||
kc.len = SSCS_S_KC_ID_CHARS;
|
||||
|
||||
rcode = miCASAReadKey(context,
|
||||
0,
|
||||
&kc,
|
||||
&appSecretId,
|
||||
inputKey,
|
||||
strlen(inputKey)+1,
|
||||
inputValue,
|
||||
&valueLen,
|
||||
NULL,
|
||||
&bytesRequired,
|
||||
&ext);
|
||||
|
||||
miCASACloseSecretStoreCache(context, 0, NULL);
|
||||
|
||||
if (rcode)
|
||||
{
|
||||
printf("miCASAReadKey returned %d\r\n", rcode);
|
||||
Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
//set null
|
||||
//memcpy(inputValue[valueLen + 1],
|
||||
printf("KeyValue is %s\r\n", inputValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WriteKey()
|
||||
{
|
||||
int rcode = 0;
|
||||
char inputID[20];
|
||||
char inputKey[20];
|
||||
char inputValue[20];
|
||||
|
||||
SSCS_SECRETSTORE_T store = {0};
|
||||
SSCS_SECRET_ID_T appSecretId = {0};
|
||||
SSCS_SECRET_ID_T sharedSecretId = {0};
|
||||
void *context;
|
||||
SSCS_KEYCHAIN_ID_T kc = {0};
|
||||
|
||||
SSCS_EXT_T ext = {0};
|
||||
|
||||
printf("Enter secretID: ");
|
||||
gets(inputID);
|
||||
|
||||
printf("Enter Key: ");
|
||||
gets(inputKey);
|
||||
|
||||
printf("Enter Value: ");
|
||||
gets(inputValue);
|
||||
|
||||
if ((sscs_Utf8Strlen(inputID) > 0) &&
|
||||
(sscs_Utf8Strlen(inputKey) > 0) &&
|
||||
(sscs_Utf8Strlen(inputValue) > 0))
|
||||
{
|
||||
appSecretId.len = sscs_Utf8Strlen(inputID) + 1;
|
||||
sscs_Utf8Strcpy(appSecretId.id, inputID);
|
||||
|
||||
printf("SAMPLE: Calling miCASAWriteKey\r\n");
|
||||
|
||||
// open secretStore
|
||||
sscs_Utf8Strcpy(store.ssName, SSCS_DEFAULT_SECRETSTORE_ID);
|
||||
store.version = 1;
|
||||
context = miCASAOpenSecretStoreCache(&store, 0, NULL);
|
||||
|
||||
if (context == NULL)
|
||||
{
|
||||
return; // NSSCS_E_SYSTEM_FAILURE;
|
||||
}
|
||||
|
||||
sscs_Utf8Strcpy(kc.keychainID, SSCS_SESSION_KEY_CHAIN_ID);
|
||||
kc.len = SSCS_S_KC_ID_CHARS;
|
||||
|
||||
rcode = miCASAWriteKey(context,
|
||||
0,
|
||||
&kc,
|
||||
&appSecretId,
|
||||
inputKey,
|
||||
strlen(inputKey)+1,
|
||||
inputValue,
|
||||
strlen(inputValue)+1,
|
||||
NULL,
|
||||
&ext);
|
||||
|
||||
miCASACloseSecretStoreCache(context, 0, NULL);
|
||||
|
||||
if (rcode)
|
||||
{
|
||||
printf("miCASAWriteKey returned %d\r\n", rcode);
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddSecret()
|
||||
{
|
||||
int rcode = 0;
|
||||
@@ -396,8 +539,10 @@ void displayMenu()
|
||||
printf("* 1. Add secret *\r\n");
|
||||
printf("* 2. Display secret *\r\n");
|
||||
printf("* 3. Remove secret *\r\n");
|
||||
printf("* 4. Run automated test *\r\n");
|
||||
printf("* 5. Quit *\r\n");
|
||||
printf("* 4. Run automated test *\r\n");
|
||||
printf("* 5. WriteKey *\r\n");
|
||||
printf("* 6. ReadKey *\r\n");
|
||||
printf("* 7. Quit *\r\n");
|
||||
printf("**************************\r\n");
|
||||
|
||||
|
||||
@@ -407,7 +552,7 @@ void displayMenu()
|
||||
// get return
|
||||
getchar();
|
||||
|
||||
if (c == '5')
|
||||
if (c == '7')
|
||||
return;
|
||||
else if (c == '1')
|
||||
AddSecret();
|
||||
@@ -417,7 +562,12 @@ void displayMenu()
|
||||
RemoveSecret();
|
||||
else if (c == '4')
|
||||
RunTests();
|
||||
|
||||
else if (c == '5')
|
||||
WriteKey();
|
||||
else if (c == '6')
|
||||
ReadKey();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user