includes/diffiehellman.php
changeset 507 586fd7d3202d
parent 467 e4bbd6fb8df3
child 536 218a627eb53e
equal deleted inserted replaced
506:da0f2a76add5 507:586fd7d3202d
     1 <?php
     1 <?php
     2 
     2 
     3 /*
     3 /*
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     5  * Version 1.1.2 (Caoineag alpha 2)
     5  * Version 1.1.3 (Caoineag alpha 3)
     6  * Copyright (C) 2006-2007 Dan Fuhry
     6  * Copyright (C) 2006-2007 Dan Fuhry
     7  * diffiehellman.php - Diffie Hellman key exchange and supporting functions
     7  * diffiehellman.php - Diffie Hellman key exchange and supporting functions
     8  *
     8  *
     9  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
     9  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    10  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    10  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    15 
    15 
    16 /**
    16 /**
    17  * The Diffie-Hellman key exchange protocol
    17  * The Diffie-Hellman key exchange protocol
    18  */
    18  */
    19 
    19 
    20 $GLOBALS['_math'] = enanomath_create();
    20 global $dh_supported;
       
    21 $dh_supported = true;
       
    22 try
       
    23 {
       
    24   $GLOBALS['_math'] = enanomath_create();
       
    25 }
       
    26 catch ( Exception $e )
       
    27 {
       
    28   $dh_supported = false;
       
    29 }
    21 // Our prime number as a base for operations.
    30 // Our prime number as a base for operations.
    22 $GLOBALS['dh_prime'] = '82818079787776757473727170696867666564636261605958575655545352515049484746454443424140393837363534333231302928272625242322212019181716151413121110987654321';
    31 $GLOBALS['dh_prime'] = '82818079787776757473727170696867666564636261605958575655545352515049484746454443424140393837363534333231302928272625242322212019181716151413121110987654321';
    23 
    32 
    24 // g, a primitive root used as an exponent
    33 // g, a primitive root used as an exponent
    25 // (2 and 5 are acceptable, but BigInt is faster with odd numbers)
    34 // (2 and 5 are acceptable, but BigInt is faster with odd numbers)