1/* 2 * QEMU base64 helpers 3 * 4 * Copyright (c) 2015 Red Hat, Inc. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21#ifndef QEMU_BASE64_H 22#define QEMU_BASE64_H 23 24#include "qemu-common.h" 25 26 27/** 28 * qbase64_decode: 29 * @input: the (possibly) base64 encoded text 30 * @in_len: length of @input or -1 if NUL terminated 31 * @out_len: filled with length of decoded data 32 * @errp: pointer to a NULL-initialized error object 33 * 34 * Attempt to decode the (possibly) base64 encoded 35 * text provided in @input. If the @input text may 36 * contain embedded NUL characters, or may not be 37 * NUL terminated, then @in_len must be set to the 38 * known size of the @input buffer. 39 * 40 * Note that embedded NULs, or lack of a NUL terminator 41 * are considered invalid base64 data and errors 42 * will be reported to this effect. 43 * 44 * If decoding is successful, the decoded data will 45 * be returned and @out_len set to indicate the 46 * number of bytes in the decoded data. The caller 47 * must use g_free() to free the returned data when 48 * it is no longer required. 49 * 50 * Returns: the decoded data or NULL 51 */ 52uint8_t *qbase64_decode(const char *input, 53 size_t in_len, 54 size_t *out_len, 55 Error **errp); 56 57 58#endif /* QEMU_BASE64_H */ 59