crypto.h

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2007,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  *  Boston, MA  02110-1301, USA.
00020  * 
00021  *                     *       *       *
00022  * 
00023  *  Pseudorandom number generation support in this file is derived from
00024  *  Tor's crypto.[ch]. Tor is distributed under this license.
00025  * 
00026  *    Copyright (c) 2001-2004, Roger Dingledine
00027  *    Copyright (c) 2004-2007, Roger Dingledine, Nick Mathewson
00028  *
00029  *   Redistribution and use in source and binary forms, with or without
00030  *   modification, are permitted provided that the following conditions are
00031  *   met:
00032  *
00033  *     * Redistributions of source code must retain the above copyright
00034  *       notice, this list of conditions and the following disclaimer.
00035  *
00036  *     * Redistributions in binary form must reproduce the above
00037  *       copyright notice, this list of conditions and the following disclaimer
00038  *       in the documentation and/or other materials provided with the
00039  *       distribution.
00040  * 
00041  *     * Neither the names of the copyright owners nor the names of its
00042  *       contributors may be used to endorse or promote products derived from
00043  *       this software without specific prior written permission.
00044  *
00045  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00046  *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00047  *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00048  *    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00049  *    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00050  *    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00051  *    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00052  *    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00053  *    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00054  *    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00055  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00056  ****************************************************************/
00057 
00058 /**
00059  * \file crypto.h
00060  * \version $Id: crypto.h 1841 2007-08-21 04:33:32Z edmanm $
00061  * \brief Provides support for pseuodrandom number generation.
00062  */
00063 
00064 #ifndef _CRYPTO_H
00065 #define _CRYPTO_H
00066 
00067 #include <QByteArray>
00068 #include <QString>
00069 
00070 /** Returns <b>len</b> bytes of pseudorandom data on success, or an empty
00071  * QByteArray on failure. This function is based on crypto_seed_rng() from
00072  * Tor's crypto.c. See LICENSE for details on Tor's license. */
00073 QByteArray crypto_rand_bytes(int len);
00074 /** Returns a pseudorandom integer, chosen uniformly from the the values in
00075  * the range [0, max). This function is based on crypto_rand_int() from Tor's
00076  * crypto.c. See LICENSE for details on Tor's license. */
00077 quint32 crypto_rand_quint32(quint32 max);
00078 /** Generates a pseudorandom string of length <b>len</b> containing printable
00079  * ASCII characters of length from the range '!' (0x21) to '~' (0x7e). */
00080 QString crypto_rand_string(int len);
00081 
00082 #endif
00083 

Generated on Wed Sep 5 15:49:27 2007 for Vidalia by  doxygen 1.5.3