c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta Jan Cholasta <jcholast@redhat.com>
e07a94a66985b674c5df11ca466792902164c4e2George McCollister George McCollister <george.mccollister@gmail.com>
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta Copyright (C) 2012 Red Hat
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta This program is free software; you can redistribute it and/or modify
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta it under the terms of the GNU General Public License as published by
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta the Free Software Foundation; either version 3 of the License, or
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta (at your option) any later version.
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta This program is distributed in the hope that it will be useful,
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta but WITHOUT ANY WARRANTY; without even the implied warranty of
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta GNU General Public License for more details.
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta You should have received a copy of the GNU General Public License
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta along with this program. If not, see <http://www.gnu.org/licenses/>.
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta const unsigned char *in,
e07a94a66985b674c5df11ca466792902164c4e2George McCollister BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
e07a94a66985b674c5df11ca466792902164c4e2George McCollister b64size = BIO_get_mem_data(bmem, &b64encoded);
e07a94a66985b674c5df11ca466792902164c4e2George McCollister outbuf = talloc_array(mem_ctx, char, b64size+1);
e07a94a66985b674c5df11ca466792902164c4e2George McCollister for (i=0, j=0; i < b64size; i++) {
e07a94a66985b674c5df11ca466792902164c4e2George McCollister if (b64encoded[i] == '\n' || b64encoded[i] == '\r') {
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholastaunsigned char *sss_base64_decode(TALLOC_CTX *mem_ctx,
c7919a4fe41133cc466aa3d9431bfceee5784e7bJan Cholasta const char *in,
e07a94a66985b674c5df11ca466792902164c4e2George McCollister BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
e07a94a66985b674c5df11ca466792902164c4e2George McCollister while((inlen = BIO_read(b64, inbuf, 512)) > 0)
e07a94a66985b674c5df11ca466792902164c4e2George McCollister size = BIO_get_mem_data(bmem_out, &b64decoded);
e07a94a66985b674c5df11ca466792902164c4e2George McCollister outbuf = talloc_memdup(mem_ctx, b64decoded, size);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "Cannot get decoded data\n");