VirtualBox

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/src/VBox/Runtime/include/internal/rand.h

    r11347 r11523  
    8585     *
    8686     * @returns IPRT status code.
     87     * @retval  VERR_NOT_SUPPORTED if it isn't a pseudo generator.
     88     *
    8789     * @param   pThis       Pointer to the instance data.
    8890     * @param   u64Seed     The seed.
    8991     */
    9092    DECLCALLBACKMEMBER(int, pfnSeed)(PRTRANDINT pThis, uint64_t u64Seed);
     93
     94    /**
     95     * Save the current state of a pseudo generator.
     96     *
     97     * This can be use to save the state so it can later be resumed at the same
     98     * position.
     99     *
     100     * @returns IPRT status code.
     101     * @retval  VINF_SUCCESS on success. *pcbState contains the length of the
     102     *          returned string and pszState contains the state string.
     103     * @retval  VERR_BUFFER_OVERFLOW if the supplied buffer is too small. *pcbState
     104     *          will contain the necessary buffer size.
     105     * @retval  VERR_NOT_SUPPORTED by non-psuedo generators.
     106     *
     107     * @param   hRand       Handle to the random number generator.
     108     * @param   pszState    Where to store the state. The returned string will be
     109     *                      null terminated and printable.
     110     * @param   pcbState    The size of the buffer pszState points to on input, the
     111     *                      size required / used on return (including the
     112     *                      terminator, thus the 'cb' instead of 'cch').
     113     */
     114    DECLCALLBACKMEMBER(int, pfnSaveState)(RTRAND hRand, char *pszState, size_t *pcbState);
     115
     116    /**
     117     * Restores the state of a pseudo generator.
     118     *
     119     * The state must've been obtained using pfnGetState.
     120     *
     121     * @returns IPRT status code.
     122     * @retval  VERR_PARSE_ERROR if the state string is malformed.
     123     * @retval  VERR_NOT_SUPPORTED by non-psuedo generators.
     124     *
     125     * @param   hRand       Handle to the random number generator.
     126     * @param   pszState    The state to load.
     127     */
     128    DECLCALLBACKMEMBER(int, pfnRestoreState)(RTRAND hRand, char const *pszState);
    91129
    92130    /**
     
    113151            uint32_t    cBits;
    114152        } ParkMiller;
     153
     154        struct RTRandFile
     155        {
     156            /** The file handle. */
     157            RTFILE      hFile;
     158        } File;
    115159    } u;
    116160} RTRANDINT;
     
    141185DECLCALLBACK(uint64_t)  rtRandAdvSynthesizeU64FromBytes(PRTRANDINT pThis, uint64_t u64First, uint64_t u64Last);
    142186DECLCALLBACK(uint64_t)  rtRandAdvSynthesizeU64FromU32(PRTRANDINT pThis, uint64_t u64First, uint64_t u64Last);
     187DECLCALLBACK(int)       rtRandAdvStubSeed(PRTRANDINT pThis, uint64_t u64Seed);
     188DECLCALLBACK(int)       rtRandAdvStubSaveState(PRTRANDINT pThis, char *pszState, size_t *pcbState);
     189DECLCALLBACK(int)       rtRandAdvStubRestoreState(PRTRANDINT pThis, char const *pszState);
     190DECLCALLBACK(int)       rtRandAdvDefaultDestroy(PRTRANDINT pThis);
    143191
    144192__END_DECLS
Note: See TracChangeset for help on using the changeset viewer.

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