Path: blob/main/sys/crypto/camellia/camellia-api.c
39478 views
/*1*2* Copyright (c) 20063* NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer as10* the first lines of this file unmodified.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*15* THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR16* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES17* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.18* IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,19* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT20* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,21* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY22* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF24* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25*/2627#include <sys/cdefs.h>2829#include <sys/types.h>30#ifdef _KERNEL31#include <sys/systm.h>32#endif33#include <crypto/camellia/camellia.h>3435void36camellia_set_key(camellia_ctx *ctx, const u_char *key, int bits)37{3839Camellia_Ekeygen(bits, key, ctx->subkey);40ctx->bits = bits;41}4243void44camellia_decrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst)45{4647Camellia_DecryptBlock(ctx->bits, src, ctx->subkey, dst);48}4950void51camellia_encrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst)52{5354Camellia_EncryptBlock(ctx->bits, src, ctx->subkey, dst);55}565758