Updated cSample with examples to use server secret support.

Exported miCASADeleteCredential.
This commit is contained in:
Rajasekaran Nagarajan 2006-10-20 04:49:58 +00:00
parent 258bb6c2e9
commit eb90af6c4e
4 changed files with 810 additions and 770 deletions

View File

@ -253,7 +253,7 @@ namespace sscs.crypto
fsEncrypt.Write(hash,0,hash.Length); fsEncrypt.Write(hash,0,hash.Length);
fsEncrypt.Flush(); fsEncrypt.Flush();
#if true//#if CLEAR //RAJ #if CLEAR
byte[] dup = (byte[])xmlData.Clone(); byte[] dup = (byte[])xmlData.Clone();
// write clear file // write clear file
FileStream fsClear = new FileStream(fileName + ".xml", FileMode.Create); FileStream fsClear = new FileStream(fileName + ".xml", FileMode.Create);

View File

@ -74,7 +74,7 @@ namespace sscs.lss
private static string LINUXID = "Unix"; private static string LINUXID = "Unix";
internal LocalStorage(SecretStore store, byte[] baMasterPasscode, bool dummy) // Merge this with the next cons - RAJ internal LocalStorage(SecretStore store, byte[] baMasterPasscode, bool dummy)
{ {
userStore = store; userStore = store;
m_baGeneratedKey = baMasterPasscode; m_baGeneratedKey = baMasterPasscode;

View File

@ -26,6 +26,7 @@ VER_1.0
miCASALockStore; miCASALockStore;
miCASARemoveKeyChain; miCASARemoveKeyChain;
miCASARemoveCredential; miCASARemoveCredential;
miCASADeleteCredential;
miCASASetCredential; miCASASetCredential;
miCASAGetCredential; miCASAGetCredential;
miCASAIsSecretPersistent; miCASAIsSecretPersistent;

View File

@ -418,7 +418,7 @@ void WriteBinaryKey()
} }
} }
void AddSecret() void AddSecret(int32_t credentialType)
{ {
int rcode = 0; int rcode = 0;
char inputID[20]; char inputID[20];
@ -460,7 +460,7 @@ void AddSecret()
0, 0,
&appSecretId, &appSecretId,
NULL, NULL,
SSCS_CRED_TYPE_BASIC_F, credentialType,
&credential, &credential,
NULL NULL
); );
@ -473,12 +473,12 @@ void AddSecret()
} }
} }
void DisplaySecret() void DisplaySecret(int32_t credentialType)
{ {
int rcode = 0; int rcode = 0;
char inputID[20]; char inputID[20];
int32_t credtype = SSCS_CRED_TYPE_BASIC_F; int32_t credtype = credentialType;
SSCS_BASIC_CREDENTIAL credential = {0}; SSCS_BASIC_CREDENTIAL credential = {0};
SSCS_SECRET_ID_T appSecretId = {0}; SSCS_SECRET_ID_T appSecretId = {0};
@ -502,7 +502,7 @@ void DisplaySecret()
0, 0,
&appSecretId, &appSecretId,
NULL, NULL,
&credtype, //SSCS_CRED_TYPE_BASIC_F, &credtype,
&credential, &credential,
NULL NULL
); );
@ -521,7 +521,7 @@ void DisplaySecret()
} }
} }
void RemoveSecret() void RemoveSecret(int32_t credentialType)
{ {
int rcode = 0; int rcode = 0;
char inputID[20]; char inputID[20];
@ -544,10 +544,11 @@ void RemoveSecret()
credential.unFlags = USERNAME_TYPE_CN_F; credential.unFlags = USERNAME_TYPE_CN_F;
// gets the credential // gets the credential
rcode = miCASARemoveCredential( rcode = miCASADeleteCredential(
0, 0,
&appSecretId, &appSecretId,
NULL, NULL,
credentialType,
NULL NULL
); );
@ -563,6 +564,36 @@ void RemoveSecret()
} }
} }
void AddUserSecret()
{
AddSecret(SSCS_CRED_TYPE_BASIC_F);
}
void DisplayUserSecret()
{
DisplaySecret(SSCS_CRED_TYPE_BASIC_F);
}
void RemoveUserSecret()
{
RemoveSecret(SSCS_CRED_TYPE_BASIC_F);
}
void AddServerSecret()
{
AddSecret(SSCS_CRED_TYPE_SERVER_F);
}
void DisplayServerSecret()
{
DisplaySecret(SSCS_CRED_TYPE_SERVER_F);
}
void RemoveServerSecret()
{
RemoveSecret(SSCS_CRED_TYPE_SERVER_F);
}
void RunTest() void RunTest()
{ {
{ {
@ -759,18 +790,21 @@ void displayMenu()
while (1) while (1)
{ {
printf("\r\n"); printf("\r\n");
printf("********** Menu **********\r\n"); printf("********** Menu *************\r\n");
printf("* 1. Add secret *\r\n"); printf("* 1. Add secret *\r\n");
printf("* 2. Display secret *\r\n"); printf("* 2. Display secret *\r\n");
printf("* 3. Remove secret *\r\n"); printf("* 3. Remove secret *\r\n");
printf("* 4. Run automated test *\r\n"); printf("* 4. Run automated test *\r\n");
printf("* 5. WriteKey *\r\n"); printf("* 5. WriteKey *\r\n");
printf("* 6. ReadKey *\r\n"); printf("* 6. ReadKey *\r\n");
printf("* 7. RemoveKey *\r\n"); printf("* 7. RemoveKey *\r\n");
printf("* 8. WriteBinaryKey *\r\n"); printf("* 8. WriteBinaryKey *\r\n");
printf("* 9. ReadBinaryKey *\r\n"); printf("* 9. ReadBinaryKey *\r\n");
printf("* Q. Quit *\r\n"); printf("* a. Add server secret *\r\n");
printf("**************************\r\n"); printf("* b. Display server secret *\r\n");
printf("* c. Remove server secret *\r\n");
printf("* Q. Quit *\r\n");
printf("*****************************\r\n");
printf("Select option and press Enter\r\n"); printf("Select option and press Enter\r\n");
@ -782,11 +816,11 @@ void displayMenu()
if ((c == 'Q') || (c == 'q')) if ((c == 'Q') || (c == 'q'))
return; return;
else if (c == '1') else if (c == '1')
AddSecret(); AddUserSecret();
else if (c == '2') else if (c == '2')
DisplaySecret(); DisplayUserSecret();
else if (c == '3') else if (c == '3')
RemoveSecret(); RemoveUserSecret();
else if (c == '4') else if (c == '4')
RunTests(); RunTests();
else if (c == '5') else if (c == '5')
@ -799,7 +833,12 @@ void displayMenu()
WriteBinaryKey(); WriteBinaryKey();
else if (c == '9') else if (c == '9')
ReadBinaryKey(); ReadBinaryKey();
else if ((c == 'A') || (c == 'a'))
AddServerSecret();
else if ((c == 'B') || (c == 'b'))
DisplayServerSecret();
else if ((c == 'C') || (c == 'c'))
RemoveServerSecret();
} }