/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 19994* University of California. All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. Neither the name of the author nor the names of any co-contributors15* may be used to endorse or promote products derived from this software16* without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS19* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE24* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS25* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER26* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR27* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN28* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29*/3031#include <sys/types.h>3233#include "crypt.h"3435static char itoa64[] = /* 0 ... 63 => ascii - 64 */36"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";3738void39_crypt_to64(char *s, u_long v, int n)40{41while (--n >= 0) {42*s++ = itoa64[v&0x3f];43v >>= 6;44}45}4647void48b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, char **cp)49{50uint32_t w;51int i;5253w = (B2 << 16) | (B1 << 8) | B0;54for (i = 0; i < n; i++) {55**cp = itoa64[w&0x3f];56(*cp)++;57w >>= 6;58}59}606162