xref: /aoo42x/main/sal/inc/rtl/random.h (revision 514f4c20)
1*514f4c20SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*514f4c20SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*514f4c20SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*514f4c20SAndrew Rist  * distributed with this work for additional information
6*514f4c20SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*514f4c20SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*514f4c20SAndrew Rist  * "License"); you may not use this file except in compliance
9*514f4c20SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*514f4c20SAndrew Rist  *
11*514f4c20SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*514f4c20SAndrew Rist  *
13*514f4c20SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*514f4c20SAndrew Rist  * software distributed under the License is distributed on an
15*514f4c20SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*514f4c20SAndrew Rist  * KIND, either express or implied.  See the License for the
17*514f4c20SAndrew Rist  * specific language governing permissions and limitations
18*514f4c20SAndrew Rist  * under the License.
19*514f4c20SAndrew Rist  *
20*514f4c20SAndrew Rist  *************************************************************/
21*514f4c20SAndrew Rist 
22*514f4c20SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _RTL_RANDOM_H_
25cdf0e10cSrcweir #define _RTL_RANDOM_H_ "$Revision: 1.7 $"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/types.h>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #ifdef __cplusplus
30cdf0e10cSrcweir extern "C" {
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /*========================================================================
34cdf0e10cSrcweir  *
35cdf0e10cSrcweir  * rtlRandom interface.
36cdf0e10cSrcweir  *
37cdf0e10cSrcweir  *======================================================================*/
38cdf0e10cSrcweir /** Random Pool opaque type.
39cdf0e10cSrcweir  */
40cdf0e10cSrcweir typedef void* rtlRandomPool;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir /** Error Code enumeration.
44cdf0e10cSrcweir  */
45cdf0e10cSrcweir enum __rtl_RandomError
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 	rtl_Random_E_None,
48cdf0e10cSrcweir 	rtl_Random_E_Argument,
49cdf0e10cSrcweir 	rtl_Random_E_Memory,
50cdf0e10cSrcweir 	rtl_Random_E_Unknown,
51cdf0e10cSrcweir 	rtl_Random_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
52cdf0e10cSrcweir };
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /** Error Code type.
55cdf0e10cSrcweir  */
56cdf0e10cSrcweir typedef enum __rtl_RandomError rtlRandomError;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
59cdf0e10cSrcweir /** Create a Random Pool.
60cdf0e10cSrcweir 	@return initialized Random Pool, or NULL upon failure.
61cdf0e10cSrcweir  */
62cdf0e10cSrcweir rtlRandomPool SAL_CALL rtl_random_createPool (void) SAL_THROW_EXTERN_C();
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 
65cdf0e10cSrcweir /** Destroy a Random Pool.
66cdf0e10cSrcweir 	@param  Pool [in] a Random Pool.
67cdf0e10cSrcweir 	@return none. Pool is invalid.
68cdf0e10cSrcweir  */
69cdf0e10cSrcweir void SAL_CALL rtl_random_destroyPool (
70cdf0e10cSrcweir 	rtlRandomPool Pool
71cdf0e10cSrcweir ) SAL_THROW_EXTERN_C();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
74cdf0e10cSrcweir /** Add bytes to a Random Pool.
75cdf0e10cSrcweir 	@param Pool    [in] a Random Pool.
76cdf0e10cSrcweir 	@param pBuffer [in] a buffer containing the bytes to add.
77cdf0e10cSrcweir 	@param nBufLen [in] the number of bytes to read from the buffer.
78cdf0e10cSrcweir 	@return rtl_Random_E_None upon success.
79cdf0e10cSrcweir  */
80cdf0e10cSrcweir rtlRandomError SAL_CALL rtl_random_addBytes (
81cdf0e10cSrcweir 	rtlRandomPool  Pool,
82cdf0e10cSrcweir 	const void    *Buffer,
83cdf0e10cSrcweir 	sal_Size       Bytes
84cdf0e10cSrcweir ) SAL_THROW_EXTERN_C();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 
87cdf0e10cSrcweir /** Retrieve bytes from a Random Pool.
88cdf0e10cSrcweir 	@param Pool    [in] a Random Pool.
89cdf0e10cSrcweir 	@param pBuffer [inout] a buffer to receive the random bytes.
90cdf0e10cSrcweir 	@param nBufLen [in] the number of bytes to write to the buffer.
91cdf0e10cSrcweir 	@return rtl_Random_E_None upon success.
92cdf0e10cSrcweir  */
93cdf0e10cSrcweir rtlRandomError SAL_CALL rtl_random_getBytes (
94cdf0e10cSrcweir 	rtlRandomPool  Pool,
95cdf0e10cSrcweir 	void          *Buffer,
96cdf0e10cSrcweir 	sal_Size       Bytes
97cdf0e10cSrcweir ) SAL_THROW_EXTERN_C();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir /*========================================================================
100cdf0e10cSrcweir  *
101cdf0e10cSrcweir  * The End.
102cdf0e10cSrcweir  *
103cdf0e10cSrcweir  *======================================================================*/
104cdf0e10cSrcweir 
105cdf0e10cSrcweir #ifdef __cplusplus
106cdf0e10cSrcweir }
107cdf0e10cSrcweir #endif
108cdf0e10cSrcweir 
109cdf0e10cSrcweir #endif /* _RTL_RANDOM_H_ */
110cdf0e10cSrcweir 
111