/** * @file digest.c * * @author Damien S. Stuart * * @brief Roll-up of the digests used by fwknop. * * Copyright 2009-2013 Damien Stuart (dstuart@dstuart.org) * * License (GNU General Public License): * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ #include "fko_common.h" #include "digest.h" #include "base64.h" /* Convert a raw digest into its hex string representation. */ static void digest_to_hex(char *out, size_t size_out, const unsigned char *in, const size_t size_in) { size_t i; /* Assume the output buffer must be a NULL terminated string */ memset(out, 0, size_out); size_out -= 1; /* The hex string representation must be long enough */ if (size_out >= (size_in * 2)) { /* For each byte... */ for(i=0; i