|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
310c69 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
310c69 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
310c69 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
310c69 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
310c69 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
310c69 |
* GNU General Public License for more details.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
310c69 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
310c69 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
310c69 |
* 02110-1301, USA.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* $Id: //eng/uds-releases/jasper/src/uds/nonce.h#1 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef NONCE_H
|
|
Packit Service |
310c69 |
#define NONCE_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "typeDefs.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Create unique data for the master nonce, using system-specific
|
|
Packit Service |
310c69 |
* methods such as the current time and a random number.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer A buffer of length specified next.
|
|
Packit Service |
310c69 |
* @param length Length of the buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return the amount of the buffer that has been filled with unique data
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
size_t createUniqueNonceData(byte *buffer, size_t length);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Generate a master nonce, using the specified data.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param data Some arbitrary information.
|
|
Packit Service |
310c69 |
* @param len The length of the information.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return a number which will be fairly unique
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
uint64_t generateMasterNonce(const void *data, size_t len);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Deterministically generate a secondary nonce based on an existing
|
|
Packit Service |
310c69 |
* nonce and some arbitrary data. Effectively hashes the nonce and
|
|
Packit Service |
310c69 |
* the data to produce a new nonce which is deterministic.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param nonce An existing nonce which is well known.
|
|
Packit Service |
310c69 |
* @param data Some data related to the creation of this nonce.
|
|
Packit Service |
310c69 |
* @param len The length of the data.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return a number which will be fairly unique and depend solely on
|
|
Packit Service |
310c69 |
* the nonce and the data.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
uint64_t generateSecondaryNonce(uint64_t nonce,
|
|
Packit Service |
310c69 |
const void *data,
|
|
Packit Service |
310c69 |
size_t len);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif // NONCE_H
|