Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / crypto / crypto_null.c
1 /*
2  * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19
20 FILE_LICENCE ( GPL2_OR_LATER );
21
22 /**
23  * @file
24  *
25  * Null crypto algorithm
26  */
27
28 #include <string.h>
29 #include <ipxe/crypto.h>
30
31 static void digest_null_init ( void *ctx __unused ) {
32         /* Do nothing */
33 }
34
35 static void digest_null_update ( void *ctx __unused, const void *src __unused,
36                                  size_t len __unused ) {
37         /* Do nothing */
38 }
39
40 static void digest_null_final ( void *ctx __unused, void *out __unused ) {
41         /* Do nothing */
42 }
43
44 struct digest_algorithm digest_null = {
45         .name = "null",
46         .ctxsize = 0,
47         .blocksize = 1,
48         .digestsize = 0,
49         .init = digest_null_init,
50         .update = digest_null_update,
51         .final = digest_null_final,
52 };
53
54 static int cipher_null_setkey ( void *ctx __unused, const void *key __unused,
55                                 size_t keylen __unused ) {
56         /* Do nothing */
57         return 0;
58 }
59
60 static void cipher_null_setiv ( void *ctx __unused,
61                                 const void *iv __unused ) {
62         /* Do nothing */
63 }
64
65 static void cipher_null_encrypt ( void *ctx __unused, const void *src,
66                                   void *dst, size_t len ) {
67         memcpy ( dst, src, len );
68 }
69
70 static void cipher_null_decrypt ( void *ctx __unused, const void *src,
71                                   void *dst, size_t len ) {
72         memcpy ( dst, src, len );
73 }
74
75 struct cipher_algorithm cipher_null = {
76         .name = "null",
77         .ctxsize = 0,
78         .blocksize = 1,
79         .setkey = cipher_null_setkey,
80         .setiv = cipher_null_setiv,
81         .encrypt = cipher_null_encrypt,
82         .decrypt = cipher_null_decrypt,
83 };
84
85 static int pubkey_null_init ( void *ctx __unused, const void *key __unused,
86                               size_t key_len __unused ) {
87         return 0;
88 }
89
90 static size_t pubkey_null_max_len ( void *ctx __unused ) {
91         return 0;
92 }
93
94 static int pubkey_null_encrypt ( void *ctx __unused,
95                                  const void *plaintext __unused,
96                                  size_t plaintext_len __unused,
97                                  void *ciphertext __unused ) {
98         return 0;
99 }
100
101 static int pubkey_null_decrypt ( void *ctx __unused,
102                                  const void *ciphertext __unused,
103                                  size_t ciphertext_len __unused,
104                                  void *plaintext __unused ) {
105         return 0;
106 }
107
108 static int pubkey_null_sign ( void *ctx __unused,
109                               struct digest_algorithm *digest __unused,
110                               const void *value __unused,
111                               void *signature __unused ) {
112         return 0;
113 }
114
115 static int pubkey_null_verify ( void *ctx __unused,
116                                 struct digest_algorithm *digest __unused,
117                                 const void *value __unused,
118                                 const void *signature __unused ,
119                                 size_t signature_len __unused ) {
120         return 0;
121 }
122
123 static void pubkey_null_final ( void *ctx __unused ) {
124         /* Do nothing */
125 }
126
127 struct pubkey_algorithm pubkey_null = {
128         .name = "null",
129         .ctxsize = 0,
130         .init = pubkey_null_init,
131         .max_len = pubkey_null_max_len,
132         .encrypt = pubkey_null_encrypt,
133         .decrypt = pubkey_null_decrypt,
134         .sign = pubkey_null_sign,
135         .verify = pubkey_null_verify,
136         .final = pubkey_null_final,
137 };