VirtualBox

Changeset 11523 in vbox for trunk/include


Ignore:
Timestamp:
Aug 20, 2008 8:48:52 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
35074
Message:

iprt: Implemented the /dev/urandom base random generator as a RTRAND opaque. Made the simple RTRand API just serve as a wrapper using the RTRandAdv API with a global RTRAND handle.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/rand.h

    r11347 r11523  
    140140
    141141/**
     142 * Create an instance of the default non-pseudo random number generator.
     143 *
     144 * @returns IPRT status code.
     145 * @retval  VERR_NOT_SUPPORTED on platforms which doesn't have this feature
     146 *          (Windows & OS/2).
     147 * @param   phRand      Where to store the handle to the generator.
     148 *
     149 * @remarks Think /dev/urandom.
     150 */
     151RTDECL(int) RTRandAdvCreateNonPseudo(PRTRAND phRand) RT_NO_THROW;
     152
     153/**
     154 * Create an instance of the default pure non-pseudo random number generator.
     155 *
     156 * Don't use this unless you seriously need good random numbers because most
     157 * systems will have will have problems producing sufficient randomness for this
     158 * and you'll end up blocking.
     159 *
     160 * @returns IPRT status code.
     161 * @retval  VERR_NOT_SUPPORTED on platforms which doesn't have this feature
     162 *          (Windows & OS/2).
     163 * @param   phRand      Where to store the handle to the generator.
     164 *
     165 * @remarks Think /dev/random.
     166 */
     167RTDECL(int) RTRandAdvCreatePureNonPseudo(PRTRAND phRand) RT_NO_THROW;
     168
     169/**
    142170 * Destroys a random number generator.
    143171 *
     
    155183 *
    156184 * @returns IPRT status code.
     185 * @retval  VERR_NOT_SUPPORTED if it isn't a pseudo generator.
     186 *
    157187 * @param   hRand       Handle to the random number generator.
    158188 * @param   u64Seed     Seed.
    159189 */
    160190RTDECL(int) RTRandAdvSeed(RTRAND hRand, uint64_t u64Seed) RT_NO_THROW;
     191
     192/**
     193 * Save the current state of a pseudo generator.
     194 *
     195 * This can be use to save the state so it can later be resumed at the same
     196 * position.
     197 *
     198 * @returns IPRT status code.
     199 * @retval  VINF_SUCCESS on success. *pcbState contains the length of the
     200 *          returned string and pszState contains the state string.
     201 * @retval  VERR_BUFFER_OVERFLOW if the supplied buffer is too small. *pcbState
     202 *          will contain the necessary buffer size.
     203 * @retval  VERR_NOT_SUPPORTED by non-psuedo generators.
     204 *
     205 * @param   hRand       Handle to the random number generator.
     206 * @param   pszState    Where to store the state. The returned string will be
     207 *                      null terminated and printable.
     208 * @param   pcbState    The size of the buffer pszState points to on input, the
     209 *                      size required / used on return (including the
     210 *                      terminator, thus the 'cb' instead of 'cch').
     211 */
     212RTDECL(int) RTRandAdvSaveState(RTRAND hRand, char *pszState, size_t *pcbState) RT_NO_THROW;
     213
     214/**
     215 * Restores the state of a pseudo generator.
     216 *
     217 * The state must've been obtained using RTRandAdvGetState.
     218 *
     219 * @returns IPRT status code.
     220 * @retval  VERR_PARSE_ERROR if the state string is malformed.
     221 * @retval  VERR_NOT_SUPPORTED by non-psuedo generators.
     222 *
     223 * @param   hRand       Handle to the random number generator.
     224 * @param   pszState    The state to load.
     225 */
     226RTDECL(int) RTRandAdvRestoreState(RTRAND hRand, char const *pszState) RT_NO_THROW;
    161227
    162228/**
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette