iPXE
crypto_null.c
Go to the documentation of this file.
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  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 /**
27  * @file
28  *
29  * Null crypto algorithm
30  */
31 
32 #include <string.h>
33 #include <ipxe/crypto.h>
34 
35 void digest_null_init ( void *ctx __unused ) {
36  /* Do nothing */
37 }
38 
39 void digest_null_update ( void *ctx __unused, const void *src __unused,
40  size_t len __unused ) {
41  /* Do nothing */
42 }
43 
44 void digest_null_final ( void *ctx __unused, void *out __unused ) {
45  /* Do nothing */
46 }
47 
49  .name = "null",
50  .ctxsize = 0,
51  .blocksize = 1,
52  .digestsize = 0,
53  .init = digest_null_init,
54  .update = digest_null_update,
55  .final = digest_null_final,
56 };
57 
58 int cipher_null_setkey ( void *ctx __unused, const void *key __unused,
59  size_t keylen __unused ) {
60  /* Do nothing */
61  return 0;
62 }
63 
64 void cipher_null_setiv ( void *ctx __unused, const void *iv __unused,
65  size_t ivlen __unused ) {
66  /* Do nothing */
67 }
68 
69 void cipher_null_encrypt ( void *ctx __unused, const void *src, void *dst,
70  size_t len ) {
71  memcpy ( dst, src, len );
72 }
73 
74 void cipher_null_decrypt ( void *ctx __unused, const void *src, void *dst,
75  size_t len ) {
76  memcpy ( dst, src, len );
77 }
78 
79 void cipher_null_auth ( void *ctx __unused, void *auth __unused ) {
80  /* Do nothing */
81 }
82 
84  .name = "null",
85  .ctxsize = 0,
86  .blocksize = 1,
87  .alignsize = 1,
88  .authsize = 0,
89  .setkey = cipher_null_setkey,
90  .setiv = cipher_null_setiv,
91  .encrypt = cipher_null_encrypt,
92  .decrypt = cipher_null_decrypt,
93  .auth = cipher_null_auth,
94 };
95 
96 int pubkey_null_init ( void *ctx __unused, const void *key __unused,
97  size_t key_len __unused ) {
98  return 0;
99 }
100 
101 size_t pubkey_null_max_len ( void *ctx __unused ) {
102  return 0;
103 }
104 
105 int pubkey_null_encrypt ( void *ctx __unused, const void *plaintext __unused,
106  size_t plaintext_len __unused,
107  void *ciphertext __unused ) {
108  return 0;
109 }
110 
111 int pubkey_null_decrypt ( void *ctx __unused, const void *ciphertext __unused,
112  size_t ciphertext_len __unused,
113  void *plaintext __unused ) {
114  return 0;
115 }
116 
119  const void *value __unused, void *signature __unused ) {
120  return 0;
121 }
122 
125  const void *value __unused,
126  const void *signature __unused ,
127  size_t signature_len __unused ) {
128  return 0;
129 }
130 
132  /* Do nothing */
133 }
134 
136  .name = "null",
137  .ctxsize = 0,
138  .init = pubkey_null_init,
139  .max_len = pubkey_null_max_len,
140  .encrypt = pubkey_null_encrypt,
141  .decrypt = pubkey_null_decrypt,
142  .sign = pubkey_null_sign,
143  .verify = pubkey_null_verify,
144  .final = pubkey_null_final,
145 };
void digest_null_final(void *ctx __unused, void *out __unused)
Definition: crypto_null.c:44
void digest_null_init(void *ctx __unused)
Definition: crypto_null.c:35
void cipher_null_decrypt(void *ctx __unused, const void *src, void *dst, size_t len)
Definition: crypto_null.c:74
static void const void void * dst
Definition: crypto.h:244
void cipher_null_encrypt(void *ctx __unused, const void *src, void *dst, size_t len)
Definition: crypto_null.c:69
static void const void * src
Definition: crypto.h:244
void cipher_null_setiv(void *ctx __unused, const void *iv __unused, size_t ivlen __unused)
Definition: crypto_null.c:64
struct pubkey_algorithm pubkey_null
Definition: crypto_null.c:135
Cryptographic API.
static void void * auth
Definition: crypto.h:264
__be32 out[4]
Definition: CIB_PRM.h:36
static void const void size_t key_len
Definition: crypto.h:285
static void const void size_t ivlen
Definition: crypto.h:239
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int cipher_null_setkey(void *ctx __unused, const void *key __unused, size_t keylen __unused)
Definition: crypto_null.c:58
static void const void size_t keylen
Definition: crypto.h:233
void digest_null_update(void *ctx __unused, const void *src __unused, size_t len __unused)
Definition: crypto_null.c:39
int pubkey_null_encrypt(void *ctx __unused, const void *plaintext __unused, size_t plaintext_len __unused, void *ciphertext __unused)
Definition: crypto_null.c:105
size_t pubkey_null_max_len(void *ctx __unused)
Definition: crypto_null.c:101
static void struct digest_algorithm * digest
HMAC-MD5 digest.
Definition: crypto.h:308
int pubkey_null_sign(void *ctx __unused, struct digest_algorithm *digest __unused, const void *value __unused, void *signature __unused)
Definition: crypto_null.c:117
static void struct digest_algorithm const void const void size_t signature_len
Definition: crypto.h:316
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
struct digest_algorithm digest_null
Definition: crypto_null.c:48
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
struct cipher_algorithm cipher_null
Definition: crypto_null.c:83
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
uint32_t len
Length.
Definition: ena.h:14
static void const void * iv
Definition: crypto.h:238
const char * name
Algorithm name.
Definition: crypto.h:19
void pubkey_null_final(void *ctx __unused)
Definition: crypto_null.c:131
A message digest algorithm.
Definition: crypto.h:17
A cipher algorithm.
Definition: crypto.h:49
int pubkey_null_init(void *ctx __unused, const void *key __unused, size_t key_len __unused)
Definition: crypto_null.c:96
int pubkey_null_verify(void *ctx __unused, struct digest_algorithm *digest __unused, const void *value __unused, const void *signature __unused, size_t signature_len __unused)
Definition: crypto_null.c:123
const char * name
Algorithm name.
Definition: crypto.h:51
void cipher_null_auth(void *ctx __unused, void *auth __unused)
Definition: crypto_null.c:79
u8 signature
Signature.
Definition: CIB_PRM.h:35
String functions.
A public key algorithm.
Definition: crypto.h:120
union @382 key
Sense key.
Definition: crypto.h:284
const char * name
Algorithm name.
Definition: crypto.h:122
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int pubkey_null_decrypt(void *ctx __unused, const void *ciphertext __unused, size_t ciphertext_len __unused, void *plaintext __unused)
Definition: crypto_null.c:111