| 1 | /* |
| 2 | * Copyright (C) 1999 Ross Combs ([email protected]) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | #include "common/setup_before.h" |
| 19 | #include "common/bnethashconv.h" |
| 20 | |
| 21 | #include "common/bnethash.h" |
| 22 | #include "common/bn_type.h" |
| 23 | #include "common/eventlog.h" |
| 24 | #include "common/setup_after.h" |
| 25 | |
| 26 | namespace pvpgn |
| 27 | { |
| 28 | |
| 29 | extern void bnhash_to_hash(bn_int const * bnhash, t_hash * hash) |
| 30 | { |
| 31 | unsigned int i; |
| 32 | |
| 33 | if (!bnhash) |
| 34 | { |
| 35 | eventlog(eventlog_level_error, __FUNCTION__, "got NULL bnhash"); |
| 36 | return; |
| 37 | } |
| 38 | if (!hash) |
| 39 | { |
| 40 | eventlog(eventlog_level_error, __FUNCTION__, "got NULL hash"); |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | for (i = 0; i < 5; i++) |
| 45 | (*hash)[i] = bn_int_get(bnhash[i]); |
| 46 | } |
| 47 | |
| 48 | |
| 49 | extern void hash_to_bnhash(t_hash const * hash, bn_int * bnhash) |
| 50 | { |
| 51 | unsigned int i; |
| 52 | |
| 53 | if (!bnhash) |
| 54 | { |
| 55 | eventlog(eventlog_level_error, __FUNCTION__, "got NULL bnhash"); |
| 56 | return; |
| 57 | } |
| 58 | if (!hash) |
| 59 | { |
| 60 | eventlog(eventlog_level_error, __FUNCTION__, "got NULL hash"); |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | for (i = 0; i < 5; i++) |
| 65 | bn_int_set(&bnhash[i], (*hash)[i]); |
| 66 | } |
| 67 | |
| 68 | } |