1*7735a0bbSgutteridge /* $NetBSD: camellia-api.c,v 1.2 2021/09/04 00:33:09 gutteridge Exp $ */
29d083d2fSdrochner
39d083d2fSdrochner /*
49d083d2fSdrochner *
59d083d2fSdrochner * Copyright (c) 2006
69d083d2fSdrochner * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
79d083d2fSdrochner *
89d083d2fSdrochner * Redistribution and use in source and binary forms, with or without
99d083d2fSdrochner * modification, are permitted provided that the following conditions
109d083d2fSdrochner * are met:
119d083d2fSdrochner * 1. Redistributions of source code must retain the above copyright
129d083d2fSdrochner * notice, this list of conditions and the following disclaimer as
139d083d2fSdrochner * the first lines of this file unmodified.
149d083d2fSdrochner * 2. Redistributions in binary form must reproduce the above copyright
159d083d2fSdrochner * notice, this list of conditions and the following disclaimer in the
169d083d2fSdrochner * documentation and/or other materials provided with the distribution.
179d083d2fSdrochner *
189d083d2fSdrochner * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
199d083d2fSdrochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
209d083d2fSdrochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
219d083d2fSdrochner * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
229d083d2fSdrochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
239d083d2fSdrochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
249d083d2fSdrochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
259d083d2fSdrochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
269d083d2fSdrochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
279d083d2fSdrochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
289d083d2fSdrochner */
299d083d2fSdrochner
309d083d2fSdrochner #include <sys/cdefs.h>
31*7735a0bbSgutteridge __KERNEL_RCSID(0, "$NetBSD: camellia-api.c,v 1.2 2021/09/04 00:33:09 gutteridge Exp $");
329d083d2fSdrochner
339d083d2fSdrochner #include <sys/types.h>
349d083d2fSdrochner #include <crypto/camellia/camellia.h>
359d083d2fSdrochner
369d083d2fSdrochner void
camellia_set_key(camellia_ctx * ctx,const u_char * key,int bits)379d083d2fSdrochner camellia_set_key(camellia_ctx *ctx, const u_char *key, int bits)
389d083d2fSdrochner {
399d083d2fSdrochner
409d083d2fSdrochner Camellia_Ekeygen(bits, key, ctx->subkey);
419d083d2fSdrochner ctx->bits = bits;
429d083d2fSdrochner }
439d083d2fSdrochner
449d083d2fSdrochner void
camellia_decrypt(const camellia_ctx * ctx,const u_char * src,u_char * dst)459d083d2fSdrochner camellia_decrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst)
469d083d2fSdrochner {
479d083d2fSdrochner
489d083d2fSdrochner Camellia_DecryptBlock(ctx->bits, src, ctx->subkey, dst);
499d083d2fSdrochner }
509d083d2fSdrochner
519d083d2fSdrochner void
camellia_encrypt(const camellia_ctx * ctx,const u_char * src,u_char * dst)529d083d2fSdrochner camellia_encrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst)
539d083d2fSdrochner {
549d083d2fSdrochner
559d083d2fSdrochner Camellia_EncryptBlock(ctx->bits, src, ctx->subkey, dst);
569d083d2fSdrochner }
57