|
Packit |
aea12f |
/*
|
|
Packit |
aea12f |
* Copyright (C) 2000-2012 Free Software Foundation, Inc.
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* Author: Nikos Mavrogiannopoulos
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* This file is part of GnuTLS.
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* The GnuTLS is free software; you can redistribute it and/or
|
|
Packit |
aea12f |
* modify it under the terms of the GNU Lesser General Public License
|
|
Packit |
aea12f |
* as published by the Free Software Foundation; either version 2.1 of
|
|
Packit |
aea12f |
* the License, or (at your option) any later version.
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* This library is distributed in the hope that it will be useful, but
|
|
Packit |
aea12f |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
aea12f |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
aea12f |
* Lesser General Public License for more details.
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
aea12f |
* along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
*/
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
/* This file contains the functions needed for 64 bit integer support in
|
|
Packit |
aea12f |
* TLS, and functions which ease the access to TLS vectors (data of given size).
|
|
Packit |
aea12f |
*/
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
#include "gnutls_int.h"
|
|
Packit |
aea12f |
#include <num.h>
|
|
Packit |
aea12f |
#include "errors.h"
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
/* This function will add one to uint64 x.
|
|
Packit |
aea12f |
* Returns 0 on success, or -1 if the uint64 max limit
|
|
Packit |
aea12f |
* has been reached.
|
|
Packit |
aea12f |
*/
|
|
Packit |
aea12f |
int _gnutls_uint64pp(gnutls_uint64 * x)
|
|
Packit |
aea12f |
{
|
|
Packit |
aea12f |
register int i, y = 0;
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
for (i = 7; i >= 0; i--) {
|
|
Packit |
aea12f |
y = 0;
|
|
Packit |
aea12f |
if (x->i[i] == 0xff) {
|
|
Packit |
aea12f |
x->i[i] = 0;
|
|
Packit |
aea12f |
y = 1;
|
|
Packit |
aea12f |
} else
|
|
Packit |
aea12f |
x->i[i]++;
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
if (y == 0)
|
|
Packit |
aea12f |
break;
|
|
Packit |
aea12f |
}
|
|
Packit |
aea12f |
if (y != 0)
|
|
Packit |
aea12f |
return -1; /* over 64 bits! WOW */
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
return 0;
|
|
Packit |
aea12f |
}
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
/* This function will add one to uint48 x.
|
|
Packit |
aea12f |
* Returns 0 on success, or -1 if the uint48 max limit
|
|
Packit |
aea12f |
* has been reached.
|
|
Packit |
aea12f |
*/
|
|
Packit |
aea12f |
int _gnutls_uint48pp(gnutls_uint64 * x)
|
|
Packit |
aea12f |
{
|
|
Packit |
aea12f |
register int i, y = 0;
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
for (i = 7; i >= 3; i--) {
|
|
Packit |
aea12f |
y = 0;
|
|
Packit |
aea12f |
if (x->i[i] == 0xff) {
|
|
Packit |
aea12f |
x->i[i] = 0;
|
|
Packit |
aea12f |
y = 1;
|
|
Packit |
aea12f |
} else
|
|
Packit |
aea12f |
x->i[i]++;
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
if (y == 0)
|
|
Packit |
aea12f |
break;
|
|
Packit |
aea12f |
}
|
|
Packit |
aea12f |
if (y != 0)
|
|
Packit |
aea12f |
return -1; /* over 48 bits */
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
return 0;
|
|
Packit |
aea12f |
}
|