| 1 |
/** @file |
| 2 |
Defines base cryptographic library APIs. |
| 3 |
The Base Cryptographic Library provides implementations of basic cryptography |
| 4 |
primitives (Hash Serials, HMAC, RSA, Diffie-Hellman, etc) for UEFI security |
| 5 |
functionality enabling. |
| 6 |
|
| 7 |
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> |
| 8 |
This program and the accompanying materials |
| 9 |
are licensed and made available under the terms and conditions of the BSD License |
| 10 |
which accompanies this distribution. The full text of the license may be found at |
| 11 |
http://opensource.org/licenses/bsd-license.php |
| 12 |
|
| 13 |
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, |
| 14 |
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. |
| 15 |
|
| 16 |
**/ |
| 17 |
|
| 18 |
#ifndef __BASE_CRYPT_LIB_H__ |
| 19 |
#define __BASE_CRYPT_LIB_H__ |
| 20 |
|
| 21 |
#define IN |
| 22 |
#define OUT |
| 23 |
#define CONST const |
| 24 |
|
| 25 |
/// |
| 26 |
/// MD4 digest size in bytes |
| 27 |
/// |
| 28 |
#define MD4_DIGEST_SIZE 16 |
| 29 |
|
| 30 |
/// |
| 31 |
/// MD5 digest size in bytes |
| 32 |
/// |
| 33 |
#define MD5_DIGEST_SIZE 16 |
| 34 |
|
| 35 |
/// |
| 36 |
/// SHA-1 digest size in bytes. |
| 37 |
/// |
| 38 |
#define SHA1_DIGEST_SIZE 20 |
| 39 |
|
| 40 |
/// |
| 41 |
/// SHA-256 digest size in bytes |
| 42 |
/// |
| 43 |
#define SHA256_DIGEST_SIZE 32 |
| 44 |
|
| 45 |
/// |
| 46 |
/// SHA-384 digest size in bytes |
| 47 |
/// |
| 48 |
#define SHA384_DIGEST_SIZE 48 |
| 49 |
|
| 50 |
/// |
| 51 |
/// SHA-512 digest size in bytes |
| 52 |
/// |
| 53 |
#define SHA512_DIGEST_SIZE 64 |
| 54 |
|
| 55 |
/// |
| 56 |
/// TDES block size in bytes |
| 57 |
/// |
| 58 |
#define TDES_BLOCK_SIZE 8 |
| 59 |
|
| 60 |
/// |
| 61 |
/// AES block size in bytes |
| 62 |
/// |
| 63 |
#define AES_BLOCK_SIZE 16 |
| 64 |
|
| 65 |
/// |
| 66 |
/// RSA Key Tags Definition used in RsaSetKey() function for key component identification. |
| 67 |
/// |
| 68 |
typedef enum { |
| 69 |
RsaKeyN, ///< RSA public Modulus (N) |
| 70 |
RsaKeyE, ///< RSA Public exponent (e) |
| 71 |
RsaKeyD, ///< RSA Private exponent (d) |
| 72 |
RsaKeyP, ///< RSA secret prime factor of Modulus (p) |
| 73 |
RsaKeyQ, ///< RSA secret prime factor of Modules (q) |
| 74 |
RsaKeyDp, ///< p's CRT exponent (== d mod (p - 1)) |
| 75 |
RsaKeyDq, ///< q's CRT exponent (== d mod (q - 1)) |
| 76 |
RsaKeyQInv ///< The CRT coefficient (== 1/q mod p) |
| 77 |
} RSA_KEY_TAG; |
| 78 |
|
| 79 |
//===================================================================================== |
| 80 |
// One-Way Cryptographic Hash Primitives |
| 81 |
//===================================================================================== |
| 82 |
|
| 83 |
/** |
| 84 |
Retrieves the size, in bytes, of the context buffer required for MD4 hash operations. |
| 85 |
|
| 86 |
If this interface is not supported, then return zero. |
| 87 |
|
| 88 |
@return The size, in bytes, of the context buffer required for MD4 hash operations. |
| 89 |
@retval 0 This interface is not supported. |
| 90 |
|
| 91 |
**/ |
| 92 |
UINTN |
| 93 |
EFIAPI |
| 94 |
Md4GetContextSize ( |
| 95 |
VOID |
| 96 |
); |
| 97 |
|
| 98 |
/** |
| 99 |
Initializes user-supplied memory pointed by Md4Context as MD4 hash context for |
| 100 |
subsequent use. |
| 101 |
|
| 102 |
If Md4Context is NULL, then return FALSE. |
| 103 |
If this interface is not supported, then return FALSE. |
| 104 |
|
| 105 |
@param[out] Md4Context Pointer to MD4 context being initialized. |
| 106 |
|
| 107 |
@retval TRUE MD4 context initialization succeeded. |
| 108 |
@retval FALSE MD4 context initialization failed. |
| 109 |
@retval FALSE This interface is not supported. |
| 110 |
|
| 111 |
**/ |
| 112 |
BOOLEAN |
| 113 |
EFIAPI |
| 114 |
Md4Init ( |
| 115 |
OUT VOID *Md4Context |
| 116 |
); |
| 117 |
|
| 118 |
/** |
| 119 |
Makes a copy of an existing MD4 context. |
| 120 |
|
| 121 |
If Md4Context is NULL, then return FALSE. |
| 122 |
If NewMd4Context is NULL, then return FALSE. |
| 123 |
If this interface is not supported, then return FALSE. |
| 124 |
|
| 125 |
@param[in] Md4Context Pointer to MD4 context being copied. |
| 126 |
@param[out] NewMd4Context Pointer to new MD4 context. |
| 127 |
|
| 128 |
@retval TRUE MD4 context copy succeeded. |
| 129 |
@retval FALSE MD4 context copy failed. |
| 130 |
@retval FALSE This interface is not supported. |
| 131 |
|
| 132 |
**/ |
| 133 |
BOOLEAN |
| 134 |
EFIAPI |
| 135 |
Md4Duplicate ( |
| 136 |
IN CONST VOID *Md4Context, |
| 137 |
OUT VOID *NewMd4Context |
| 138 |
); |
| 139 |
|
| 140 |
/** |
| 141 |
Digests the input data and updates MD4 context. |
| 142 |
|
| 143 |
This function performs MD4 digest on a data buffer of the specified size. |
| 144 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 145 |
MD4 context should be already correctly initialized by Md4Init(), and should not be finalized |
| 146 |
by Md4Final(). Behavior with invalid context is undefined. |
| 147 |
|
| 148 |
If Md4Context is NULL, then return FALSE. |
| 149 |
If this interface is not supported, then return FALSE. |
| 150 |
|
| 151 |
@param[in, out] Md4Context Pointer to the MD4 context. |
| 152 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 153 |
@param[in] DataSize Size of Data buffer in bytes. |
| 154 |
|
| 155 |
@retval TRUE MD4 data digest succeeded. |
| 156 |
@retval FALSE MD4 data digest failed. |
| 157 |
@retval FALSE This interface is not supported. |
| 158 |
|
| 159 |
**/ |
| 160 |
BOOLEAN |
| 161 |
EFIAPI |
| 162 |
Md4Update ( |
| 163 |
IN OUT VOID *Md4Context, |
| 164 |
IN CONST VOID *Data, |
| 165 |
IN UINTN DataSize |
| 166 |
); |
| 167 |
|
| 168 |
/** |
| 169 |
Completes computation of the MD4 digest value. |
| 170 |
|
| 171 |
This function completes MD4 hash computation and retrieves the digest value into |
| 172 |
the specified memory. After this function has been called, the MD4 context cannot |
| 173 |
be used again. |
| 174 |
MD4 context should be already correctly initialized by Md4Init(), and should not be |
| 175 |
finalized by Md4Final(). Behavior with invalid MD4 context is undefined. |
| 176 |
|
| 177 |
If Md4Context is NULL, then return FALSE. |
| 178 |
If HashValue is NULL, then return FALSE. |
| 179 |
If this interface is not supported, then return FALSE. |
| 180 |
|
| 181 |
@param[in, out] Md4Context Pointer to the MD4 context. |
| 182 |
@param[out] HashValue Pointer to a buffer that receives the MD4 digest |
| 183 |
value (16 bytes). |
| 184 |
|
| 185 |
@retval TRUE MD4 digest computation succeeded. |
| 186 |
@retval FALSE MD4 digest computation failed. |
| 187 |
@retval FALSE This interface is not supported. |
| 188 |
|
| 189 |
**/ |
| 190 |
BOOLEAN |
| 191 |
EFIAPI |
| 192 |
Md4Final ( |
| 193 |
IN OUT VOID *Md4Context, |
| 194 |
OUT UINT8 *HashValue |
| 195 |
); |
| 196 |
|
| 197 |
/** |
| 198 |
Computes the MD4 message digest of a input data buffer. |
| 199 |
|
| 200 |
This function performs the MD4 message digest of a given data buffer, and places |
| 201 |
the digest value into the specified memory. |
| 202 |
|
| 203 |
If this interface is not supported, then return FALSE. |
| 204 |
|
| 205 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 206 |
@param[in] DataSize Size of Data buffer in bytes. |
| 207 |
@param[out] HashValue Pointer to a buffer that receives the MD4 digest |
| 208 |
value (16 bytes). |
| 209 |
|
| 210 |
@retval TRUE MD4 digest computation succeeded. |
| 211 |
@retval FALSE MD4 digest computation failed. |
| 212 |
@retval FALSE This interface is not supported. |
| 213 |
|
| 214 |
**/ |
| 215 |
BOOLEAN |
| 216 |
EFIAPI |
| 217 |
Md4HashAll ( |
| 218 |
IN CONST VOID *Data, |
| 219 |
IN UINTN DataSize, |
| 220 |
OUT UINT8 *HashValue |
| 221 |
); |
| 222 |
|
| 223 |
/** |
| 224 |
Retrieves the size, in bytes, of the context buffer required for MD5 hash operations. |
| 225 |
|
| 226 |
If this interface is not supported, then return zero. |
| 227 |
|
| 228 |
@return The size, in bytes, of the context buffer required for MD5 hash operations. |
| 229 |
@retval 0 This interface is not supported. |
| 230 |
|
| 231 |
**/ |
| 232 |
UINTN |
| 233 |
EFIAPI |
| 234 |
Md5GetContextSize ( |
| 235 |
VOID |
| 236 |
); |
| 237 |
|
| 238 |
/** |
| 239 |
Initializes user-supplied memory pointed by Md5Context as MD5 hash context for |
| 240 |
subsequent use. |
| 241 |
|
| 242 |
If Md5Context is NULL, then return FALSE. |
| 243 |
If this interface is not supported, then return FALSE. |
| 244 |
|
| 245 |
@param[out] Md5Context Pointer to MD5 context being initialized. |
| 246 |
|
| 247 |
@retval TRUE MD5 context initialization succeeded. |
| 248 |
@retval FALSE MD5 context initialization failed. |
| 249 |
@retval FALSE This interface is not supported. |
| 250 |
|
| 251 |
**/ |
| 252 |
BOOLEAN |
| 253 |
EFIAPI |
| 254 |
Md5Init ( |
| 255 |
OUT VOID *Md5Context |
| 256 |
); |
| 257 |
|
| 258 |
/** |
| 259 |
Makes a copy of an existing MD5 context. |
| 260 |
|
| 261 |
If Md5Context is NULL, then return FALSE. |
| 262 |
If NewMd5Context is NULL, then return FALSE. |
| 263 |
If this interface is not supported, then return FALSE. |
| 264 |
|
| 265 |
@param[in] Md5Context Pointer to MD5 context being copied. |
| 266 |
@param[out] NewMd5Context Pointer to new MD5 context. |
| 267 |
|
| 268 |
@retval TRUE MD5 context copy succeeded. |
| 269 |
@retval FALSE MD5 context copy failed. |
| 270 |
@retval FALSE This interface is not supported. |
| 271 |
|
| 272 |
**/ |
| 273 |
BOOLEAN |
| 274 |
EFIAPI |
| 275 |
Md5Duplicate ( |
| 276 |
IN CONST VOID *Md5Context, |
| 277 |
OUT VOID *NewMd5Context |
| 278 |
); |
| 279 |
|
| 280 |
/** |
| 281 |
Digests the input data and updates MD5 context. |
| 282 |
|
| 283 |
This function performs MD5 digest on a data buffer of the specified size. |
| 284 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 285 |
MD5 context should be already correctly initialized by Md5Init(), and should not be finalized |
| 286 |
by Md5Final(). Behavior with invalid context is undefined. |
| 287 |
|
| 288 |
If Md5Context is NULL, then return FALSE. |
| 289 |
If this interface is not supported, then return FALSE. |
| 290 |
|
| 291 |
@param[in, out] Md5Context Pointer to the MD5 context. |
| 292 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 293 |
@param[in] DataSize Size of Data buffer in bytes. |
| 294 |
|
| 295 |
@retval TRUE MD5 data digest succeeded. |
| 296 |
@retval FALSE MD5 data digest failed. |
| 297 |
@retval FALSE This interface is not supported. |
| 298 |
|
| 299 |
**/ |
| 300 |
BOOLEAN |
| 301 |
EFIAPI |
| 302 |
Md5Update ( |
| 303 |
IN OUT VOID *Md5Context, |
| 304 |
IN CONST VOID *Data, |
| 305 |
IN UINTN DataSize |
| 306 |
); |
| 307 |
|
| 308 |
/** |
| 309 |
Completes computation of the MD5 digest value. |
| 310 |
|
| 311 |
This function completes MD5 hash computation and retrieves the digest value into |
| 312 |
the specified memory. After this function has been called, the MD5 context cannot |
| 313 |
be used again. |
| 314 |
MD5 context should be already correctly initialized by Md5Init(), and should not be |
| 315 |
finalized by Md5Final(). Behavior with invalid MD5 context is undefined. |
| 316 |
|
| 317 |
If Md5Context is NULL, then return FALSE. |
| 318 |
If HashValue is NULL, then return FALSE. |
| 319 |
If this interface is not supported, then return FALSE. |
| 320 |
|
| 321 |
@param[in, out] Md5Context Pointer to the MD5 context. |
| 322 |
@param[out] HashValue Pointer to a buffer that receives the MD5 digest |
| 323 |
value (16 bytes). |
| 324 |
|
| 325 |
@retval TRUE MD5 digest computation succeeded. |
| 326 |
@retval FALSE MD5 digest computation failed. |
| 327 |
@retval FALSE This interface is not supported. |
| 328 |
|
| 329 |
**/ |
| 330 |
BOOLEAN |
| 331 |
EFIAPI |
| 332 |
Md5Final ( |
| 333 |
IN OUT VOID *Md5Context, |
| 334 |
OUT UINT8 *HashValue |
| 335 |
); |
| 336 |
|
| 337 |
/** |
| 338 |
Computes the MD5 message digest of a input data buffer. |
| 339 |
|
| 340 |
This function performs the MD5 message digest of a given data buffer, and places |
| 341 |
the digest value into the specified memory. |
| 342 |
|
| 343 |
If this interface is not supported, then return FALSE. |
| 344 |
|
| 345 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 346 |
@param[in] DataSize Size of Data buffer in bytes. |
| 347 |
@param[out] HashValue Pointer to a buffer that receives the MD5 digest |
| 348 |
value (16 bytes). |
| 349 |
|
| 350 |
@retval TRUE MD5 digest computation succeeded. |
| 351 |
@retval FALSE MD5 digest computation failed. |
| 352 |
@retval FALSE This interface is not supported. |
| 353 |
|
| 354 |
**/ |
| 355 |
BOOLEAN |
| 356 |
EFIAPI |
| 357 |
Md5HashAll ( |
| 358 |
IN CONST VOID *Data, |
| 359 |
IN UINTN DataSize, |
| 360 |
OUT UINT8 *HashValue |
| 361 |
); |
| 362 |
|
| 363 |
/** |
| 364 |
Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations. |
| 365 |
|
| 366 |
If this interface is not supported, then return zero. |
| 367 |
|
| 368 |
@return The size, in bytes, of the context buffer required for SHA-1 hash operations. |
| 369 |
@retval 0 This interface is not supported. |
| 370 |
|
| 371 |
**/ |
| 372 |
UINTN |
| 373 |
EFIAPI |
| 374 |
Sha1GetContextSize ( |
| 375 |
VOID |
| 376 |
); |
| 377 |
|
| 378 |
/** |
| 379 |
Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for |
| 380 |
subsequent use. |
| 381 |
|
| 382 |
If Sha1Context is NULL, then return FALSE. |
| 383 |
If this interface is not supported, then return FALSE. |
| 384 |
|
| 385 |
@param[out] Sha1Context Pointer to SHA-1 context being initialized. |
| 386 |
|
| 387 |
@retval TRUE SHA-1 context initialization succeeded. |
| 388 |
@retval FALSE SHA-1 context initialization failed. |
| 389 |
@retval FALSE This interface is not supported. |
| 390 |
|
| 391 |
**/ |
| 392 |
BOOLEAN |
| 393 |
EFIAPI |
| 394 |
Sha1Init ( |
| 395 |
OUT VOID *Sha1Context |
| 396 |
); |
| 397 |
|
| 398 |
/** |
| 399 |
Makes a copy of an existing SHA-1 context. |
| 400 |
|
| 401 |
If Sha1Context is NULL, then return FALSE. |
| 402 |
If NewSha1Context is NULL, then return FALSE. |
| 403 |
If this interface is not supported, then return FALSE. |
| 404 |
|
| 405 |
@param[in] Sha1Context Pointer to SHA-1 context being copied. |
| 406 |
@param[out] NewSha1Context Pointer to new SHA-1 context. |
| 407 |
|
| 408 |
@retval TRUE SHA-1 context copy succeeded. |
| 409 |
@retval FALSE SHA-1 context copy failed. |
| 410 |
@retval FALSE This interface is not supported. |
| 411 |
|
| 412 |
**/ |
| 413 |
BOOLEAN |
| 414 |
EFIAPI |
| 415 |
Sha1Duplicate ( |
| 416 |
IN CONST VOID *Sha1Context, |
| 417 |
OUT VOID *NewSha1Context |
| 418 |
); |
| 419 |
|
| 420 |
/** |
| 421 |
Digests the input data and updates SHA-1 context. |
| 422 |
|
| 423 |
This function performs SHA-1 digest on a data buffer of the specified size. |
| 424 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 425 |
SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized |
| 426 |
by Sha1Final(). Behavior with invalid context is undefined. |
| 427 |
|
| 428 |
If Sha1Context is NULL, then return FALSE. |
| 429 |
If this interface is not supported, then return FALSE. |
| 430 |
|
| 431 |
@param[in, out] Sha1Context Pointer to the SHA-1 context. |
| 432 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 433 |
@param[in] DataSize Size of Data buffer in bytes. |
| 434 |
|
| 435 |
@retval TRUE SHA-1 data digest succeeded. |
| 436 |
@retval FALSE SHA-1 data digest failed. |
| 437 |
@retval FALSE This interface is not supported. |
| 438 |
|
| 439 |
**/ |
| 440 |
BOOLEAN |
| 441 |
EFIAPI |
| 442 |
Sha1Update ( |
| 443 |
IN OUT VOID *Sha1Context, |
| 444 |
IN CONST VOID *Data, |
| 445 |
IN UINTN DataSize |
| 446 |
); |
| 447 |
|
| 448 |
/** |
| 449 |
Completes computation of the SHA-1 digest value. |
| 450 |
|
| 451 |
This function completes SHA-1 hash computation and retrieves the digest value into |
| 452 |
the specified memory. After this function has been called, the SHA-1 context cannot |
| 453 |
be used again. |
| 454 |
SHA-1 context should be already correctly initialized by Sha1Init(), and should not be |
| 455 |
finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined. |
| 456 |
|
| 457 |
If Sha1Context is NULL, then return FALSE. |
| 458 |
If HashValue is NULL, then return FALSE. |
| 459 |
If this interface is not supported, then return FALSE. |
| 460 |
|
| 461 |
@param[in, out] Sha1Context Pointer to the SHA-1 context. |
| 462 |
@param[out] HashValue Pointer to a buffer that receives the SHA-1 digest |
| 463 |
value (20 bytes). |
| 464 |
|
| 465 |
@retval TRUE SHA-1 digest computation succeeded. |
| 466 |
@retval FALSE SHA-1 digest computation failed. |
| 467 |
@retval FALSE This interface is not supported. |
| 468 |
|
| 469 |
**/ |
| 470 |
BOOLEAN |
| 471 |
EFIAPI |
| 472 |
Sha1Final ( |
| 473 |
IN OUT VOID *Sha1Context, |
| 474 |
OUT UINT8 *HashValue |
| 475 |
); |
| 476 |
|
| 477 |
/** |
| 478 |
Computes the SHA-1 message digest of a input data buffer. |
| 479 |
|
| 480 |
This function performs the SHA-1 message digest of a given data buffer, and places |
| 481 |
the digest value into the specified memory. |
| 482 |
|
| 483 |
If this interface is not supported, then return FALSE. |
| 484 |
|
| 485 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 486 |
@param[in] DataSize Size of Data buffer in bytes. |
| 487 |
@param[out] HashValue Pointer to a buffer that receives the SHA-1 digest |
| 488 |
value (20 bytes). |
| 489 |
|
| 490 |
@retval TRUE SHA-1 digest computation succeeded. |
| 491 |
@retval FALSE SHA-1 digest computation failed. |
| 492 |
@retval FALSE This interface is not supported. |
| 493 |
|
| 494 |
**/ |
| 495 |
BOOLEAN |
| 496 |
EFIAPI |
| 497 |
Sha1HashAll ( |
| 498 |
IN CONST VOID *Data, |
| 499 |
IN UINTN DataSize, |
| 500 |
OUT UINT8 *HashValue |
| 501 |
); |
| 502 |
|
| 503 |
/** |
| 504 |
Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations. |
| 505 |
|
| 506 |
@return The size, in bytes, of the context buffer required for SHA-256 hash operations. |
| 507 |
|
| 508 |
**/ |
| 509 |
UINTN |
| 510 |
EFIAPI |
| 511 |
Sha256GetContextSize ( |
| 512 |
VOID |
| 513 |
); |
| 514 |
|
| 515 |
/** |
| 516 |
Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for |
| 517 |
subsequent use. |
| 518 |
|
| 519 |
If Sha256Context is NULL, then return FALSE. |
| 520 |
|
| 521 |
@param[out] Sha256Context Pointer to SHA-256 context being initialized. |
| 522 |
|
| 523 |
@retval TRUE SHA-256 context initialization succeeded. |
| 524 |
@retval FALSE SHA-256 context initialization failed. |
| 525 |
|
| 526 |
**/ |
| 527 |
BOOLEAN |
| 528 |
EFIAPI |
| 529 |
Sha256Init ( |
| 530 |
OUT VOID *Sha256Context |
| 531 |
); |
| 532 |
|
| 533 |
/** |
| 534 |
Makes a copy of an existing SHA-256 context. |
| 535 |
|
| 536 |
If Sha256Context is NULL, then return FALSE. |
| 537 |
If NewSha256Context is NULL, then return FALSE. |
| 538 |
If this interface is not supported, then return FALSE. |
| 539 |
|
| 540 |
@param[in] Sha256Context Pointer to SHA-256 context being copied. |
| 541 |
@param[out] NewSha256Context Pointer to new SHA-256 context. |
| 542 |
|
| 543 |
@retval TRUE SHA-256 context copy succeeded. |
| 544 |
@retval FALSE SHA-256 context copy failed. |
| 545 |
@retval FALSE This interface is not supported. |
| 546 |
|
| 547 |
**/ |
| 548 |
BOOLEAN |
| 549 |
EFIAPI |
| 550 |
Sha256Duplicate ( |
| 551 |
IN CONST VOID *Sha256Context, |
| 552 |
OUT VOID *NewSha256Context |
| 553 |
); |
| 554 |
|
| 555 |
/** |
| 556 |
Digests the input data and updates SHA-256 context. |
| 557 |
|
| 558 |
This function performs SHA-256 digest on a data buffer of the specified size. |
| 559 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 560 |
SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized |
| 561 |
by Sha256Final(). Behavior with invalid context is undefined. |
| 562 |
|
| 563 |
If Sha256Context is NULL, then return FALSE. |
| 564 |
|
| 565 |
@param[in, out] Sha256Context Pointer to the SHA-256 context. |
| 566 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 567 |
@param[in] DataSize Size of Data buffer in bytes. |
| 568 |
|
| 569 |
@retval TRUE SHA-256 data digest succeeded. |
| 570 |
@retval FALSE SHA-256 data digest failed. |
| 571 |
|
| 572 |
**/ |
| 573 |
BOOLEAN |
| 574 |
EFIAPI |
| 575 |
Sha256Update ( |
| 576 |
IN OUT VOID *Sha256Context, |
| 577 |
IN CONST VOID *Data, |
| 578 |
IN UINTN DataSize |
| 579 |
); |
| 580 |
|
| 581 |
/** |
| 582 |
Completes computation of the SHA-256 digest value. |
| 583 |
|
| 584 |
This function completes SHA-256 hash computation and retrieves the digest value into |
| 585 |
the specified memory. After this function has been called, the SHA-256 context cannot |
| 586 |
be used again. |
| 587 |
SHA-256 context should be already correctly initialized by Sha256Init(), and should not be |
| 588 |
finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined. |
| 589 |
|
| 590 |
If Sha256Context is NULL, then return FALSE. |
| 591 |
If HashValue is NULL, then return FALSE. |
| 592 |
|
| 593 |
@param[in, out] Sha256Context Pointer to the SHA-256 context. |
| 594 |
@param[out] HashValue Pointer to a buffer that receives the SHA-256 digest |
| 595 |
value (32 bytes). |
| 596 |
|
| 597 |
@retval TRUE SHA-256 digest computation succeeded. |
| 598 |
@retval FALSE SHA-256 digest computation failed. |
| 599 |
|
| 600 |
**/ |
| 601 |
BOOLEAN |
| 602 |
EFIAPI |
| 603 |
Sha256Final ( |
| 604 |
IN OUT VOID *Sha256Context, |
| 605 |
OUT UINT8 *HashValue |
| 606 |
); |
| 607 |
|
| 608 |
/** |
| 609 |
Computes the SHA-256 message digest of a input data buffer. |
| 610 |
|
| 611 |
This function performs the SHA-256 message digest of a given data buffer, and places |
| 612 |
the digest value into the specified memory. |
| 613 |
|
| 614 |
If this interface is not supported, then return FALSE. |
| 615 |
|
| 616 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 617 |
@param[in] DataSize Size of Data buffer in bytes. |
| 618 |
@param[out] HashValue Pointer to a buffer that receives the SHA-256 digest |
| 619 |
value (32 bytes). |
| 620 |
|
| 621 |
@retval TRUE SHA-256 digest computation succeeded. |
| 622 |
@retval FALSE SHA-256 digest computation failed. |
| 623 |
@retval FALSE This interface is not supported. |
| 624 |
|
| 625 |
**/ |
| 626 |
BOOLEAN |
| 627 |
EFIAPI |
| 628 |
Sha256HashAll ( |
| 629 |
IN CONST VOID *Data, |
| 630 |
IN UINTN DataSize, |
| 631 |
OUT UINT8 *HashValue |
| 632 |
); |
| 633 |
|
| 634 |
/** |
| 635 |
Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations. |
| 636 |
|
| 637 |
@return The size, in bytes, of the context buffer required for SHA-384 hash operations. |
| 638 |
|
| 639 |
**/ |
| 640 |
UINTN |
| 641 |
EFIAPI |
| 642 |
Sha384GetContextSize ( |
| 643 |
VOID |
| 644 |
); |
| 645 |
|
| 646 |
/** |
| 647 |
Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for |
| 648 |
subsequent use. |
| 649 |
|
| 650 |
If Sha384Context is NULL, then return FALSE. |
| 651 |
|
| 652 |
@param[out] Sha384Context Pointer to SHA-384 context being initialized. |
| 653 |
|
| 654 |
@retval TRUE SHA-384 context initialization succeeded. |
| 655 |
@retval FALSE SHA-384 context initialization failed. |
| 656 |
|
| 657 |
**/ |
| 658 |
BOOLEAN |
| 659 |
EFIAPI |
| 660 |
Sha384Init ( |
| 661 |
OUT VOID *Sha384Context |
| 662 |
); |
| 663 |
|
| 664 |
/** |
| 665 |
Makes a copy of an existing SHA-384 context. |
| 666 |
|
| 667 |
If Sha384Context is NULL, then return FALSE. |
| 668 |
If NewSha384Context is NULL, then return FALSE. |
| 669 |
If this interface is not supported, then return FALSE. |
| 670 |
|
| 671 |
@param[in] Sha384Context Pointer to SHA-384 context being copied. |
| 672 |
@param[out] NewSha384Context Pointer to new SHA-384 context. |
| 673 |
|
| 674 |
@retval TRUE SHA-384 context copy succeeded. |
| 675 |
@retval FALSE SHA-384 context copy failed. |
| 676 |
@retval FALSE This interface is not supported. |
| 677 |
|
| 678 |
**/ |
| 679 |
BOOLEAN |
| 680 |
EFIAPI |
| 681 |
Sha384Duplicate ( |
| 682 |
IN CONST VOID *Sha384Context, |
| 683 |
OUT VOID *NewSha384Context |
| 684 |
); |
| 685 |
|
| 686 |
/** |
| 687 |
Digests the input data and updates SHA-384 context. |
| 688 |
|
| 689 |
This function performs SHA-384 digest on a data buffer of the specified size. |
| 690 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 691 |
SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized |
| 692 |
by Sha384Final(). Behavior with invalid context is undefined. |
| 693 |
|
| 694 |
If Sha384Context is NULL, then return FALSE. |
| 695 |
|
| 696 |
@param[in, out] Sha384Context Pointer to the SHA-384 context. |
| 697 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 698 |
@param[in] DataSize Size of Data buffer in bytes. |
| 699 |
|
| 700 |
@retval TRUE SHA-384 data digest succeeded. |
| 701 |
@retval FALSE SHA-384 data digest failed. |
| 702 |
|
| 703 |
**/ |
| 704 |
BOOLEAN |
| 705 |
EFIAPI |
| 706 |
Sha384Update ( |
| 707 |
IN OUT VOID *Sha384Context, |
| 708 |
IN CONST VOID *Data, |
| 709 |
IN UINTN DataSize |
| 710 |
); |
| 711 |
|
| 712 |
/** |
| 713 |
Completes computation of the SHA-384 digest value. |
| 714 |
|
| 715 |
This function completes SHA-384 hash computation and retrieves the digest value into |
| 716 |
the specified memory. After this function has been called, the SHA-384 context cannot |
| 717 |
be used again. |
| 718 |
SHA-384 context should be already correctly initialized by Sha384Init(), and should not be |
| 719 |
finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined. |
| 720 |
|
| 721 |
If Sha384Context is NULL, then return FALSE. |
| 722 |
If HashValue is NULL, then return FALSE. |
| 723 |
|
| 724 |
@param[in, out] Sha384Context Pointer to the SHA-384 context. |
| 725 |
@param[out] HashValue Pointer to a buffer that receives the SHA-384 digest |
| 726 |
value (48 bytes). |
| 727 |
|
| 728 |
@retval TRUE SHA-384 digest computation succeeded. |
| 729 |
@retval FALSE SHA-384 digest computation failed. |
| 730 |
|
| 731 |
**/ |
| 732 |
BOOLEAN |
| 733 |
EFIAPI |
| 734 |
Sha384Final ( |
| 735 |
IN OUT VOID *Sha384Context, |
| 736 |
OUT UINT8 *HashValue |
| 737 |
); |
| 738 |
|
| 739 |
/** |
| 740 |
Computes the SHA-384 message digest of a input data buffer. |
| 741 |
|
| 742 |
This function performs the SHA-384 message digest of a given data buffer, and places |
| 743 |
the digest value into the specified memory. |
| 744 |
|
| 745 |
If this interface is not supported, then return FALSE. |
| 746 |
|
| 747 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 748 |
@param[in] DataSize Size of Data buffer in bytes. |
| 749 |
@param[out] HashValue Pointer to a buffer that receives the SHA-384 digest |
| 750 |
value (48 bytes). |
| 751 |
|
| 752 |
@retval TRUE SHA-384 digest computation succeeded. |
| 753 |
@retval FALSE SHA-384 digest computation failed. |
| 754 |
@retval FALSE This interface is not supported. |
| 755 |
|
| 756 |
**/ |
| 757 |
BOOLEAN |
| 758 |
EFIAPI |
| 759 |
Sha384HashAll ( |
| 760 |
IN CONST VOID *Data, |
| 761 |
IN UINTN DataSize, |
| 762 |
OUT UINT8 *HashValue |
| 763 |
); |
| 764 |
|
| 765 |
/** |
| 766 |
Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations. |
| 767 |
|
| 768 |
@return The size, in bytes, of the context buffer required for SHA-512 hash operations. |
| 769 |
|
| 770 |
**/ |
| 771 |
UINTN |
| 772 |
EFIAPI |
| 773 |
Sha512GetContextSize ( |
| 774 |
VOID |
| 775 |
); |
| 776 |
|
| 777 |
/** |
| 778 |
Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for |
| 779 |
subsequent use. |
| 780 |
|
| 781 |
If Sha512Context is NULL, then return FALSE. |
| 782 |
|
| 783 |
@param[out] Sha512Context Pointer to SHA-512 context being initialized. |
| 784 |
|
| 785 |
@retval TRUE SHA-512 context initialization succeeded. |
| 786 |
@retval FALSE SHA-512 context initialization failed. |
| 787 |
|
| 788 |
**/ |
| 789 |
BOOLEAN |
| 790 |
EFIAPI |
| 791 |
Sha512Init ( |
| 792 |
OUT VOID *Sha512Context |
| 793 |
); |
| 794 |
|
| 795 |
/** |
| 796 |
Makes a copy of an existing SHA-512 context. |
| 797 |
|
| 798 |
If Sha512Context is NULL, then return FALSE. |
| 799 |
If NewSha512Context is NULL, then return FALSE. |
| 800 |
If this interface is not supported, then return FALSE. |
| 801 |
|
| 802 |
@param[in] Sha512Context Pointer to SHA-512 context being copied. |
| 803 |
@param[out] NewSha512Context Pointer to new SHA-512 context. |
| 804 |
|
| 805 |
@retval TRUE SHA-512 context copy succeeded. |
| 806 |
@retval FALSE SHA-512 context copy failed. |
| 807 |
@retval FALSE This interface is not supported. |
| 808 |
|
| 809 |
**/ |
| 810 |
BOOLEAN |
| 811 |
EFIAPI |
| 812 |
Sha512Duplicate ( |
| 813 |
IN CONST VOID *Sha512Context, |
| 814 |
OUT VOID *NewSha512Context |
| 815 |
); |
| 816 |
|
| 817 |
/** |
| 818 |
Digests the input data and updates SHA-512 context. |
| 819 |
|
| 820 |
This function performs SHA-512 digest on a data buffer of the specified size. |
| 821 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 822 |
SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized |
| 823 |
by Sha512Final(). Behavior with invalid context is undefined. |
| 824 |
|
| 825 |
If Sha512Context is NULL, then return FALSE. |
| 826 |
|
| 827 |
@param[in, out] Sha512Context Pointer to the SHA-512 context. |
| 828 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 829 |
@param[in] DataSize Size of Data buffer in bytes. |
| 830 |
|
| 831 |
@retval TRUE SHA-512 data digest succeeded. |
| 832 |
@retval FALSE SHA-512 data digest failed. |
| 833 |
|
| 834 |
**/ |
| 835 |
BOOLEAN |
| 836 |
EFIAPI |
| 837 |
Sha512Update ( |
| 838 |
IN OUT VOID *Sha512Context, |
| 839 |
IN CONST VOID *Data, |
| 840 |
IN UINTN DataSize |
| 841 |
); |
| 842 |
|
| 843 |
/** |
| 844 |
Completes computation of the SHA-512 digest value. |
| 845 |
|
| 846 |
This function completes SHA-512 hash computation and retrieves the digest value into |
| 847 |
the specified memory. After this function has been called, the SHA-512 context cannot |
| 848 |
be used again. |
| 849 |
SHA-512 context should be already correctly initialized by Sha512Init(), and should not be |
| 850 |
finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined. |
| 851 |
|
| 852 |
If Sha512Context is NULL, then return FALSE. |
| 853 |
If HashValue is NULL, then return FALSE. |
| 854 |
|
| 855 |
@param[in, out] Sha512Context Pointer to the SHA-512 context. |
| 856 |
@param[out] HashValue Pointer to a buffer that receives the SHA-512 digest |
| 857 |
value (64 bytes). |
| 858 |
|
| 859 |
@retval TRUE SHA-512 digest computation succeeded. |
| 860 |
@retval FALSE SHA-512 digest computation failed. |
| 861 |
|
| 862 |
**/ |
| 863 |
BOOLEAN |
| 864 |
EFIAPI |
| 865 |
Sha512Final ( |
| 866 |
IN OUT VOID *Sha512Context, |
| 867 |
OUT UINT8 *HashValue |
| 868 |
); |
| 869 |
|
| 870 |
/** |
| 871 |
Computes the SHA-512 message digest of a input data buffer. |
| 872 |
|
| 873 |
This function performs the SHA-512 message digest of a given data buffer, and places |
| 874 |
the digest value into the specified memory. |
| 875 |
|
| 876 |
If this interface is not supported, then return FALSE. |
| 877 |
|
| 878 |
@param[in] Data Pointer to the buffer containing the data to be hashed. |
| 879 |
@param[in] DataSize Size of Data buffer in bytes. |
| 880 |
@param[out] HashValue Pointer to a buffer that receives the SHA-512 digest |
| 881 |
value (64 bytes). |
| 882 |
|
| 883 |
@retval TRUE SHA-512 digest computation succeeded. |
| 884 |
@retval FALSE SHA-512 digest computation failed. |
| 885 |
@retval FALSE This interface is not supported. |
| 886 |
|
| 887 |
**/ |
| 888 |
BOOLEAN |
| 889 |
EFIAPI |
| 890 |
Sha512HashAll ( |
| 891 |
IN CONST VOID *Data, |
| 892 |
IN UINTN DataSize, |
| 893 |
OUT UINT8 *HashValue |
| 894 |
); |
| 895 |
|
| 896 |
//===================================================================================== |
| 897 |
// MAC (Message Authentication Code) Primitive |
| 898 |
//===================================================================================== |
| 899 |
|
| 900 |
/** |
| 901 |
Retrieves the size, in bytes, of the context buffer required for HMAC-MD5 operations. |
| 902 |
|
| 903 |
If this interface is not supported, then return zero. |
| 904 |
|
| 905 |
@return The size, in bytes, of the context buffer required for HMAC-MD5 operations. |
| 906 |
@retval 0 This interface is not supported. |
| 907 |
|
| 908 |
**/ |
| 909 |
UINTN |
| 910 |
EFIAPI |
| 911 |
HmacMd5GetContextSize ( |
| 912 |
VOID |
| 913 |
); |
| 914 |
|
| 915 |
/** |
| 916 |
Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 context for |
| 917 |
subsequent use. |
| 918 |
|
| 919 |
If HmacMd5Context is NULL, then return FALSE. |
| 920 |
If this interface is not supported, then return FALSE. |
| 921 |
|
| 922 |
@param[out] HmacMd5Context Pointer to HMAC-MD5 context being initialized. |
| 923 |
@param[in] Key Pointer to the user-supplied key. |
| 924 |
@param[in] KeySize Key size in bytes. |
| 925 |
|
| 926 |
@retval TRUE HMAC-MD5 context initialization succeeded. |
| 927 |
@retval FALSE HMAC-MD5 context initialization failed. |
| 928 |
@retval FALSE This interface is not supported. |
| 929 |
|
| 930 |
**/ |
| 931 |
BOOLEAN |
| 932 |
EFIAPI |
| 933 |
HmacMd5Init ( |
| 934 |
OUT VOID *HmacMd5Context, |
| 935 |
IN CONST UINT8 *Key, |
| 936 |
IN UINTN KeySize |
| 937 |
); |
| 938 |
|
| 939 |
/** |
| 940 |
Makes a copy of an existing HMAC-MD5 context. |
| 941 |
|
| 942 |
If HmacMd5Context is NULL, then return FALSE. |
| 943 |
If NewHmacMd5Context is NULL, then return FALSE. |
| 944 |
If this interface is not supported, then return FALSE. |
| 945 |
|
| 946 |
@param[in] HmacMd5Context Pointer to HMAC-MD5 context being copied. |
| 947 |
@param[out] NewHmacMd5Context Pointer to new HMAC-MD5 context. |
| 948 |
|
| 949 |
@retval TRUE HMAC-MD5 context copy succeeded. |
| 950 |
@retval FALSE HMAC-MD5 context copy failed. |
| 951 |
@retval FALSE This interface is not supported. |
| 952 |
|
| 953 |
**/ |
| 954 |
BOOLEAN |
| 955 |
EFIAPI |
| 956 |
HmacMd5Duplicate ( |
| 957 |
IN CONST VOID *HmacMd5Context, |
| 958 |
OUT VOID *NewHmacMd5Context |
| 959 |
); |
| 960 |
|
| 961 |
/** |
| 962 |
Digests the input data and updates HMAC-MD5 context. |
| 963 |
|
| 964 |
This function performs HMAC-MD5 digest on a data buffer of the specified size. |
| 965 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 966 |
HMAC-MD5 context should be already correctly initialized by HmacMd5Init(), and should not be |
| 967 |
finalized by HmacMd5Final(). Behavior with invalid context is undefined. |
| 968 |
|
| 969 |
If HmacMd5Context is NULL, then return FALSE. |
| 970 |
If this interface is not supported, then return FALSE. |
| 971 |
|
| 972 |
@param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context. |
| 973 |
@param[in] Data Pointer to the buffer containing the data to be digested. |
| 974 |
@param[in] DataSize Size of Data buffer in bytes. |
| 975 |
|
| 976 |
@retval TRUE HMAC-MD5 data digest succeeded. |
| 977 |
@retval FALSE HMAC-MD5 data digest failed. |
| 978 |
@retval FALSE This interface is not supported. |
| 979 |
|
| 980 |
**/ |
| 981 |
BOOLEAN |
| 982 |
EFIAPI |
| 983 |
HmacMd5Update ( |
| 984 |
IN OUT VOID *HmacMd5Context, |
| 985 |
IN CONST VOID *Data, |
| 986 |
IN UINTN DataSize |
| 987 |
); |
| 988 |
|
| 989 |
/** |
| 990 |
Completes computation of the HMAC-MD5 digest value. |
| 991 |
|
| 992 |
This function completes HMAC-MD5 hash computation and retrieves the digest value into |
| 993 |
the specified memory. After this function has been called, the HMAC-MD5 context cannot |
| 994 |
be used again. |
| 995 |
HMAC-MD5 context should be already correctly initialized by HmacMd5Init(), and should not be |
| 996 |
finalized by HmacMd5Final(). Behavior with invalid HMAC-MD5 context is undefined. |
| 997 |
|
| 998 |
If HmacMd5Context is NULL, then return FALSE. |
| 999 |
If HmacValue is NULL, then return FALSE. |
| 1000 |
If this interface is not supported, then return FALSE. |
| 1001 |
|
| 1002 |
@param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context. |
| 1003 |
@param[out] HmacValue Pointer to a buffer that receives the HMAC-MD5 digest |
| 1004 |
value (16 bytes). |
| 1005 |
|
| 1006 |
@retval TRUE HMAC-MD5 digest computation succeeded. |
| 1007 |
@retval FALSE HMAC-MD5 digest computation failed. |
| 1008 |
@retval FALSE This interface is not supported. |
| 1009 |
|
| 1010 |
**/ |
| 1011 |
BOOLEAN |
| 1012 |
EFIAPI |
| 1013 |
HmacMd5Final ( |
| 1014 |
IN OUT VOID *HmacMd5Context, |
| 1015 |
OUT UINT8 *HmacValue |
| 1016 |
); |
| 1017 |
|
| 1018 |
/** |
| 1019 |
Retrieves the size, in bytes, of the context buffer required for HMAC-SHA1 operations. |
| 1020 |
|
| 1021 |
If this interface is not supported, then return zero. |
| 1022 |
|
| 1023 |
@return The size, in bytes, of the context buffer required for HMAC-SHA1 operations. |
| 1024 |
@retval 0 This interface is not supported. |
| 1025 |
|
| 1026 |
**/ |
| 1027 |
UINTN |
| 1028 |
EFIAPI |
| 1029 |
HmacSha1GetContextSize ( |
| 1030 |
VOID |
| 1031 |
); |
| 1032 |
|
| 1033 |
/** |
| 1034 |
Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1 context for |
| 1035 |
subsequent use. |
| 1036 |
|
| 1037 |
If HmacSha1Context is NULL, then return FALSE. |
| 1038 |
If this interface is not supported, then return FALSE. |
| 1039 |
|
| 1040 |
@param[out] HmacSha1Context Pointer to HMAC-SHA1 context being initialized. |
| 1041 |
@param[in] Key Pointer to the user-supplied key. |
| 1042 |
@param[in] KeySize Key size in bytes. |
| 1043 |
|
| 1044 |
@retval TRUE HMAC-SHA1 context initialization succeeded. |
| 1045 |
@retval FALSE HMAC-SHA1 context initialization failed. |
| 1046 |
@retval FALSE This interface is not supported. |
| 1047 |
|
| 1048 |
**/ |
| 1049 |
BOOLEAN |
| 1050 |
EFIAPI |
| 1051 |
HmacSha1Init ( |
| 1052 |
OUT VOID *HmacSha1Context, |
| 1053 |
IN CONST UINT8 *Key, |
| 1054 |
IN UINTN KeySize |
| 1055 |
); |
| 1056 |
|
| 1057 |
/** |
| 1058 |
Makes a copy of an existing HMAC-SHA1 context. |
| 1059 |
|
| 1060 |
If HmacSha1Context is NULL, then return FALSE. |
| 1061 |
If NewHmacSha1Context is NULL, then return FALSE. |
| 1062 |
If this interface is not supported, then return FALSE. |
| 1063 |
|
| 1064 |
@param[in] HmacSha1Context Pointer to HMAC-SHA1 context being copied. |
| 1065 |
@param[out] NewHmacSha1Context Pointer to new HMAC-SHA1 context. |
| 1066 |
|
| 1067 |
@retval TRUE HMAC-SHA1 context copy succeeded. |
| 1068 |
@retval FALSE HMAC-SHA1 context copy failed. |
| 1069 |
@retval FALSE This interface is not supported. |
| 1070 |
|
| 1071 |
**/ |
| 1072 |
BOOLEAN |
| 1073 |
EFIAPI |
| 1074 |
HmacSha1Duplicate ( |
| 1075 |
IN CONST VOID *HmacSha1Context, |
| 1076 |
OUT VOID *NewHmacSha1Context |
| 1077 |
); |
| 1078 |
|
| 1079 |
/** |
| 1080 |
Digests the input data and updates HMAC-SHA1 context. |
| 1081 |
|
| 1082 |
This function performs HMAC-SHA1 digest on a data buffer of the specified size. |
| 1083 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 1084 |
HMAC-SHA1 context should be already correctly initialized by HmacSha1Init(), and should not |
| 1085 |
be finalized by HmacSha1Final(). Behavior with invalid context is undefined. |
| 1086 |
|
| 1087 |
If HmacSha1Context is NULL, then return FALSE. |
| 1088 |
If this interface is not supported, then return FALSE. |
| 1089 |
|
| 1090 |
@param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context. |
| 1091 |
@param[in] Data Pointer to the buffer containing the data to be digested. |
| 1092 |
@param[in] DataSize Size of Data buffer in bytes. |
| 1093 |
|
| 1094 |
@retval TRUE HMAC-SHA1 data digest succeeded. |
| 1095 |
@retval FALSE HMAC-SHA1 data digest failed. |
| 1096 |
@retval FALSE This interface is not supported. |
| 1097 |
|
| 1098 |
**/ |
| 1099 |
BOOLEAN |
| 1100 |
EFIAPI |
| 1101 |
HmacSha1Update ( |
| 1102 |
IN OUT VOID *HmacSha1Context, |
| 1103 |
IN CONST VOID *Data, |
| 1104 |
IN UINTN DataSize |
| 1105 |
); |
| 1106 |
|
| 1107 |
/** |
| 1108 |
Completes computation of the HMAC-SHA1 digest value. |
| 1109 |
|
| 1110 |
This function completes HMAC-SHA1 hash computation and retrieves the digest value into |
| 1111 |
the specified memory. After this function has been called, the HMAC-SHA1 context cannot |
| 1112 |
be used again. |
| 1113 |
HMAC-SHA1 context should be already correctly initialized by HmacSha1Init(), and should |
| 1114 |
not be finalized by HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined. |
| 1115 |
|
| 1116 |
If HmacSha1Context is NULL, then return FALSE. |
| 1117 |
If HmacValue is NULL, then return FALSE. |
| 1118 |
If this interface is not supported, then return FALSE. |
| 1119 |
|
| 1120 |
@param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context. |
| 1121 |
@param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA1 digest |
| 1122 |
value (20 bytes). |
| 1123 |
|
| 1124 |
@retval TRUE HMAC-SHA1 digest computation succeeded. |
| 1125 |
@retval FALSE HMAC-SHA1 digest computation failed. |
| 1126 |
@retval FALSE This interface is not supported. |
| 1127 |
|
| 1128 |
**/ |
| 1129 |
BOOLEAN |
| 1130 |
EFIAPI |
| 1131 |
HmacSha1Final ( |
| 1132 |
IN OUT VOID *HmacSha1Context, |
| 1133 |
OUT UINT8 *HmacValue |
| 1134 |
); |
| 1135 |
|
| 1136 |
/** |
| 1137 |
Retrieves the size, in bytes, of the context buffer required for HMAC-SHA256 operations. |
| 1138 |
|
| 1139 |
If this interface is not supported, then return zero. |
| 1140 |
|
| 1141 |
@return The size, in bytes, of the context buffer required for HMAC-SHA256 operations. |
| 1142 |
@retval 0 This interface is not supported. |
| 1143 |
|
| 1144 |
**/ |
| 1145 |
UINTN |
| 1146 |
EFIAPI |
| 1147 |
HmacSha256GetContextSize ( |
| 1148 |
VOID |
| 1149 |
); |
| 1150 |
|
| 1151 |
/** |
| 1152 |
Initializes user-supplied memory pointed by HmacSha256Context as HMAC-SHA256 context for |
| 1153 |
subsequent use. |
| 1154 |
|
| 1155 |
If HmacSha256Context is NULL, then return FALSE. |
| 1156 |
If this interface is not supported, then return FALSE. |
| 1157 |
|
| 1158 |
@param[out] HmacSha256Context Pointer to HMAC-SHA256 context being initialized. |
| 1159 |
@param[in] Key Pointer to the user-supplied key. |
| 1160 |
@param[in] KeySize Key size in bytes. |
| 1161 |
|
| 1162 |
@retval TRUE HMAC-SHA256 context initialization succeeded. |
| 1163 |
@retval FALSE HMAC-SHA256 context initialization failed. |
| 1164 |
@retval FALSE This interface is not supported. |
| 1165 |
|
| 1166 |
**/ |
| 1167 |
BOOLEAN |
| 1168 |
EFIAPI |
| 1169 |
HmacSha256Init ( |
| 1170 |
OUT VOID *HmacSha256Context, |
| 1171 |
IN CONST UINT8 *Key, |
| 1172 |
IN UINTN KeySize |
| 1173 |
); |
| 1174 |
|
| 1175 |
/** |
| 1176 |
Makes a copy of an existing HMAC-SHA256 context. |
| 1177 |
|
| 1178 |
If HmacSha256Context is NULL, then return FALSE. |
| 1179 |
If NewHmacSha256Context is NULL, then return FALSE. |
| 1180 |
If this interface is not supported, then return FALSE. |
| 1181 |
|
| 1182 |
@param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied. |
| 1183 |
@param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context. |
| 1184 |
|
| 1185 |
@retval TRUE HMAC-SHA256 context copy succeeded. |
| 1186 |
@retval FALSE HMAC-SHA256 context copy failed. |
| 1187 |
@retval FALSE This interface is not supported. |
| 1188 |
|
| 1189 |
**/ |
| 1190 |
BOOLEAN |
| 1191 |
EFIAPI |
| 1192 |
HmacSha256Duplicate ( |
| 1193 |
IN CONST VOID *HmacSha256Context, |
| 1194 |
OUT VOID *NewHmacSha256Context |
| 1195 |
); |
| 1196 |
|
| 1197 |
/** |
| 1198 |
Digests the input data and updates HMAC-SHA256 context. |
| 1199 |
|
| 1200 |
This function performs HMAC-SHA256 digest on a data buffer of the specified size. |
| 1201 |
It can be called multiple times to compute the digest of long or discontinuous data streams. |
| 1202 |
HMAC-SHA256 context should be already correctly initialized by HmacSha256Init(), and should not |
| 1203 |
be finalized by HmacSha256Final(). Behavior with invalid context is undefined. |
| 1204 |
|
| 1205 |
If HmacSha256Context is NULL, then return FALSE. |
| 1206 |
If this interface is not supported, then return FALSE. |
| 1207 |
|
| 1208 |
@param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context. |
| 1209 |
@param[in] Data Pointer to the buffer containing the data to be digested. |
| 1210 |
@param[in] DataSize Size of Data buffer in bytes. |
| 1211 |
|
| 1212 |
@retval TRUE HMAC-SHA256 data digest succeeded. |
| 1213 |
@retval FALSE HMAC-SHA256 data digest failed. |
| 1214 |
@retval FALSE This interface is not supported. |
| 1215 |
|
| 1216 |
**/ |
| 1217 |
BOOLEAN |
| 1218 |
EFIAPI |
| 1219 |
HmacSha256Update ( |
| 1220 |
IN OUT VOID *HmacSha256Context, |
| 1221 |
IN CONST VOID *Data, |
| 1222 |
IN UINTN DataSize |
| 1223 |
); |
| 1224 |
|
| 1225 |
/** |
| 1226 |
Completes computation of the HMAC-SHA256 digest value. |
| 1227 |
|
| 1228 |
This function completes HMAC-SHA256 hash computation and retrieves the digest value into |
| 1229 |
the specified memory. After this function has been called, the HMAC-SHA256 context cannot |
| 1230 |
be used again. |
| 1231 |
HMAC-SHA256 context should be already correctly initialized by HmacSha256Init(), and should |
| 1232 |
not be finalized by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined. |
| 1233 |
|
| 1234 |
If HmacSha256Context is NULL, then return FALSE. |
| 1235 |
If HmacValue is NULL, then return FALSE. |
| 1236 |
If this interface is not supported, then return FALSE. |
| 1237 |
|
| 1238 |
@param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context. |
| 1239 |
@param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest |
| 1240 |
value (32 bytes). |
| 1241 |
|
| 1242 |
@retval TRUE HMAC-SHA256 digest computation succeeded. |
| 1243 |
@retval FALSE HMAC-SHA256 digest computation failed. |
| 1244 |
@retval FALSE This interface is not supported. |
| 1245 |
|
| 1246 |
**/ |
| 1247 |
BOOLEAN |
| 1248 |
EFIAPI |
| 1249 |
HmacSha256Final ( |
| 1250 |
IN OUT VOID *HmacSha256Context, |
| 1251 |
OUT UINT8 *HmacValue |
| 1252 |
); |
| 1253 |
|
| 1254 |
//===================================================================================== |
| 1255 |
// Symmetric Cryptography Primitive |
| 1256 |
//===================================================================================== |
| 1257 |
|
| 1258 |
/** |
| 1259 |
Retrieves the size, in bytes, of the context buffer required for TDES operations. |
| 1260 |
|
| 1261 |
If this interface is not supported, then return zero. |
| 1262 |
|
| 1263 |
@return The size, in bytes, of the context buffer required for TDES operations. |
| 1264 |
@retval 0 This interface is not supported. |
| 1265 |
|
| 1266 |
**/ |
| 1267 |
UINTN |
| 1268 |
EFIAPI |
| 1269 |
TdesGetContextSize ( |
| 1270 |
VOID |
| 1271 |
); |
| 1272 |
|
| 1273 |
/** |
| 1274 |
Initializes user-supplied memory as TDES context for subsequent use. |
| 1275 |
|
| 1276 |
This function initializes user-supplied memory pointed by TdesContext as TDES context. |
| 1277 |
In addition, it sets up all TDES key materials for subsequent encryption and decryption |
| 1278 |
operations. |
| 1279 |
There are 3 key options as follows: |
| 1280 |
KeyLength = 64, Keying option 1: K1 == K2 == K3 (Backward compatibility with DES) |
| 1281 |
KeyLength = 128, Keying option 2: K1 != K2 and K3 = K1 (Less Security) |
| 1282 |
KeyLength = 192 Keying option 3: K1 != K2 != K3 (Strongest) |
| 1283 |
|
| 1284 |
If TdesContext is NULL, then return FALSE. |
| 1285 |
If Key is NULL, then return FALSE. |
| 1286 |
If KeyLength is not valid, then return FALSE. |
| 1287 |
If this interface is not supported, then return FALSE. |
| 1288 |
|
| 1289 |
@param[out] TdesContext Pointer to TDES context being initialized. |
| 1290 |
@param[in] Key Pointer to the user-supplied TDES key. |
| 1291 |
@param[in] KeyLength Length of TDES key in bits. |
| 1292 |
|
| 1293 |
@retval TRUE TDES context initialization succeeded. |
| 1294 |
@retval FALSE TDES context initialization failed. |
| 1295 |
@retval FALSE This interface is not supported. |
| 1296 |
|
| 1297 |
**/ |
| 1298 |
BOOLEAN |
| 1299 |
EFIAPI |
| 1300 |
TdesInit ( |
| 1301 |
OUT VOID *TdesContext, |
| 1302 |
IN CONST UINT8 *Key, |
| 1303 |
IN UINTN KeyLength |
| 1304 |
); |
| 1305 |
|
| 1306 |
/** |
| 1307 |
Performs TDES encryption on a data buffer of the specified size in ECB mode. |
| 1308 |
|
| 1309 |
This function performs TDES encryption on data buffer pointed by Input, of specified |
| 1310 |
size of InputSize, in ECB mode. |
| 1311 |
InputSize must be multiple of block size (8 bytes). This function does not perform |
| 1312 |
padding. Caller must perform padding, if necessary, to ensure valid input data size. |
| 1313 |
TdesContext should be already correctly initialized by TdesInit(). Behavior with |
| 1314 |
invalid TDES context is undefined. |
| 1315 |
|
| 1316 |
If TdesContext is NULL, then return FALSE. |
| 1317 |
If Input is NULL, then return FALSE. |
| 1318 |
If InputSize is not multiple of block size (8 bytes), then return FALSE. |
| 1319 |
If Output is NULL, then return FALSE. |
| 1320 |
If this interface is not supported, then return FALSE. |
| 1321 |
|
| 1322 |
@param[in] TdesContext Pointer to the TDES context. |
| 1323 |
@param[in] Input Pointer to the buffer containing the data to be encrypted. |
| 1324 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1325 |
@param[out] Output Pointer to a buffer that receives the TDES encryption output. |
| 1326 |
|
| 1327 |
@retval TRUE TDES encryption succeeded. |
| 1328 |
@retval FALSE TDES encryption failed. |
| 1329 |
@retval FALSE This interface is not supported. |
| 1330 |
|
| 1331 |
**/ |
| 1332 |
BOOLEAN |
| 1333 |
EFIAPI |
| 1334 |
TdesEcbEncrypt ( |
| 1335 |
IN VOID *TdesContext, |
| 1336 |
IN CONST UINT8 *Input, |
| 1337 |
IN UINTN InputSize, |
| 1338 |
OUT UINT8 *Output |
| 1339 |
); |
| 1340 |
|
| 1341 |
/** |
| 1342 |
Performs TDES decryption on a data buffer of the specified size in ECB mode. |
| 1343 |
|
| 1344 |
This function performs TDES decryption on data buffer pointed by Input, of specified |
| 1345 |
size of InputSize, in ECB mode. |
| 1346 |
InputSize must be multiple of block size (8 bytes). This function does not perform |
| 1347 |
padding. Caller must perform padding, if necessary, to ensure valid input data size. |
| 1348 |
TdesContext should be already correctly initialized by TdesInit(). Behavior with |
| 1349 |
invalid TDES context is undefined. |
| 1350 |
|
| 1351 |
If TdesContext is NULL, then return FALSE. |
| 1352 |
If Input is NULL, then return FALSE. |
| 1353 |
If InputSize is not multiple of block size (8 bytes), then return FALSE. |
| 1354 |
If Output is NULL, then return FALSE. |
| 1355 |
If this interface is not supported, then return FALSE. |
| 1356 |
|
| 1357 |
@param[in] TdesContext Pointer to the TDES context. |
| 1358 |
@param[in] Input Pointer to the buffer containing the data to be decrypted. |
| 1359 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1360 |
@param[out] Output Pointer to a buffer that receives the TDES decryption output. |
| 1361 |
|
| 1362 |
@retval TRUE TDES decryption succeeded. |
| 1363 |
@retval FALSE TDES decryption failed. |
| 1364 |
@retval FALSE This interface is not supported. |
| 1365 |
|
| 1366 |
**/ |
| 1367 |
BOOLEAN |
| 1368 |
EFIAPI |
| 1369 |
TdesEcbDecrypt ( |
| 1370 |
IN VOID *TdesContext, |
| 1371 |
IN CONST UINT8 *Input, |
| 1372 |
IN UINTN InputSize, |
| 1373 |
OUT UINT8 *Output |
| 1374 |
); |
| 1375 |
|
| 1376 |
/** |
| 1377 |
Performs TDES encryption on a data buffer of the specified size in CBC mode. |
| 1378 |
|
| 1379 |
This function performs TDES encryption on data buffer pointed by Input, of specified |
| 1380 |
size of InputSize, in CBC mode. |
| 1381 |
InputSize must be multiple of block size (8 bytes). This function does not perform |
| 1382 |
padding. Caller must perform padding, if necessary, to ensure valid input data size. |
| 1383 |
Initialization vector should be one block size (8 bytes). |
| 1384 |
TdesContext should be already correctly initialized by TdesInit(). Behavior with |
| 1385 |
invalid TDES context is undefined. |
| 1386 |
|
| 1387 |
If TdesContext is NULL, then return FALSE. |
| 1388 |
If Input is NULL, then return FALSE. |
| 1389 |
If InputSize is not multiple of block size (8 bytes), then return FALSE. |
| 1390 |
If Ivec is NULL, then return FALSE. |
| 1391 |
If Output is NULL, then return FALSE. |
| 1392 |
If this interface is not supported, then return FALSE. |
| 1393 |
|
| 1394 |
@param[in] TdesContext Pointer to the TDES context. |
| 1395 |
@param[in] Input Pointer to the buffer containing the data to be encrypted. |
| 1396 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1397 |
@param[in] Ivec Pointer to initialization vector. |
| 1398 |
@param[out] Output Pointer to a buffer that receives the TDES encryption output. |
| 1399 |
|
| 1400 |
@retval TRUE TDES encryption succeeded. |
| 1401 |
@retval FALSE TDES encryption failed. |
| 1402 |
@retval FALSE This interface is not supported. |
| 1403 |
|
| 1404 |
**/ |
| 1405 |
BOOLEAN |
| 1406 |
EFIAPI |
| 1407 |
TdesCbcEncrypt ( |
| 1408 |
IN VOID *TdesContext, |
| 1409 |
IN CONST UINT8 *Input, |
| 1410 |
IN UINTN InputSize, |
| 1411 |
IN CONST UINT8 *Ivec, |
| 1412 |
OUT UINT8 *Output |
| 1413 |
); |
| 1414 |
|
| 1415 |
/** |
| 1416 |
Performs TDES decryption on a data buffer of the specified size in CBC mode. |
| 1417 |
|
| 1418 |
This function performs TDES decryption on data buffer pointed by Input, of specified |
| 1419 |
size of InputSize, in CBC mode. |
| 1420 |
InputSize must be multiple of block size (8 bytes). This function does not perform |
| 1421 |
padding. Caller must perform padding, if necessary, to ensure valid input data size. |
| 1422 |
Initialization vector should be one block size (8 bytes). |
| 1423 |
TdesContext should be already correctly initialized by TdesInit(). Behavior with |
| 1424 |
invalid TDES context is undefined. |
| 1425 |
|
| 1426 |
If TdesContext is NULL, then return FALSE. |
| 1427 |
If Input is NULL, then return FALSE. |
| 1428 |
If InputSize is not multiple of block size (8 bytes), then return FALSE. |
| 1429 |
If Ivec is NULL, then return FALSE. |
| 1430 |
If Output is NULL, then return FALSE. |
| 1431 |
If this interface is not supported, then return FALSE. |
| 1432 |
|
| 1433 |
@param[in] TdesContext Pointer to the TDES context. |
| 1434 |
@param[in] Input Pointer to the buffer containing the data to be encrypted. |
| 1435 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1436 |
@param[in] Ivec Pointer to initialization vector. |
| 1437 |
@param[out] Output Pointer to a buffer that receives the TDES encryption output. |
| 1438 |
|
| 1439 |
@retval TRUE TDES decryption succeeded. |
| 1440 |
@retval FALSE TDES decryption failed. |
| 1441 |
@retval FALSE This interface is not supported. |
| 1442 |
|
| 1443 |
**/ |
| 1444 |
BOOLEAN |
| 1445 |
EFIAPI |
| 1446 |
TdesCbcDecrypt ( |
| 1447 |
IN VOID *TdesContext, |
| 1448 |
IN CONST UINT8 *Input, |
| 1449 |
IN UINTN InputSize, |
| 1450 |
IN CONST UINT8 *Ivec, |
| 1451 |
OUT UINT8 *Output |
| 1452 |
); |
| 1453 |
|
| 1454 |
/** |
| 1455 |
Retrieves the size, in bytes, of the context buffer required for AES operations. |
| 1456 |
|
| 1457 |
If this interface is not supported, then return zero. |
| 1458 |
|
| 1459 |
@return The size, in bytes, of the context buffer required for AES operations. |
| 1460 |
@retval 0 This interface is not supported. |
| 1461 |
|
| 1462 |
**/ |
| 1463 |
UINTN |
| 1464 |
EFIAPI |
| 1465 |
AesGetContextSize ( |
| 1466 |
VOID |
| 1467 |
); |
| 1468 |
|
| 1469 |
/** |
| 1470 |
Initializes user-supplied memory as AES context for subsequent use. |
| 1471 |
|
| 1472 |
This function initializes user-supplied memory pointed by AesContext as AES context. |
| 1473 |
In addition, it sets up all AES key materials for subsequent encryption and decryption |
| 1474 |
operations. |
| 1475 |
There are 3 options for key length, 128 bits, 192 bits, and 256 bits. |
| 1476 |
|
| 1477 |
If AesContext is NULL, then return FALSE. |
| 1478 |
If Key is NULL, then return FALSE. |
| 1479 |
If KeyLength is not valid, then return FALSE. |
| 1480 |
If this interface is not supported, then return FALSE. |
| 1481 |
|
| 1482 |
@param[out] AesContext Pointer to AES context being initialized. |
| 1483 |
@param[in] Key Pointer to the user-supplied AES key. |
| 1484 |
@param[in] KeyLength Length of AES key in bits. |
| 1485 |
|
| 1486 |
@retval TRUE AES context initialization succeeded. |
| 1487 |
@retval FALSE AES context initialization failed. |
| 1488 |
@retval FALSE This interface is not supported. |
| 1489 |
|
| 1490 |
**/ |
| 1491 |
BOOLEAN |
| 1492 |
EFIAPI |
| 1493 |
AesInit ( |
| 1494 |
OUT VOID *AesContext, |
| 1495 |
IN CONST UINT8 *Key, |
| 1496 |
IN UINTN KeyLength |
| 1497 |
); |
| 1498 |
|
| 1499 |
/** |
| 1500 |
Performs AES encryption on a data buffer of the specified size in ECB mode. |
| 1501 |
|
| 1502 |
This function performs AES encryption on data buffer pointed by Input, of specified |
| 1503 |
size of InputSize, in ECB mode. |
| 1504 |
InputSize must be multiple of block size (16 bytes). This function does not perform |
| 1505 |
padding. Caller must perform padding, if necessary, to ensure valid input data size. |
| 1506 |
AesContext should be already correctly initialized by AesInit(). Behavior with |
| 1507 |
invalid AES context is undefined. |
| 1508 |
|
| 1509 |
If AesContext is NULL, then return FALSE. |
| 1510 |
If Input is NULL, then return FALSE. |
| 1511 |
If InputSize is not multiple of block size (16 bytes), then return FALSE. |
| 1512 |
If Output is NULL, then return FALSE. |
| 1513 |
If this interface is not supported, then return FALSE. |
| 1514 |
|
| 1515 |
@param[in] AesContext Pointer to the AES context. |
| 1516 |
@param[in] Input Pointer to the buffer containing the data to be encrypted. |
| 1517 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1518 |
@param[out] Output Pointer to a buffer that receives the AES encryption output. |
| 1519 |
|
| 1520 |
@retval TRUE AES encryption succeeded. |
| 1521 |
@retval FALSE AES encryption failed. |
| 1522 |
@retval FALSE This interface is not supported. |
| 1523 |
|
| 1524 |
**/ |
| 1525 |
BOOLEAN |
| 1526 |
EFIAPI |
| 1527 |
AesEcbEncrypt ( |
| 1528 |
IN VOID *AesContext, |
| 1529 |
IN CONST UINT8 *Input, |
| 1530 |
IN UINTN InputSize, |
| 1531 |
OUT UINT8 *Output |
| 1532 |
); |
| 1533 |
|
| 1534 |
/** |
| 1535 |
Performs AES decryption on a data buffer of the specified size in ECB mode. |
| 1536 |
|
| 1537 |
This function performs AES decryption on data buffer pointed by Input, of specified |
| 1538 |
size of InputSize, in ECB mode. |
| 1539 |
InputSize must be multiple of block size (16 bytes). This function does not perform |
| 1540 |
padding. Caller must perform padding, if necessary, to ensure valid input data size. |
| 1541 |
AesContext should be already correctly initialized by AesInit(). Behavior with |
| 1542 |
invalid AES context is undefined. |
| 1543 |
|
| 1544 |
If AesContext is NULL, then return FALSE. |
| 1545 |
If Input is NULL, then return FALSE. |
| 1546 |
If InputSize is not multiple of block size (16 bytes), then return FALSE. |
| 1547 |
If Output is NULL, then return FALSE. |
| 1548 |
If this interface is not supported, then return FALSE. |
| 1549 |
|
| 1550 |
@param[in] AesContext Pointer to the AES context. |
| 1551 |
@param[in] Input Pointer to the buffer containing the data to be decrypted. |
| 1552 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1553 |
@param[out] Output Pointer to a buffer that receives the AES decryption output. |
| 1554 |
|
| 1555 |
@retval TRUE AES decryption succeeded. |
| 1556 |
@retval FALSE AES decryption failed. |
| 1557 |
@retval FALSE This interface is not supported. |
| 1558 |
|
| 1559 |
**/ |
| 1560 |
BOOLEAN |
| 1561 |
EFIAPI |
| 1562 |
AesEcbDecrypt ( |
| 1563 |
IN VOID *AesContext, |
| 1564 |
IN CONST UINT8 *Input, |
| 1565 |
IN UINTN InputSize, |
| 1566 |
OUT UINT8 *Output |
| 1567 |
); |
| 1568 |
|
| 1569 |
/** |
| 1570 |
Performs AES encryption on a data buffer of the specified size in CBC mode. |
| 1571 |
|
| 1572 |
This function performs AES encryption on data buffer pointed by Input, of specified |
| 1573 |
size of InputSize, in CBC mode. |
| 1574 |
InputSize must be multiple of block size (16 bytes). This function does not perform |
| 1575 |
padding. Caller must perform padding, if necessary, to ensure valid input data size. |
| 1576 |
Initialization vector should be one block size (16 bytes). |
| 1577 |
AesContext should be already correctly initialized by AesInit(). Behavior with |
| 1578 |
invalid AES context is undefined. |
| 1579 |
|
| 1580 |
If AesContext is NULL, then return FALSE. |
| 1581 |
If Input is NULL, then return FALSE. |
| 1582 |
If InputSize is not multiple of block size (16 bytes), then return FALSE. |
| 1583 |
If Ivec is NULL, then return FALSE. |
| 1584 |
If Output is NULL, then return FALSE. |
| 1585 |
If this interface is not supported, then return FALSE. |
| 1586 |
|
| 1587 |
@param[in] AesContext Pointer to the AES context. |
| 1588 |
@param[in] Input Pointer to the buffer containing the data to be encrypted. |
| 1589 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1590 |
@param[in] Ivec Pointer to initialization vector. |
| 1591 |
@param[out] Output Pointer to a buffer that receives the AES encryption output. |
| 1592 |
|
| 1593 |
@retval TRUE AES encryption succeeded. |
| 1594 |
@retval FALSE AES encryption failed. |
| 1595 |
@retval FALSE This interface is not supported. |
| 1596 |
|
| 1597 |
**/ |
| 1598 |
BOOLEAN |
| 1599 |
EFIAPI |
| 1600 |
AesCbcEncrypt ( |
| 1601 |
IN VOID *AesContext, |
| 1602 |
IN CONST UINT8 *Input, |
| 1603 |
IN UINTN InputSize, |
| 1604 |
IN CONST UINT8 *Ivec, |
| 1605 |
OUT UINT8 *Output |
| 1606 |
); |
| 1607 |
|
| 1608 |
/** |
| 1609 |
Performs AES decryption on a data buffer of the specified size in CBC mode. |
| 1610 |
|
| 1611 |
This function performs AES decryption on data buffer pointed by Input, of specified |
| 1612 |
size of InputSize, in CBC mode. |
| 1613 |
InputSize must be multiple of block size (16 bytes). This function does not perform |
| 1614 |
padding. Caller must perform padding, if necessary, to ensure valid input data size. |
| 1615 |
Initialization vector should be one block size (16 bytes). |
| 1616 |
AesContext should be already correctly initialized by AesInit(). Behavior with |
| 1617 |
invalid AES context is undefined. |
| 1618 |
|
| 1619 |
If AesContext is NULL, then return FALSE. |
| 1620 |
If Input is NULL, then return FALSE. |
| 1621 |
If InputSize is not multiple of block size (16 bytes), then return FALSE. |
| 1622 |
If Ivec is NULL, then return FALSE. |
| 1623 |
If Output is NULL, then return FALSE. |
| 1624 |
If this interface is not supported, then return FALSE. |
| 1625 |
|
| 1626 |
@param[in] AesContext Pointer to the AES context. |
| 1627 |
@param[in] Input Pointer to the buffer containing the data to be encrypted. |
| 1628 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1629 |
@param[in] Ivec Pointer to initialization vector. |
| 1630 |
@param[out] Output Pointer to a buffer that receives the AES encryption output. |
| 1631 |
|
| 1632 |
@retval TRUE AES decryption succeeded. |
| 1633 |
@retval FALSE AES decryption failed. |
| 1634 |
@retval FALSE This interface is not supported. |
| 1635 |
|
| 1636 |
**/ |
| 1637 |
BOOLEAN |
| 1638 |
EFIAPI |
| 1639 |
AesCbcDecrypt ( |
| 1640 |
IN VOID *AesContext, |
| 1641 |
IN CONST UINT8 *Input, |
| 1642 |
IN UINTN InputSize, |
| 1643 |
IN CONST UINT8 *Ivec, |
| 1644 |
OUT UINT8 *Output |
| 1645 |
); |
| 1646 |
|
| 1647 |
/** |
| 1648 |
Retrieves the size, in bytes, of the context buffer required for ARC4 operations. |
| 1649 |
|
| 1650 |
If this interface is not supported, then return zero. |
| 1651 |
|
| 1652 |
@return The size, in bytes, of the context buffer required for ARC4 operations. |
| 1653 |
@retval 0 This interface is not supported. |
| 1654 |
|
| 1655 |
**/ |
| 1656 |
UINTN |
| 1657 |
EFIAPI |
| 1658 |
Arc4GetContextSize ( |
| 1659 |
VOID |
| 1660 |
); |
| 1661 |
|
| 1662 |
/** |
| 1663 |
Initializes user-supplied memory as ARC4 context for subsequent use. |
| 1664 |
|
| 1665 |
This function initializes user-supplied memory pointed by Arc4Context as ARC4 context. |
| 1666 |
In addition, it sets up all ARC4 key materials for subsequent encryption and decryption |
| 1667 |
operations. |
| 1668 |
|
| 1669 |
If Arc4Context is NULL, then return FALSE. |
| 1670 |
If Key is NULL, then return FALSE. |
| 1671 |
If KeySize does not in the range of [5, 256] bytes, then return FALSE. |
| 1672 |
If this interface is not supported, then return FALSE. |
| 1673 |
|
| 1674 |
@param[out] Arc4Context Pointer to ARC4 context being initialized. |
| 1675 |
@param[in] Key Pointer to the user-supplied ARC4 key. |
| 1676 |
@param[in] KeySize Size of ARC4 key in bytes. |
| 1677 |
|
| 1678 |
@retval TRUE ARC4 context initialization succeeded. |
| 1679 |
@retval FALSE ARC4 context initialization failed. |
| 1680 |
@retval FALSE This interface is not supported. |
| 1681 |
|
| 1682 |
**/ |
| 1683 |
BOOLEAN |
| 1684 |
EFIAPI |
| 1685 |
Arc4Init ( |
| 1686 |
OUT VOID *Arc4Context, |
| 1687 |
IN CONST UINT8 *Key, |
| 1688 |
IN UINTN KeySize |
| 1689 |
); |
| 1690 |
|
| 1691 |
/** |
| 1692 |
Performs ARC4 encryption on a data buffer of the specified size. |
| 1693 |
|
| 1694 |
This function performs ARC4 encryption on data buffer pointed by Input, of specified |
| 1695 |
size of InputSize. |
| 1696 |
Arc4Context should be already correctly initialized by Arc4Init(). Behavior with |
| 1697 |
invalid ARC4 context is undefined. |
| 1698 |
|
| 1699 |
If Arc4Context is NULL, then return FALSE. |
| 1700 |
If Input is NULL, then return FALSE. |
| 1701 |
If Output is NULL, then return FALSE. |
| 1702 |
If this interface is not supported, then return FALSE. |
| 1703 |
|
| 1704 |
@param[in] Arc4Context Pointer to the ARC4 context. |
| 1705 |
@param[in] Input Pointer to the buffer containing the data to be encrypted. |
| 1706 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1707 |
@param[out] Output Pointer to a buffer that receives the ARC4 encryption output. |
| 1708 |
|
| 1709 |
@retval TRUE ARC4 encryption succeeded. |
| 1710 |
@retval FALSE ARC4 encryption failed. |
| 1711 |
@retval FALSE This interface is not supported. |
| 1712 |
|
| 1713 |
**/ |
| 1714 |
BOOLEAN |
| 1715 |
EFIAPI |
| 1716 |
Arc4Encrypt ( |
| 1717 |
IN OUT VOID *Arc4Context, |
| 1718 |
IN CONST UINT8 *Input, |
| 1719 |
IN UINTN InputSize, |
| 1720 |
OUT UINT8 *Output |
| 1721 |
); |
| 1722 |
|
| 1723 |
/** |
| 1724 |
Performs ARC4 decryption on a data buffer of the specified size. |
| 1725 |
|
| 1726 |
This function performs ARC4 decryption on data buffer pointed by Input, of specified |
| 1727 |
size of InputSize. |
| 1728 |
Arc4Context should be already correctly initialized by Arc4Init(). Behavior with |
| 1729 |
invalid ARC4 context is undefined. |
| 1730 |
|
| 1731 |
If Arc4Context is NULL, then return FALSE. |
| 1732 |
If Input is NULL, then return FALSE. |
| 1733 |
If Output is NULL, then return FALSE. |
| 1734 |
If this interface is not supported, then return FALSE. |
| 1735 |
|
| 1736 |
@param[in] Arc4Context Pointer to the ARC4 context. |
| 1737 |
@param[in] Input Pointer to the buffer containing the data to be decrypted. |
| 1738 |
@param[in] InputSize Size of the Input buffer in bytes. |
| 1739 |
@param[out] Output Pointer to a buffer that receives the ARC4 decryption output. |
| 1740 |
|
| 1741 |
@retval TRUE ARC4 decryption succeeded. |
| 1742 |
@retval FALSE ARC4 decryption failed. |
| 1743 |
@retval FALSE This interface is not supported. |
| 1744 |
|
| 1745 |
**/ |
| 1746 |
BOOLEAN |
| 1747 |
EFIAPI |
| 1748 |
Arc4Decrypt ( |
| 1749 |
IN OUT VOID *Arc4Context, |
| 1750 |
IN UINT8 *Input, |
| 1751 |
IN UINTN InputSize, |
| 1752 |
OUT UINT8 *Output |
| 1753 |
); |
| 1754 |
|
| 1755 |
/** |
| 1756 |
Resets the ARC4 context to the initial state. |
| 1757 |
|
| 1758 |
The function resets the ARC4 context to the state it had immediately after the |
| 1759 |
ARC4Init() function call. |
| 1760 |
Contrary to ARC4Init(), Arc4Reset() requires no secret key as input, but ARC4 context |
| 1761 |
should be already correctly initialized by ARC4Init(). |
| 1762 |
|
| 1763 |
If Arc4Context is NULL, then return FALSE. |
| 1764 |
If this interface is not supported, then return FALSE. |
| 1765 |
|
| 1766 |
@param[in, out] Arc4Context Pointer to the ARC4 context. |
| 1767 |
|
| 1768 |
@retval TRUE ARC4 reset succeeded. |
| 1769 |
@retval FALSE ARC4 reset failed. |
| 1770 |
@retval FALSE This interface is not supported. |
| 1771 |
|
| 1772 |
**/ |
| 1773 |
BOOLEAN |
| 1774 |
EFIAPI |
| 1775 |
Arc4Reset ( |
| 1776 |
IN OUT VOID *Arc4Context |
| 1777 |
); |
| 1778 |
|
| 1779 |
//===================================================================================== |
| 1780 |
// Asymmetric Cryptography Primitive |
| 1781 |
//===================================================================================== |
| 1782 |
|
| 1783 |
/** |
| 1784 |
Allocates and initializes one RSA context for subsequent use. |
| 1785 |
|
| 1786 |
@return Pointer to the RSA context that has been initialized. |
| 1787 |
If the allocations fails, RsaNew() returns NULL. |
| 1788 |
|
| 1789 |
**/ |
| 1790 |
VOID * |
| 1791 |
EFIAPI |
| 1792 |
RsaNew ( |
| 1793 |
VOID |
| 1794 |
); |
| 1795 |
|
| 1796 |
/** |
| 1797 |
Release the specified RSA context. |
| 1798 |
|
| 1799 |
If RsaContext is NULL, then return FALSE. |
| 1800 |
|
| 1801 |
@param[in] RsaContext Pointer to the RSA context to be released. |
| 1802 |
|
| 1803 |
**/ |
| 1804 |
VOID |
| 1805 |
EFIAPI |
| 1806 |
RsaFree ( |
| 1807 |
IN VOID *RsaContext |
| 1808 |
); |
| 1809 |
|
| 1810 |
/** |
| 1811 |
Sets the tag-designated key component into the established RSA context. |
| 1812 |
|
| 1813 |
This function sets the tag-designated RSA key component into the established |
| 1814 |
RSA context from the user-specified non-negative integer (octet string format |
| 1815 |
represented in RSA PKCS#1). |
| 1816 |
If BigNumber is NULL, then the specified key component in RSA context is cleared. |
| 1817 |
|
| 1818 |
If RsaContext is NULL, then return FALSE. |
| 1819 |
|
| 1820 |
@param[in, out] RsaContext Pointer to RSA context being set. |
| 1821 |
@param[in] KeyTag Tag of RSA key component being set. |
| 1822 |
@param[in] BigNumber Pointer to octet integer buffer. |
| 1823 |
If NULL, then the specified key component in RSA |
| 1824 |
context is cleared. |
| 1825 |
@param[in] BnSize Size of big number buffer in bytes. |
| 1826 |
If BigNumber is NULL, then it is ignored. |
| 1827 |
|
| 1828 |
@retval TRUE RSA key component was set successfully. |
| 1829 |
@retval FALSE Invalid RSA key component tag. |
| 1830 |
|
| 1831 |
**/ |
| 1832 |
BOOLEAN |
| 1833 |
EFIAPI |
| 1834 |
RsaSetKey ( |
| 1835 |
IN OUT VOID *RsaContext, |
| 1836 |
IN RSA_KEY_TAG KeyTag, |
| 1837 |
IN CONST UINT8 *BigNumber, |
| 1838 |
IN UINTN BnSize |
| 1839 |
); |
| 1840 |
|
| 1841 |
/** |
| 1842 |
Gets the tag-designated RSA key component from the established RSA context. |
| 1843 |
|
| 1844 |
This function retrieves the tag-designated RSA key component from the |
| 1845 |
established RSA context as a non-negative integer (octet string format |
| 1846 |
represented in RSA PKCS#1). |
| 1847 |
If specified key component has not been set or has been cleared, then returned |
| 1848 |
BnSize is set to 0. |
| 1849 |
If the BigNumber buffer is too small to hold the contents of the key, FALSE |
| 1850 |
is returned and BnSize is set to the required buffer size to obtain the key. |
| 1851 |
|
| 1852 |
If RsaContext is NULL, then return FALSE. |
| 1853 |
If BnSize is NULL, then return FALSE. |
| 1854 |
If BnSize is large enough but BigNumber is NULL, then return FALSE. |
| 1855 |
If this interface is not supported, then return FALSE. |
| 1856 |
|
| 1857 |
@param[in, out] RsaContext Pointer to RSA context being set. |
| 1858 |
@param[in] KeyTag Tag of RSA key component being set. |
| 1859 |
@param[out] BigNumber Pointer to octet integer buffer. |
| 1860 |
@param[in, out] BnSize On input, the size of big number buffer in bytes. |
| 1861 |
On output, the size of data returned in big number buffer in bytes. |
| 1862 |
|
| 1863 |
@retval TRUE RSA key component was retrieved successfully. |
| 1864 |
@retval FALSE Invalid RSA key component tag. |
| 1865 |
@retval FALSE BnSize is too small. |
| 1866 |
@retval FALSE This interface is not supported. |
| 1867 |
|
| 1868 |
**/ |
| 1869 |
BOOLEAN |
| 1870 |
EFIAPI |
| 1871 |
RsaGetKey ( |
| 1872 |
IN OUT VOID *RsaContext, |
| 1873 |
IN RSA_KEY_TAG KeyTag, |
| 1874 |
OUT UINT8 *BigNumber, |
| 1875 |
IN OUT UINTN *BnSize |
| 1876 |
); |
| 1877 |
|
| 1878 |
/** |
| 1879 |
Generates RSA key components. |
| 1880 |
|
| 1881 |
This function generates RSA key components. It takes RSA public exponent E and |
| 1882 |
length in bits of RSA modulus N as input, and generates all key components. |
| 1883 |
If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used. |
| 1884 |
|
| 1885 |
Before this function can be invoked, pseudorandom number generator must be correctly |
| 1886 |
initialized by RandomSeed(). |
| 1887 |
|
| 1888 |
If RsaContext is NULL, then return FALSE. |
| 1889 |
If this interface is not supported, then return FALSE. |
| 1890 |
|
| 1891 |
@param[in, out] RsaContext Pointer to RSA context being set. |
| 1892 |
@param[in] ModulusLength Length of RSA modulus N in bits. |
| 1893 |
@param[in] PublicExponent Pointer to RSA public exponent. |
| 1894 |
@param[in] PublicExponentSize Size of RSA public exponent buffer in bytes. |
| 1895 |
|
| 1896 |
@retval TRUE RSA key component was generated successfully. |
| 1897 |
@retval FALSE Invalid RSA key component tag. |
| 1898 |
@retval FALSE This interface is not supported. |
| 1899 |
|
| 1900 |
**/ |
| 1901 |
BOOLEAN |
| 1902 |
EFIAPI |
| 1903 |
RsaGenerateKey ( |
| 1904 |
IN OUT VOID *RsaContext, |
| 1905 |
IN UINTN ModulusLength, |
| 1906 |
IN CONST UINT8 *PublicExponent, |
| 1907 |
IN UINTN PublicExponentSize |
| 1908 |
); |
| 1909 |
|
| 1910 |
/** |
| 1911 |
Validates key components of RSA context. |
| 1912 |
NOTE: This function performs integrity checks on all the RSA key material, so |
| 1913 |
the RSA key structure must contain all the private key data. |
| 1914 |
|
| 1915 |
This function validates key components of RSA context in following aspects: |
| 1916 |
- Whether p is a prime |
| 1917 |
- Whether q is a prime |
| 1918 |
- Whether n = p * q |
| 1919 |
- Whether d*e = 1 mod lcm(p-1,q-1) |
| 1920 |
|
| 1921 |
If RsaContext is NULL, then return FALSE. |
| 1922 |
If this interface is not supported, then return FALSE. |
| 1923 |
|
| 1924 |
@param[in] RsaContext Pointer to RSA context to check. |
| 1925 |
|
| 1926 |
@retval TRUE RSA key components are valid. |
| 1927 |
@retval FALSE RSA key components are not valid. |
| 1928 |
@retval FALSE This interface is not supported. |
| 1929 |
|
| 1930 |
**/ |
| 1931 |
BOOLEAN |
| 1932 |
EFIAPI |
| 1933 |
RsaCheckKey ( |
| 1934 |
IN VOID *RsaContext |
| 1935 |
); |
| 1936 |
|
| 1937 |
/** |
| 1938 |
Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme. |
| 1939 |
|
| 1940 |
This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in |
| 1941 |
RSA PKCS#1. |
| 1942 |
If the Signature buffer is too small to hold the contents of signature, FALSE |
| 1943 |
is returned and SigSize is set to the required buffer size to obtain the signature. |
| 1944 |
|
| 1945 |
If RsaContext is NULL, then return FALSE. |
| 1946 |
If MessageHash is NULL, then return FALSE. |
| 1947 |
If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE. |
| 1948 |
If SigSize is large enough but Signature is NULL, then return FALSE. |
| 1949 |
If this interface is not supported, then return FALSE. |
| 1950 |
|
| 1951 |
@param[in] RsaContext Pointer to RSA context for signature generation. |
| 1952 |
@param[in] MessageHash Pointer to octet message hash to be signed. |
| 1953 |
@param[in] HashSize Size of the message hash in bytes. |
| 1954 |
@param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature. |
| 1955 |
@param[in, out] SigSize On input, the size of Signature buffer in bytes. |
| 1956 |
On output, the size of data returned in Signature buffer in bytes. |
| 1957 |
|
| 1958 |
@retval TRUE Signature successfully generated in PKCS1-v1_5. |
| 1959 |
@retval FALSE Signature generation failed. |
| 1960 |
@retval FALSE SigSize is too small. |
| 1961 |
@retval FALSE This interface is not supported. |
| 1962 |
|
| 1963 |
**/ |
| 1964 |
BOOLEAN |
| 1965 |
EFIAPI |
| 1966 |
RsaPkcs1Sign ( |
| 1967 |
IN VOID *RsaContext, |
| 1968 |
IN CONST UINT8 *MessageHash, |
| 1969 |
IN UINTN HashSize, |
| 1970 |
OUT UINT8 *Signature, |
| 1971 |
IN OUT UINTN *SigSize |
| 1972 |
); |
| 1973 |
|
| 1974 |
/** |
| 1975 |
Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in |
| 1976 |
RSA PKCS#1. |
| 1977 |
|
| 1978 |
If RsaContext is NULL, then return FALSE. |
| 1979 |
If MessageHash is NULL, then return FALSE. |
| 1980 |
If Signature is NULL, then return FALSE. |
| 1981 |
If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE. |
| 1982 |
|
| 1983 |
@param[in] RsaContext Pointer to RSA context for signature verification. |
| 1984 |
@param[in] MessageHash Pointer to octet message hash to be checked. |
| 1985 |
@param[in] HashSize Size of the message hash in bytes. |
| 1986 |
@param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified. |
| 1987 |
@param[in] SigSize Size of signature in bytes. |
| 1988 |
|
| 1989 |
@retval TRUE Valid signature encoded in PKCS1-v1_5. |
| 1990 |
@retval FALSE Invalid signature or invalid RSA context. |
| 1991 |
|
| 1992 |
**/ |
| 1993 |
BOOLEAN |
| 1994 |
EFIAPI |
| 1995 |
RsaPkcs1Verify ( |
| 1996 |
IN VOID *RsaContext, |
| 1997 |
IN CONST UINT8 *MessageHash, |
| 1998 |
IN UINTN HashSize, |
| 1999 |
IN CONST UINT8 *Signature, |
| 2000 |
IN UINTN SigSize |
| 2001 |
); |
| 2002 |
|
| 2003 |
/** |
| 2004 |
Retrieve the RSA Private Key from the password-protected PEM key data. |
| 2005 |
|
| 2006 |
If PemData is NULL, then return FALSE. |
| 2007 |
If RsaContext is NULL, then return FALSE. |
| 2008 |
If this interface is not supported, then return FALSE. |
| 2009 |
|
| 2010 |
@param[in] PemData Pointer to the PEM-encoded key data to be retrieved. |
| 2011 |
@param[in] PemSize Size of the PEM key data in bytes. |
| 2012 |
@param[in] Password NULL-terminated passphrase used for encrypted PEM key data. |
| 2013 |
@param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved |
| 2014 |
RSA private key component. Use RsaFree() function to free the |
| 2015 |
resource. |
| 2016 |
|
| 2017 |
@retval TRUE RSA Private Key was retrieved successfully. |
| 2018 |
@retval FALSE Invalid PEM key data or incorrect password. |
| 2019 |
@retval FALSE This interface is not supported. |
| 2020 |
|
| 2021 |
**/ |
| 2022 |
BOOLEAN |
| 2023 |
EFIAPI |
| 2024 |
RsaGetPrivateKeyFromPem ( |
| 2025 |
IN CONST UINT8 *PemData, |
| 2026 |
IN UINTN PemSize, |
| 2027 |
IN CONST CHAR8 *Password, |
| 2028 |
OUT VOID **RsaContext |
| 2029 |
); |
| 2030 |
|
| 2031 |
/** |
| 2032 |
Retrieve the RSA Public Key from one DER-encoded X509 certificate. |
| 2033 |
|
| 2034 |
If Cert is NULL, then return FALSE. |
| 2035 |
If RsaContext is NULL, then return FALSE. |
| 2036 |
If this interface is not supported, then return FALSE. |
| 2037 |
|
| 2038 |
@param[in] Cert Pointer to the DER-encoded X509 certificate. |
| 2039 |
@param[in] CertSize Size of the X509 certificate in bytes. |
| 2040 |
@param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved |
| 2041 |
RSA public key component. Use RsaFree() function to free the |
| 2042 |
resource. |
| 2043 |
|
| 2044 |
@retval TRUE RSA Public Key was retrieved successfully. |
| 2045 |
@retval FALSE Fail to retrieve RSA public key from X509 certificate. |
| 2046 |
@retval FALSE This interface is not supported. |
| 2047 |
|
| 2048 |
**/ |
| 2049 |
BOOLEAN |
| 2050 |
EFIAPI |
| 2051 |
RsaGetPublicKeyFromX509 ( |
| 2052 |
IN CONST UINT8 *Cert, |
| 2053 |
IN UINTN CertSize, |
| 2054 |
OUT VOID **RsaContext |
| 2055 |
); |
| 2056 |
|
| 2057 |
/** |
| 2058 |
Retrieve the subject bytes from one X.509 certificate. |
| 2059 |
|
| 2060 |
If Cert is NULL, then return FALSE. |
| 2061 |
If SubjectSize is NULL, then return FALSE. |
| 2062 |
If this interface is not supported, then return FALSE. |
| 2063 |
|
| 2064 |
@param[in] Cert Pointer to the DER-encoded X509 certificate. |
| 2065 |
@param[in] CertSize Size of the X509 certificate in bytes. |
| 2066 |
@param[out] CertSubject Pointer to the retrieved certificate subject bytes. |
| 2067 |
@param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input, |
| 2068 |
and the size of buffer returned CertSubject on output. |
| 2069 |
|
| 2070 |
@retval TRUE The certificate subject retrieved successfully. |
| 2071 |
@retval FALSE Invalid certificate, or the SubjectSize is too small for the result. |
| 2072 |
The SubjectSize will be updated with the required size. |
| 2073 |
@retval FALSE This interface is not supported. |
| 2074 |
|
| 2075 |
**/ |
| 2076 |
BOOLEAN |
| 2077 |
EFIAPI |
| 2078 |
X509GetSubjectName ( |
| 2079 |
IN CONST UINT8 *Cert, |
| 2080 |
IN UINTN CertSize, |
| 2081 |
OUT UINT8 *CertSubject, |
| 2082 |
IN OUT UINTN *SubjectSize |
| 2083 |
); |
| 2084 |
|
| 2085 |
/** |
| 2086 |
Verify one X509 certificate was issued by the trusted CA. |
| 2087 |
|
| 2088 |
If Cert is NULL, then return FALSE. |
| 2089 |
If CACert is NULL, then return FALSE. |
| 2090 |
If this interface is not supported, then return FALSE. |
| 2091 |
|
| 2092 |
@param[in] Cert Pointer to the DER-encoded X509 certificate to be verified. |
| 2093 |
@param[in] CertSize Size of the X509 certificate in bytes. |
| 2094 |
@param[in] CACert Pointer to the DER-encoded trusted CA certificate. |
| 2095 |
@param[in] CACertSize Size of the CA Certificate in bytes. |
| 2096 |
|
| 2097 |
@retval TRUE The certificate was issued by the trusted CA. |
| 2098 |
@retval FALSE Invalid certificate or the certificate was not issued by the given |
| 2099 |
trusted CA. |
| 2100 |
@retval FALSE This interface is not supported. |
| 2101 |
|
| 2102 |
**/ |
| 2103 |
BOOLEAN |
| 2104 |
EFIAPI |
| 2105 |
X509VerifyCert ( |
| 2106 |
IN CONST UINT8 *Cert, |
| 2107 |
IN UINTN CertSize, |
| 2108 |
IN CONST UINT8 *CACert, |
| 2109 |
IN UINTN CACertSize |
| 2110 |
); |
| 2111 |
|
| 2112 |
/** |
| 2113 |
Construct a X509 object from DER-encoded certificate data. |
| 2114 |
|
| 2115 |
If Cert is NULL, then return FALSE. |
| 2116 |
If SingleX509Cert is NULL, then return FALSE. |
| 2117 |
If this interface is not supported, then return FALSE. |
| 2118 |
|
| 2119 |
@param[in] Cert Pointer to the DER-encoded certificate data. |
| 2120 |
@param[in] CertSize The size of certificate data in bytes. |
| 2121 |
@param[out] SingleX509Cert The generated X509 object. |
| 2122 |
|
| 2123 |
@retval TRUE The X509 object generation succeeded. |
| 2124 |
@retval FALSE The operation failed. |
| 2125 |
@retval FALSE This interface is not supported. |
| 2126 |
|
| 2127 |
**/ |
| 2128 |
BOOLEAN |
| 2129 |
EFIAPI |
| 2130 |
X509ConstructCertificate ( |
| 2131 |
IN CONST UINT8 *Cert, |
| 2132 |
IN UINTN CertSize, |
| 2133 |
OUT UINT8 **SingleX509Cert |
| 2134 |
); |
| 2135 |
|
| 2136 |
/** |
| 2137 |
Construct a X509 stack object from a list of DER-encoded certificate data. |
| 2138 |
|
| 2139 |
If X509Stack is NULL, then return FALSE. |
| 2140 |
If this interface is not supported, then return FALSE. |
| 2141 |
|
| 2142 |
@param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object. |
| 2143 |
On output, pointer to the X509 stack object with new |
| 2144 |
inserted X509 certificate. |
| 2145 |
@param ... A list of DER-encoded single certificate data followed |
| 2146 |
by certificate size. A NULL terminates the list. The |
| 2147 |
pairs are the arguments to X509ConstructCertificate(). |
| 2148 |
|
| 2149 |
@retval TRUE The X509 stack construction succeeded. |
| 2150 |
@retval FALSE The construction operation failed. |
| 2151 |
@retval FALSE This interface is not supported. |
| 2152 |
|
| 2153 |
**/ |
| 2154 |
BOOLEAN |
| 2155 |
EFIAPI |
| 2156 |
X509ConstructCertificateStack ( |
| 2157 |
IN OUT UINT8 **X509Stack, |
| 2158 |
... |
| 2159 |
); |
| 2160 |
|
| 2161 |
/** |
| 2162 |
Release the specified X509 object. |
| 2163 |
|
| 2164 |
If the interface is not supported, then ASSERT(). |
| 2165 |
|
| 2166 |
@param[in] X509Cert Pointer to the X509 object to be released. |
| 2167 |
|
| 2168 |
**/ |
| 2169 |
VOID |
| 2170 |
EFIAPI |
| 2171 |
X509Free ( |
| 2172 |
IN VOID *X509Cert |
| 2173 |
); |
| 2174 |
|
| 2175 |
/** |
| 2176 |
Release the specified X509 stack object. |
| 2177 |
|
| 2178 |
If the interface is not supported, then ASSERT(). |
| 2179 |
|
| 2180 |
@param[in] X509Stack Pointer to the X509 stack object to be released. |
| 2181 |
|
| 2182 |
**/ |
| 2183 |
VOID |
| 2184 |
EFIAPI |
| 2185 |
X509StackFree ( |
| 2186 |
IN VOID *X509Stack |
| 2187 |
); |
| 2188 |
|
| 2189 |
/** |
| 2190 |
Retrieve the TBSCertificate from one given X.509 certificate. |
| 2191 |
|
| 2192 |
@param[in] Cert Pointer to the given DER-encoded X509 certificate. |
| 2193 |
@param[in] CertSize Size of the X509 certificate in bytes. |
| 2194 |
@param[out] TBSCert DER-Encoded To-Be-Signed certificate. |
| 2195 |
@param[out] TBSCertSize Size of the TBS certificate in bytes. |
| 2196 |
|
| 2197 |
If Cert is NULL, then return FALSE. |
| 2198 |
If TBSCert is NULL, then return FALSE. |
| 2199 |
If TBSCertSize is NULL, then return FALSE. |
| 2200 |
If this interface is not supported, then return FALSE. |
| 2201 |
|
| 2202 |
@retval TRUE The TBSCertificate was retrieved successfully. |
| 2203 |
@retval FALSE Invalid X.509 certificate. |
| 2204 |
|
| 2205 |
**/ |
| 2206 |
BOOLEAN |
| 2207 |
EFIAPI |
| 2208 |
X509GetTBSCert ( |
| 2209 |
IN CONST UINT8 *Cert, |
| 2210 |
IN UINTN CertSize, |
| 2211 |
OUT UINT8 **TBSCert, |
| 2212 |
OUT UINTN *TBSCertSize |
| 2213 |
); |
| 2214 |
|
| 2215 |
/** |
| 2216 |
Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0 |
| 2217 |
password based encryption key derivation function PBKDF2, as specified in RFC 2898. |
| 2218 |
|
| 2219 |
If Password or Salt or OutKey is NULL, then return FALSE. |
| 2220 |
If the hash algorithm could not be determined, then return FALSE. |
| 2221 |
If this interface is not supported, then return FALSE. |
| 2222 |
|
| 2223 |
@param[in] PasswordLength Length of input password in bytes. |
| 2224 |
@param[in] Password Pointer to the array for the password. |
| 2225 |
@param[in] SaltLength Size of the Salt in bytes. |
| 2226 |
@param[in] Salt Pointer to the Salt. |
| 2227 |
@param[in] IterationCount Number of iterations to perform. Its value should be |
| 2228 |
greater than or equal to 1. |
| 2229 |
@param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE). |
| 2230 |
NOTE: DigestSize will be used to determine the hash algorithm. |
| 2231 |
Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported. |
| 2232 |
@param[in] KeyLength Size of the derived key buffer in bytes. |
| 2233 |
@param[out] OutKey Pointer to the output derived key buffer. |
| 2234 |
|
| 2235 |
@retval TRUE A key was derived successfully. |
| 2236 |
@retval FALSE One of the pointers was NULL or one of the sizes was too large. |
| 2237 |
@retval FALSE The hash algorithm could not be determined from the digest size. |
| 2238 |
@retval FALSE The key derivation operation failed. |
| 2239 |
@retval FALSE This interface is not supported. |
| 2240 |
|
| 2241 |
**/ |
| 2242 |
BOOLEAN |
| 2243 |
EFIAPI |
| 2244 |
Pkcs5HashPassword ( |
| 2245 |
IN UINTN PasswordLength, |
| 2246 |
IN CONST CHAR8 *Password, |
| 2247 |
IN UINTN SaltLength, |
| 2248 |
IN CONST UINT8 *Salt, |
| 2249 |
IN UINTN IterationCount, |
| 2250 |
IN UINTN DigestSize, |
| 2251 |
IN UINTN KeyLength, |
| 2252 |
OUT UINT8 *OutKey |
| 2253 |
); |
| 2254 |
|
| 2255 |
/** |
| 2256 |
Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7: |
| 2257 |
Cryptographic Message Syntax Standard". The input signed data could be wrapped |
| 2258 |
in a ContentInfo structure. |
| 2259 |
|
| 2260 |
If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then |
| 2261 |
return FALSE. If P7Length overflow, then return FALSE. |
| 2262 |
If this interface is not supported, then return FALSE. |
| 2263 |
|
| 2264 |
@param[in] P7Data Pointer to the PKCS#7 message to verify. |
| 2265 |
@param[in] P7Length Length of the PKCS#7 message in bytes. |
| 2266 |
@param[out] CertStack Pointer to Signer's certificates retrieved from P7Data. |
| 2267 |
It's caller's responsibility to free the buffer. |
| 2268 |
@param[out] StackLength Length of signer's certificates in bytes. |
| 2269 |
@param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates. |
| 2270 |
It's caller's responsibility to free the buffer. |
| 2271 |
@param[out] CertLength Length of the trusted certificate in bytes. |
| 2272 |
|
| 2273 |
@retval TRUE The operation is finished successfully. |
| 2274 |
@retval FALSE Error occurs during the operation. |
| 2275 |
@retval FALSE This interface is not supported. |
| 2276 |
|
| 2277 |
**/ |
| 2278 |
BOOLEAN |
| 2279 |
EFIAPI |
| 2280 |
Pkcs7GetSigners ( |
| 2281 |
IN CONST UINT8 *P7Data, |
| 2282 |
IN UINTN P7Length, |
| 2283 |
OUT UINT8 **CertStack, |
| 2284 |
OUT UINTN *StackLength, |
| 2285 |
OUT UINT8 **TrustedCert, |
| 2286 |
OUT UINTN *CertLength |
| 2287 |
); |
| 2288 |
|
| 2289 |
/** |
| 2290 |
Wrap function to use free() to free allocated memory for certificates. |
| 2291 |
|
| 2292 |
If this interface is not supported, then ASSERT(). |
| 2293 |
|
| 2294 |
@param[in] Certs Pointer to the certificates to be freed. |
| 2295 |
|
| 2296 |
**/ |
| 2297 |
VOID |
| 2298 |
EFIAPI |
| 2299 |
Pkcs7FreeSigners ( |
| 2300 |
IN UINT8 *Certs |
| 2301 |
); |
| 2302 |
|
| 2303 |
/** |
| 2304 |
Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7: |
| 2305 |
Cryptographic Message Syntax Standard", and outputs two certificate lists chained and |
| 2306 |
unchained to the signer's certificates. |
| 2307 |
The input signed data could be wrapped in a ContentInfo structure. |
| 2308 |
|
| 2309 |
@param[in] P7Data Pointer to the PKCS#7 message. |
| 2310 |
@param[in] P7Length Length of the PKCS#7 message in bytes. |
| 2311 |
@param[out] SignerChainCerts Pointer to the certificates list chained to signer's |
| 2312 |
certificate. It's caller's responsibility to free the buffer. |
| 2313 |
@param[out] ChainLength Length of the chained certificates list buffer in bytes. |
| 2314 |
@param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's |
| 2315 |
responsibility to free the buffer. |
| 2316 |
@param[out] UnchainLength Length of the unchained certificates list buffer in bytes. |
| 2317 |
|
| 2318 |
@retval TRUE The operation is finished successfully. |
| 2319 |
@retval FALSE Error occurs during the operation. |
| 2320 |
|
| 2321 |
**/ |
| 2322 |
BOOLEAN |
| 2323 |
EFIAPI |
| 2324 |
Pkcs7GetCertificatesList ( |
| 2325 |
IN CONST UINT8 *P7Data, |
| 2326 |
IN UINTN P7Length, |
| 2327 |
OUT UINT8 **SignerChainCerts, |
| 2328 |
OUT UINTN *ChainLength, |
| 2329 |
OUT UINT8 **UnchainCerts, |
| 2330 |
OUT UINTN *UnchainLength |
| 2331 |
); |
| 2332 |
|
| 2333 |
/** |
| 2334 |
Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message |
| 2335 |
Syntax Standard, version 1.5". This interface is only intended to be used for |
| 2336 |
application to perform PKCS#7 functionality validation. |
| 2337 |
|
| 2338 |
If this interface is not supported, then return FALSE. |
| 2339 |
|
| 2340 |
@param[in] PrivateKey Pointer to the PEM-formatted private key data for |
| 2341 |
data signing. |
| 2342 |
@param[in] PrivateKeySize Size of the PEM private key data in bytes. |
| 2343 |
@param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM |
| 2344 |
key data. |
| 2345 |
@param[in] InData Pointer to the content to be signed. |
| 2346 |
@param[in] InDataSize Size of InData in bytes. |
| 2347 |
@param[in] SignCert Pointer to signer's DER-encoded certificate to sign with. |
| 2348 |
@param[in] OtherCerts Pointer to an optional additional set of certificates to |
| 2349 |
include in the PKCS#7 signedData (e.g. any intermediate |
| 2350 |
CAs in the chain). |
| 2351 |
@param[out] SignedData Pointer to output PKCS#7 signedData. |
| 2352 |
@param[out] SignedDataSize Size of SignedData in bytes. |
| 2353 |
|
| 2354 |
@retval TRUE PKCS#7 data signing succeeded. |
| 2355 |
@retval FALSE PKCS#7 data signing failed. |
| 2356 |
@retval FALSE This interface is not supported. |
| 2357 |
|
| 2358 |
**/ |
| 2359 |
BOOLEAN |
| 2360 |
EFIAPI |
| 2361 |
Pkcs7Sign ( |
| 2362 |
IN CONST UINT8 *PrivateKey, |
| 2363 |
IN UINTN PrivateKeySize, |
| 2364 |
IN CONST UINT8 *KeyPassword, |
| 2365 |
IN UINT8 *InData, |
| 2366 |
IN UINTN InDataSize, |
| 2367 |
IN UINT8 *SignCert, |
| 2368 |
IN UINT8 *OtherCerts OPTIONAL, |
| 2369 |
OUT UINT8 **SignedData, |
| 2370 |
OUT UINTN *SignedDataSize |
| 2371 |
); |
| 2372 |
|
| 2373 |
/** |
| 2374 |
Verifies the validity of a PKCS#7 signed data as described in "PKCS #7: |
| 2375 |
Cryptographic Message Syntax Standard". The input signed data could be wrapped |
| 2376 |
in a ContentInfo structure. |
| 2377 |
|
| 2378 |
If P7Data, TrustedCert or InData is NULL, then return FALSE. |
| 2379 |
If P7Length, CertLength or DataLength overflow, then return FALSE. |
| 2380 |
If this interface is not supported, then return FALSE. |
| 2381 |
|
| 2382 |
@param[in] P7Data Pointer to the PKCS#7 message to verify. |
| 2383 |
@param[in] P7Length Length of the PKCS#7 message in bytes. |
| 2384 |
@param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which |
| 2385 |
is used for certificate chain verification. |
| 2386 |
@param[in] CertLength Length of the trusted certificate in bytes. |
| 2387 |
@param[in] InData Pointer to the content to be verified. |
| 2388 |
@param[in] DataLength Length of InData in bytes. |
| 2389 |
|
| 2390 |
@retval TRUE The specified PKCS#7 signed data is valid. |
| 2391 |
@retval FALSE Invalid PKCS#7 signed data. |
| 2392 |
@retval FALSE This interface is not supported. |
| 2393 |
|
| 2394 |
**/ |
| 2395 |
BOOLEAN |
| 2396 |
EFIAPI |
| 2397 |
Pkcs7Verify ( |
| 2398 |
IN CONST UINT8 *P7Data, |
| 2399 |
IN UINTN P7Length, |
| 2400 |
IN CONST UINT8 *TrustedCert, |
| 2401 |
IN UINTN CertLength, |
| 2402 |
IN CONST UINT8 *InData, |
| 2403 |
IN UINTN DataLength |
| 2404 |
); |
| 2405 |
|
| 2406 |
#if defined(ENABLE_CODESIGN_EKU) |
| 2407 |
/** |
| 2408 |
This function receives a PKCS#7 formatted signature blob, |
| 2409 |
looks for the EKU SEQUENCE blob, and if found then looks |
| 2410 |
for all the required EKUs. This function was created so that |
| 2411 |
the Surface team can cut down on the number of Certificate |
| 2412 |
Authorities (CA's) by checking EKU's on leaf signers for |
| 2413 |
a specific product. This prevents one product's certificate |
| 2414 |
from signing another product's firmware or unlock blobs. |
| 2415 |
|
| 2416 |
Note that this function does not validate the certificate chain. |
| 2417 |
That needs to be done before using this function. |
| 2418 |
|
| 2419 |
@param[in] Pkcs7Signature The PKCS#7 signed information content block. An array |
| 2420 |
containing the content block with both the signature, |
| 2421 |
the signer's certificate, and any necessary intermediate |
| 2422 |
certificates. |
| 2423 |
@param[in] Pkcs7SignatureSize Number of bytes in Pkcs7Signature. |
| 2424 |
@param[in] RequiredEKUs Array of null-terminated strings listing OIDs of |
| 2425 |
required EKUs that must be present in the signature. |
| 2426 |
@param[in] RequiredEKUsSize Number of elements in the RequiredEKUs string array. |
| 2427 |
@param[in] RequireAllPresent If this is TRUE, then all of the specified EKU's |
| 2428 |
must be present in the leaf signer. If it is |
| 2429 |
FALSE, then we will succeed if we find any |
| 2430 |
of the specified EKU's. |
| 2431 |
|
| 2432 |
@retval EFI_SUCCESS The required EKUs were found in the signature. |
| 2433 |
@retval EFI_INVALID_PARAMETER A parameter was invalid. |
| 2434 |
@retval EFI_NOT_FOUND One or more EKU's were not found in the signature. |
| 2435 |
|
| 2436 |
**/ |
| 2437 |
EFI_STATUS |
| 2438 |
EFIAPI |
| 2439 |
VerifyEKUsInPkcs7Signature ( |
| 2440 |
IN CONST UINT8 *Pkcs7Signature, |
| 2441 |
IN CONST UINT32 SignatureSize, |
| 2442 |
IN CONST CHAR8 *RequiredEKUs[], |
| 2443 |
IN CONST UINT32 RequiredEKUsSize, |
| 2444 |
IN BOOLEAN RequireAllPresent |
| 2445 |
); |
| 2446 |
#endif |
| 2447 |
|
| 2448 |
/** |
| 2449 |
Extracts the attached content from a PKCS#7 signed data if existed. The input signed |
| 2450 |
data could be wrapped in a ContentInfo structure. |
| 2451 |
|
| 2452 |
If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow, |
| 2453 |
then return FALSE. If the P7Data is not correctly formatted, then return FALSE. |
| 2454 |
|
| 2455 |
Caution: This function may receive untrusted input. So this function will do |
| 2456 |
basic check for PKCS#7 data structure. |
| 2457 |
|
| 2458 |
@param[in] P7Data Pointer to the PKCS#7 signed data to process. |
| 2459 |
@param[in] P7Length Length of the PKCS#7 signed data in bytes. |
| 2460 |
@param[out] Content Pointer to the extracted content from the PKCS#7 signedData. |
| 2461 |
It's caller's responsibility to free the buffer. |
| 2462 |
@param[out] ContentSize The size of the extracted content in bytes. |
| 2463 |
|
| 2464 |
@retval TRUE The P7Data was correctly formatted for processing. |
| 2465 |
@retval FALSE The P7Data was not correctly formatted for processing. |
| 2466 |
|
| 2467 |
*/ |
| 2468 |
BOOLEAN |
| 2469 |
EFIAPI |
| 2470 |
Pkcs7GetAttachedContent ( |
| 2471 |
IN CONST UINT8 *P7Data, |
| 2472 |
IN UINTN P7Length, |
| 2473 |
OUT VOID **Content, |
| 2474 |
OUT UINTN *ContentSize |
| 2475 |
); |
| 2476 |
|
| 2477 |
/** |
| 2478 |
Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows |
| 2479 |
Authenticode Portable Executable Signature Format". |
| 2480 |
|
| 2481 |
If AuthData is NULL, then return FALSE. |
| 2482 |
If ImageHash is NULL, then return FALSE. |
| 2483 |
If this interface is not supported, then return FALSE. |
| 2484 |
|
| 2485 |
@param[in] AuthData Pointer to the Authenticode Signature retrieved from signed |
| 2486 |
PE/COFF image to be verified. |
| 2487 |
@param[in] DataSize Size of the Authenticode Signature in bytes. |
| 2488 |
@param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which |
| 2489 |
is used for certificate chain verification. |
| 2490 |
@param[in] CertSize Size of the trusted certificate in bytes. |
| 2491 |
@param[in] ImageHash Pointer to the original image file hash value. The procedure |
| 2492 |
for calculating the image hash value is described in Authenticode |
| 2493 |
specification. |
| 2494 |
@param[in] HashSize Size of Image hash value in bytes. |
| 2495 |
|
| 2496 |
@retval TRUE The specified Authenticode Signature is valid. |
| 2497 |
@retval FALSE Invalid Authenticode Signature. |
| 2498 |
@retval FALSE This interface is not supported. |
| 2499 |
|
| 2500 |
**/ |
| 2501 |
BOOLEAN |
| 2502 |
EFIAPI |
| 2503 |
AuthenticodeVerify ( |
| 2504 |
IN CONST UINT8 *AuthData, |
| 2505 |
IN UINTN DataSize, |
| 2506 |
IN CONST UINT8 *TrustedCert, |
| 2507 |
IN UINTN CertSize, |
| 2508 |
IN CONST UINT8 *ImageHash, |
| 2509 |
IN UINTN HashSize |
| 2510 |
); |
| 2511 |
|
| 2512 |
/** |
| 2513 |
Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode |
| 2514 |
signature. |
| 2515 |
|
| 2516 |
If AuthData is NULL, then return FALSE. |
| 2517 |
If this interface is not supported, then return FALSE. |
| 2518 |
|
| 2519 |
@param[in] AuthData Pointer to the Authenticode Signature retrieved from signed |
| 2520 |
PE/COFF image to be verified. |
| 2521 |
@param[in] DataSize Size of the Authenticode Signature in bytes. |
| 2522 |
@param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which |
| 2523 |
is used for TSA certificate chain verification. |
| 2524 |
@param[in] CertSize Size of the trusted certificate in bytes. |
| 2525 |
@param[out] SigningTime Return the time of timestamp generation time if the timestamp |
| 2526 |
signature is valid. |
| 2527 |
|
| 2528 |
@retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature. |
| 2529 |
@retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data. |
| 2530 |
|
| 2531 |
**/ |
| 2532 |
BOOLEAN |
| 2533 |
EFIAPI |
| 2534 |
ImageTimestampVerify ( |
| 2535 |
IN CONST UINT8 *AuthData, |
| 2536 |
IN UINTN DataSize, |
| 2537 |
IN CONST UINT8 *TsaCert, |
| 2538 |
IN UINTN CertSize, |
| 2539 |
OUT EFI_TIME *SigningTime |
| 2540 |
); |
| 2541 |
|
| 2542 |
//===================================================================================== |
| 2543 |
// DH Key Exchange Primitive |
| 2544 |
//===================================================================================== |
| 2545 |
|
| 2546 |
/** |
| 2547 |
Allocates and Initializes one Diffie-Hellman Context for subsequent use. |
| 2548 |
|
| 2549 |
@return Pointer to the Diffie-Hellman Context that has been initialized. |
| 2550 |
If the allocations fails, DhNew() returns NULL. |
| 2551 |
If the interface is not supported, DhNew() returns NULL. |
| 2552 |
|
| 2553 |
**/ |
| 2554 |
VOID * |
| 2555 |
EFIAPI |
| 2556 |
DhNew ( |
| 2557 |
VOID |
| 2558 |
); |
| 2559 |
|
| 2560 |
/** |
| 2561 |
Release the specified DH context. |
| 2562 |
|
| 2563 |
If the interface is not supported, then ASSERT(). |
| 2564 |
|
| 2565 |
@param[in] DhContext Pointer to the DH context to be released. |
| 2566 |
|
| 2567 |
**/ |
| 2568 |
VOID |
| 2569 |
EFIAPI |
| 2570 |
DhFree ( |
| 2571 |
IN VOID *DhContext |
| 2572 |
); |
| 2573 |
|
| 2574 |
/** |
| 2575 |
Generates DH parameter. |
| 2576 |
|
| 2577 |
Given generator g, and length of prime number p in bits, this function generates p, |
| 2578 |
and sets DH context according to value of g and p. |
| 2579 |
|
| 2580 |
Before this function can be invoked, pseudorandom number generator must be correctly |
| 2581 |
initialized by RandomSeed(). |
| 2582 |
|
| 2583 |
If DhContext is NULL, then return FALSE. |
| 2584 |
If Prime is NULL, then return FALSE. |
| 2585 |
If this interface is not supported, then return FALSE. |
| 2586 |
|
| 2587 |
@param[in, out] DhContext Pointer to the DH context. |
| 2588 |
@param[in] Generator Value of generator. |
| 2589 |
@param[in] PrimeLength Length in bits of prime to be generated. |
| 2590 |
@param[out] Prime Pointer to the buffer to receive the generated prime number. |
| 2591 |
|
| 2592 |
@retval TRUE DH parameter generation succeeded. |
| 2593 |
@retval FALSE Value of Generator is not supported. |
| 2594 |
@retval FALSE PRNG fails to generate random prime number with PrimeLength. |
| 2595 |
@retval FALSE This interface is not supported. |
| 2596 |
|
| 2597 |
**/ |
| 2598 |
BOOLEAN |
| 2599 |
EFIAPI |
| 2600 |
DhGenerateParameter ( |
| 2601 |
IN OUT VOID *DhContext, |
| 2602 |
IN UINTN Generator, |
| 2603 |
IN UINTN PrimeLength, |
| 2604 |
OUT UINT8 *Prime |
| 2605 |
); |
| 2606 |
|
| 2607 |
/** |
| 2608 |
Sets generator and prime parameters for DH. |
| 2609 |
|
| 2610 |
Given generator g, and prime number p, this function and sets DH |
| 2611 |
context accordingly. |
| 2612 |
|
| 2613 |
If DhContext is NULL, then return FALSE. |
| 2614 |
If Prime is NULL, then return FALSE. |
| 2615 |
If this interface is not supported, then return FALSE. |
| 2616 |
|
| 2617 |
@param[in, out] DhContext Pointer to the DH context. |
| 2618 |
@param[in] Generator Value of generator. |
| 2619 |
@param[in] PrimeLength Length in bits of prime to be generated. |
| 2620 |
@param[in] Prime Pointer to the prime number. |
| 2621 |
|
| 2622 |
@retval TRUE DH parameter setting succeeded. |
| 2623 |
@retval FALSE Value of Generator is not supported. |
| 2624 |
@retval FALSE Value of Generator is not suitable for the Prime. |
| 2625 |
@retval FALSE Value of Prime is not a prime number. |
| 2626 |
@retval FALSE Value of Prime is not a safe prime number. |
| 2627 |
@retval FALSE This interface is not supported. |
| 2628 |
|
| 2629 |
**/ |
| 2630 |
BOOLEAN |
| 2631 |
EFIAPI |
| 2632 |
DhSetParameter ( |
| 2633 |
IN OUT VOID *DhContext, |
| 2634 |
IN UINTN Generator, |
| 2635 |
IN UINTN PrimeLength, |
| 2636 |
IN CONST UINT8 *Prime |
| 2637 |
); |
| 2638 |
|
| 2639 |
/** |
| 2640 |
Generates DH public key. |
| 2641 |
|
| 2642 |
This function generates random secret exponent, and computes the public key, which is |
| 2643 |
returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly. |
| 2644 |
If the PublicKey buffer is too small to hold the public key, FALSE is returned and |
| 2645 |
PublicKeySize is set to the required buffer size to obtain the public key. |
| 2646 |
|
| 2647 |
If DhContext is NULL, then return FALSE. |
| 2648 |
If PublicKeySize is NULL, then return FALSE. |
| 2649 |
If PublicKeySize is large enough but PublicKey is NULL, then return FALSE. |
| 2650 |
If this interface is not supported, then return FALSE. |
| 2651 |
|
| 2652 |
@param[in, out] DhContext Pointer to the DH context. |
| 2653 |
@param[out] PublicKey Pointer to the buffer to receive generated public key. |
| 2654 |
@param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes. |
| 2655 |
On output, the size of data returned in PublicKey buffer in bytes. |
| 2656 |
|
| 2657 |
@retval TRUE DH public key generation succeeded. |
| 2658 |
@retval FALSE DH public key generation failed. |
| 2659 |
@retval FALSE PublicKeySize is not large enough. |
| 2660 |
@retval FALSE This interface is not supported. |
| 2661 |
|
| 2662 |
**/ |
| 2663 |
BOOLEAN |
| 2664 |
EFIAPI |
| 2665 |
DhGenerateKey ( |
| 2666 |
IN OUT VOID *DhContext, |
| 2667 |
OUT UINT8 *PublicKey, |
| 2668 |
IN OUT UINTN *PublicKeySize |
| 2669 |
); |
| 2670 |
|
| 2671 |
/** |
| 2672 |
Computes exchanged common key. |
| 2673 |
|
| 2674 |
Given peer's public key, this function computes the exchanged common key, based on its own |
| 2675 |
context including value of prime modulus and random secret exponent. |
| 2676 |
|
| 2677 |
If DhContext is NULL, then return FALSE. |
| 2678 |
If PeerPublicKey is NULL, then return FALSE. |
| 2679 |
If KeySize is NULL, then return FALSE. |
| 2680 |
If Key is NULL, then return FALSE. |
| 2681 |
If KeySize is not large enough, then return FALSE. |
| 2682 |
If this interface is not supported, then return FALSE. |
| 2683 |
|
| 2684 |
@param[in, out] DhContext Pointer to the DH context. |
| 2685 |
@param[in] PeerPublicKey Pointer to the peer's public key. |
| 2686 |
@param[in] PeerPublicKeySize Size of peer's public key in bytes. |
| 2687 |
@param[out] Key Pointer to the buffer to receive generated key. |
| 2688 |
@param[in, out] KeySize On input, the size of Key buffer in bytes. |
| 2689 |
On output, the size of data returned in Key buffer in bytes. |
| 2690 |
|
| 2691 |
@retval TRUE DH exchanged key generation succeeded. |
| 2692 |
@retval FALSE DH exchanged key generation failed. |
| 2693 |
@retval FALSE KeySize is not large enough. |
| 2694 |
@retval FALSE This interface is not supported. |
| 2695 |
|
| 2696 |
**/ |
| 2697 |
BOOLEAN |
| 2698 |
EFIAPI |
| 2699 |
DhComputeKey ( |
| 2700 |
IN OUT VOID *DhContext, |
| 2701 |
IN CONST UINT8 *PeerPublicKey, |
| 2702 |
IN UINTN PeerPublicKeySize, |
| 2703 |
OUT UINT8 *Key, |
| 2704 |
IN OUT UINTN *KeySize |
| 2705 |
); |
| 2706 |
|
| 2707 |
//===================================================================================== |
| 2708 |
// Pseudo-Random Generation Primitive |
| 2709 |
//===================================================================================== |
| 2710 |
|
| 2711 |
/** |
| 2712 |
Sets up the seed value for the pseudorandom number generator. |
| 2713 |
|
| 2714 |
This function sets up the seed value for the pseudorandom number generator. |
| 2715 |
If Seed is not NULL, then the seed passed in is used. |
| 2716 |
If Seed is NULL, then default seed is used. |
| 2717 |
If this interface is not supported, then return FALSE. |
| 2718 |
|
| 2719 |
@param[in] Seed Pointer to seed value. |
| 2720 |
If NULL, default seed is used. |
| 2721 |
@param[in] SeedSize Size of seed value. |
| 2722 |
If Seed is NULL, this parameter is ignored. |
| 2723 |
|
| 2724 |
@retval TRUE Pseudorandom number generator has enough entropy for random generation. |
| 2725 |
@retval FALSE Pseudorandom number generator does not have enough entropy for random generation. |
| 2726 |
@retval FALSE This interface is not supported. |
| 2727 |
|
| 2728 |
**/ |
| 2729 |
BOOLEAN |
| 2730 |
EFIAPI |
| 2731 |
RandomSeed ( |
| 2732 |
IN CONST UINT8 *Seed OPTIONAL, |
| 2733 |
IN UINTN SeedSize |
| 2734 |
); |
| 2735 |
|
| 2736 |
/** |
| 2737 |
Generates a pseudorandom byte stream of the specified size. |
| 2738 |
|
| 2739 |
If Output is NULL, then return FALSE. |
| 2740 |
If this interface is not supported, then return FALSE. |
| 2741 |
|
| 2742 |
@param[out] Output Pointer to buffer to receive random value. |
| 2743 |
@param[in] Size Size of random bytes to generate. |
| 2744 |
|
| 2745 |
@retval TRUE Pseudorandom byte stream generated successfully. |
| 2746 |
@retval FALSE Pseudorandom number generator fails to generate due to lack of entropy. |
| 2747 |
@retval FALSE This interface is not supported. |
| 2748 |
|
| 2749 |
**/ |
| 2750 |
BOOLEAN |
| 2751 |
EFIAPI |
| 2752 |
RandomBytes ( |
| 2753 |
OUT UINT8 *Output, |
| 2754 |
IN UINTN Size |
| 2755 |
); |
| 2756 |
|
| 2757 |
#endif // __BASE_CRYPT_LIB_H__ |