1 1.2 gutterid /* $NetBSD: camellia-api.c,v 1.2 2021/09/04 00:33:09 gutteridge Exp $ */ 2 1.1 drochner 3 1.1 drochner /* 4 1.1 drochner * 5 1.1 drochner * Copyright (c) 2006 6 1.1 drochner * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved. 7 1.1 drochner * 8 1.1 drochner * Redistribution and use in source and binary forms, with or without 9 1.1 drochner * modification, are permitted provided that the following conditions 10 1.1 drochner * are met: 11 1.1 drochner * 1. Redistributions of source code must retain the above copyright 12 1.1 drochner * notice, this list of conditions and the following disclaimer as 13 1.1 drochner * the first lines of this file unmodified. 14 1.1 drochner * 2. Redistributions in binary form must reproduce the above copyright 15 1.1 drochner * notice, this list of conditions and the following disclaimer in the 16 1.1 drochner * documentation and/or other materials provided with the distribution. 17 1.1 drochner * 18 1.1 drochner * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR 19 1.1 drochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 1.1 drochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 1.1 drochner * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT, 22 1.1 drochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 1.1 drochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 1.1 drochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 1.1 drochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 1.1 drochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 1.1 drochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 1.1 drochner */ 29 1.1 drochner 30 1.1 drochner #include <sys/cdefs.h> 31 1.2 gutterid __KERNEL_RCSID(0, "$NetBSD: camellia-api.c,v 1.2 2021/09/04 00:33:09 gutteridge Exp $"); 32 1.1 drochner 33 1.1 drochner #include <sys/types.h> 34 1.1 drochner #include <crypto/camellia/camellia.h> 35 1.1 drochner 36 1.1 drochner void 37 1.1 drochner camellia_set_key(camellia_ctx *ctx, const u_char *key, int bits) 38 1.1 drochner { 39 1.1 drochner 40 1.1 drochner Camellia_Ekeygen(bits, key, ctx->subkey); 41 1.1 drochner ctx->bits = bits; 42 1.1 drochner } 43 1.1 drochner 44 1.1 drochner void 45 1.1 drochner camellia_decrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst) 46 1.1 drochner { 47 1.1 drochner 48 1.1 drochner Camellia_DecryptBlock(ctx->bits, src, ctx->subkey, dst); 49 1.1 drochner } 50 1.1 drochner 51 1.1 drochner void 52 1.1 drochner camellia_encrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst) 53 1.1 drochner { 54 1.1 drochner 55 1.1 drochner Camellia_EncryptBlock(ctx->bits, src, ctx->subkey, dst); 56 1.1 drochner } 57