2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
15 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
17 // Licensed under the Apache License, Version 2.0 (the License);
18 // you may not use this file except in compliance with the License.
19 // You may obtain a copy of the License at
21 // http://www.apache.org/licenses/LICENSE-2.0
23 // Unless required by applicable law or agreed to in writing, software
24 // distributed under the License is distributed on an "AS IS" BASIS,
25 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 // See the License for the specific language governing permissions and
27 // limitations under the License.
32 * @brief This header file contains declarations of Pseudo Random Function based on ANSI X9.31 Appendix A.2.4.
36 * Generate random numbers as per X9.31 specification using algorithm passed as input.
42 #include "secure_storage.h"
47 #define SS_PRNG_SUCCESS 0
48 #define SS_PRNG_ERROR_INVALID_ARG -1
49 #define SS_PRNG_ERROR_OUT_OF_MEMORY -2
50 #define SS_PRNG_ERROR_SYSTEM -3
53 #define TryCatch(condition, expr, ...) \
62 * Generate random numbers as per X9.31 specification using algorithm passed as input.
64 * @return Returns pointer to byte buffer containing generated random number.
65 * @param[in] pAlg Pointer to algorithm used for random number generation. Supports EVP_des_ecb(), EVP_des_ede3_ecb() and EVP_AES_128_ecb().
66 * @param[in] requiredLength Integer type indicating required size of random number.
68 unsigned char* GetRandomBytesN(struct evp_cipher_st* pAlg, long requiredLength);