b128605d4af12856ad4cd26312806f3bf325a385vboxsync/* $Id$ */
b128605d4af12856ad4cd26312806f3bf325a385vboxsync/** @file
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * IPRT - SHA-512 string functions.
b128605d4af12856ad4cd26312806f3bf325a385vboxsync */
b128605d4af12856ad4cd26312806f3bf325a385vboxsync
b128605d4af12856ad4cd26312806f3bf325a385vboxsync/*
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2009-2010 Oracle Corporation
b128605d4af12856ad4cd26312806f3bf325a385vboxsync *
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * available from http://www.virtualbox.org. This file is free software;
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * General Public License (GPL) as published by the Free Software
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b128605d4af12856ad4cd26312806f3bf325a385vboxsync *
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * The contents of this file may alternatively be used under the terms
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * of the Common Development and Distribution License Version 1.0
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * VirtualBox OSE distribution, in which case the provisions of the
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * CDDL are applicable instead of those of the GPL.
b128605d4af12856ad4cd26312806f3bf325a385vboxsync *
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * You may elect to license modified versions of this file under the
b128605d4af12856ad4cd26312806f3bf325a385vboxsync * terms and conditions of either the GPL or the CDDL or both.
b128605d4af12856ad4cd26312806f3bf325a385vboxsync */
b128605d4af12856ad4cd26312806f3bf325a385vboxsync
b128605d4af12856ad4cd26312806f3bf325a385vboxsync
b128605d4af12856ad4cd26312806f3bf325a385vboxsync/*******************************************************************************
b128605d4af12856ad4cd26312806f3bf325a385vboxsync* Header Files *
b128605d4af12856ad4cd26312806f3bf325a385vboxsync*******************************************************************************/
b128605d4af12856ad4cd26312806f3bf325a385vboxsync#include "internal/iprt.h"
b128605d4af12856ad4cd26312806f3bf325a385vboxsync#include <iprt/sha.h>
b128605d4af12856ad4cd26312806f3bf325a385vboxsync
b128605d4af12856ad4cd26312806f3bf325a385vboxsync#include <iprt/assert.h>
b128605d4af12856ad4cd26312806f3bf325a385vboxsync#include <iprt/err.h>
b128605d4af12856ad4cd26312806f3bf325a385vboxsync#include <iprt/string.h>
b128605d4af12856ad4cd26312806f3bf325a385vboxsync
b128605d4af12856ad4cd26312806f3bf325a385vboxsync
b128605d4af12856ad4cd26312806f3bf325a385vboxsyncRTDECL(int) RTSha512ToString(uint8_t const pabDigest[RTSHA512_HASH_SIZE], char *pszDigest, size_t cchDigest)
b128605d4af12856ad4cd26312806f3bf325a385vboxsync{
b128605d4af12856ad4cd26312806f3bf325a385vboxsync return RTStrPrintHexBytes(pszDigest, cchDigest, &pabDigest[0], RTSHA512_HASH_SIZE, 0 /*fFlags*/);
b128605d4af12856ad4cd26312806f3bf325a385vboxsync}
b128605d4af12856ad4cd26312806f3bf325a385vboxsync
b128605d4af12856ad4cd26312806f3bf325a385vboxsync
b128605d4af12856ad4cd26312806f3bf325a385vboxsyncRTDECL(int) RTSha512FromString(char const *pszDigest, uint8_t pabDigest[RTSHA512_HASH_SIZE])
b128605d4af12856ad4cd26312806f3bf325a385vboxsync{
b128605d4af12856ad4cd26312806f3bf325a385vboxsync return RTStrConvertHexBytes(RTStrStripL(pszDigest), &pabDigest[0], RTSHA512_HASH_SIZE, 0 /*fFlags*/);
b128605d4af12856ad4cd26312806f3bf325a385vboxsync}
b128605d4af12856ad4cd26312806f3bf325a385vboxsync