diff --git a/c_micasad/verbs/ReadKey.cs b/c_micasad/verbs/ReadKey.cs index 4779a899..1f6b9ca7 100644 --- a/c_micasad/verbs/ReadKey.cs +++ b/c_micasad/verbs/ReadKey.cs @@ -126,8 +126,14 @@ namespace sscs.verbs else { secret = keyChain.GetSecret(secretId); - string valStr = secret.GetKeyValue(key).GetValue(); - val = Encoding.UTF8.GetBytes(valStr); + KeyValue kv = secret.GetKeyValue(key); + if (kv != null) + { + string valStr = secret.GetKeyValue(key).GetValue(); + val = Encoding.UTF8.GetBytes(valStr); + } + else + retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; } } else diff --git a/c_micasadk/sscs_ndk.c b/c_micasadk/sscs_ndk.c index f99ee827..4d27c6d9 100644 --- a/c_micasadk/sscs_ndk.c +++ b/c_micasadk/sscs_ndk.c @@ -536,6 +536,51 @@ static int32_t sscsshs_UnescapeSecretIDBuf /* ############################### CODE ENDS HERE ############################# */ } /* end of sscsshs_UnescapeSecretIDBuf */ +static int32_t unescapeString(uint8_t *val, uint32_t *valueLen) +{ + uint32_t k,i = 0; + uint32_t len = 0; + uint8_t *temp; + uint32_t rc = NSSCS_SUCCESS; + + len = *valueLen; + temp = malloc(len); + if (temp) + { + for(k = i = 0; i < len; i++) + { + rc = NSSCS_SUCCESS; + if(val[i] == (SS_UTF8_T)'\\') + { + if(i + 1 < len) + { + if(val[i + 1] == (SS_UTF8_T)'\\' + || val[i + 1] == (SS_UTF8_T)'=' + || val[i + 1] == (SS_UTF8_T)':') + { + temp[k++] = val[i + 1]; + i++; + } + } + else + { + temp[k] = val[i]; + } + } + else + { + temp[k++] = val[i]; + } + } // end for ... + temp[k] = '\0'; + sscs_Utf8Strcpy(val, temp); + *valueLen = k; + free(temp); + return rc; + } + else + return NSSCS_E_PARSER_FAILURE; +} /* @@ -1798,6 +1843,11 @@ miCASAReadKey epPassword, bytesRequired, ext); + + if (rc == NSSCS_SUCCESS) + { + unescapeString(val, valLen); + } /* ############################### CODE EXITS HERE ############################# */ diff --git a/include/micasa.h b/include/micasa.h index 849d269d..93bcffd8 100644 --- a/include/micasa.h +++ b/include/micasa.h @@ -478,6 +478,22 @@ miCASAWriteBinaryKey SSCS_EXT_T * ext ); +SSCS_EXTERN_LIBCALL(int32_t) +miCASAReadKey +( + void * context, + uint32_t ssFlags, + SSCS_KEYCHAIN_ID_T * keyChainID, + SSCS_SECRET_ID_T * sharedSecretID, + SS_UTF8_T * key, + uint32_t keyLen, + uint8_t * val, + uint32_t * valLen, + SSCS_PASSWORD_T * epPassword, + uint32_t * bytesRequired, + SSCS_EXT_T * ext +); + SSCS_EXTERN_LIBCALL(int32_t) miCASAReadBinaryKey ( diff --git a/include/sscs_cache.h b/include/sscs_cache.h index 898025ce..d8c053ff 100644 --- a/include/sscs_cache.h +++ b/include/sscs_cache.h @@ -487,6 +487,21 @@ int sscs_CacheWriteBinaryKey void *reserved ); +int sscs_CacheReadKey +( + void *ssHandle, + uint32_t ssFlags, + SSCS_KEYCHAIN_ID_T *keychainID, + SSCS_SECRET_ID_T *secretID, + SS_UTF8_T *key, + uint32_t keyLen, + uint8_t *val, + uint32_t *valLen, + SSCS_PASSWORD_T *epPassword, + uint32_t *bytesRequired, + void *reserved +); + int sscs_CacheReadBinaryKey ( void *ssHandle,