iPXE
crypto_null.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  *
00019  * You can also choose to distribute this program under the terms of
00020  * the Unmodified Binary Distribution Licence (as given in the file
00021  * COPYING.UBDL), provided that you have satisfied its requirements.
00022  */
00023 
00024 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00025 
00026 /**
00027  * @file
00028  *
00029  * Null crypto algorithm
00030  */
00031 
00032 #include <string.h>
00033 #include <ipxe/crypto.h>
00034 
00035 static void digest_null_init ( void *ctx __unused ) {
00036         /* Do nothing */
00037 }
00038 
00039 static void digest_null_update ( void *ctx __unused, const void *src __unused,
00040                                  size_t len __unused ) {
00041         /* Do nothing */
00042 }
00043 
00044 static void digest_null_final ( void *ctx __unused, void *out __unused ) {
00045         /* Do nothing */
00046 }
00047 
00048 struct digest_algorithm digest_null = {
00049         .name = "null",
00050         .ctxsize = 0,
00051         .blocksize = 1,
00052         .digestsize = 0,
00053         .init = digest_null_init,
00054         .update = digest_null_update,
00055         .final = digest_null_final,
00056 };
00057 
00058 static int cipher_null_setkey ( void *ctx __unused, const void *key __unused,
00059                                 size_t keylen __unused ) {
00060         /* Do nothing */
00061         return 0;
00062 }
00063 
00064 static void cipher_null_setiv ( void *ctx __unused,
00065                                 const void *iv __unused ) {
00066         /* Do nothing */
00067 }
00068 
00069 static void cipher_null_encrypt ( void *ctx __unused, const void *src,
00070                                   void *dst, size_t len ) {
00071         memcpy ( dst, src, len );
00072 }
00073 
00074 static void cipher_null_decrypt ( void *ctx __unused, const void *src,
00075                                   void *dst, size_t len ) {
00076         memcpy ( dst, src, len );
00077 }
00078 
00079 struct cipher_algorithm cipher_null = {
00080         .name = "null",
00081         .ctxsize = 0,
00082         .blocksize = 1,
00083         .setkey = cipher_null_setkey,
00084         .setiv = cipher_null_setiv,
00085         .encrypt = cipher_null_encrypt,
00086         .decrypt = cipher_null_decrypt,
00087 };
00088 
00089 static int pubkey_null_init ( void *ctx __unused, const void *key __unused,
00090                               size_t key_len __unused ) {
00091         return 0;
00092 }
00093 
00094 static size_t pubkey_null_max_len ( void *ctx __unused ) {
00095         return 0;
00096 }
00097 
00098 static int pubkey_null_encrypt ( void *ctx __unused,
00099                                  const void *plaintext __unused,
00100                                  size_t plaintext_len __unused,
00101                                  void *ciphertext __unused ) {
00102         return 0;
00103 }
00104 
00105 static int pubkey_null_decrypt ( void *ctx __unused,
00106                                  const void *ciphertext __unused,
00107                                  size_t ciphertext_len __unused,
00108                                  void *plaintext __unused ) {
00109         return 0;
00110 }
00111 
00112 static int pubkey_null_sign ( void *ctx __unused,
00113                               struct digest_algorithm *digest __unused,
00114                               const void *value __unused,
00115                               void *signature __unused ) {
00116         return 0;
00117 }
00118 
00119 static int pubkey_null_verify ( void *ctx __unused,
00120                                 struct digest_algorithm *digest __unused,
00121                                 const void *value __unused,
00122                                 const void *signature __unused ,
00123                                 size_t signature_len __unused ) {
00124         return 0;
00125 }
00126 
00127 static void pubkey_null_final ( void *ctx __unused ) {
00128         /* Do nothing */
00129 }
00130 
00131 struct pubkey_algorithm pubkey_null = {
00132         .name = "null",
00133         .ctxsize = 0,
00134         .init = pubkey_null_init,
00135         .max_len = pubkey_null_max_len,
00136         .encrypt = pubkey_null_encrypt,
00137         .decrypt = pubkey_null_decrypt,
00138         .sign = pubkey_null_sign,
00139         .verify = pubkey_null_verify,
00140         .final = pubkey_null_final,
00141 };