Annotation of embedaddon/sudo/plugins/sudoers/sha2.h, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (c) 2013 Todd C. Miller <Todd.Miller@courtesan.com>
! 3: *
! 4: * Permission to use, copy, modify, and distribute this software for any
! 5: * purpose with or without fee is hereby granted, provided that the above
! 6: * copyright notice and this permission notice appear in all copies.
! 7: *
! 8: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
! 9: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
! 10: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
! 11: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
! 12: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
! 13: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
! 14: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
! 15: */
! 16:
! 17: /*
! 18: * Derived from the public domain SHA-1 and SHA-2 implementations
! 19: * by Steve Reid and Wei Dai respectively.
! 20: */
! 21:
! 22: #ifndef _SUDOERS_SHA2_H
! 23: #define _SUDOERS_SHA2_H
! 24:
! 25: #define SHA224_BLOCK_LENGTH 64
! 26: #define SHA224_DIGEST_LENGTH 28
! 27: #define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1)
! 28:
! 29: #define SHA256_BLOCK_LENGTH 64
! 30: #define SHA256_DIGEST_LENGTH 32
! 31: #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
! 32:
! 33: #define SHA384_BLOCK_LENGTH 128
! 34: #define SHA384_DIGEST_LENGTH 48
! 35: #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
! 36:
! 37: #define SHA512_BLOCK_LENGTH 128
! 38: #define SHA512_DIGEST_LENGTH 64
! 39: #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
! 40:
! 41: typedef struct {
! 42: union {
! 43: uint32_t st32[8]; /* sha224 and sha256 */
! 44: uint64_t st64[8]; /* sha384 and sha512 */
! 45: } state;
! 46: uint64_t count[2];
! 47: uint8_t buffer[SHA512_BLOCK_LENGTH];
! 48: } SHA2_CTX;
! 49:
! 50: void SHA224Init(SHA2_CTX *ctx);
! 51: void SHA224Pad(SHA2_CTX *ctx);
! 52: void SHA224Transform(uint32_t state[8], const uint8_t buffer[SHA224_BLOCK_LENGTH]);
! 53: void SHA224Update(SHA2_CTX *ctx, const uint8_t *data, size_t len);
! 54: void SHA224Final(uint8_t digest[SHA224_DIGEST_LENGTH], SHA2_CTX *ctx);
! 55:
! 56: void SHA256Init(SHA2_CTX *ctx);
! 57: void SHA256Pad(SHA2_CTX *ctx);
! 58: void SHA256Transform(uint32_t state[8], const uint8_t buffer[SHA256_BLOCK_LENGTH]);
! 59: void SHA256Update(SHA2_CTX *ctx, const uint8_t *data, size_t len);
! 60: void SHA256Final(uint8_t digest[SHA256_DIGEST_LENGTH], SHA2_CTX *ctx);
! 61:
! 62: void SHA384Init(SHA2_CTX *ctx);
! 63: void SHA384Pad(SHA2_CTX *ctx);
! 64: void SHA384Transform(uint64_t state[8], const uint8_t buffer[SHA384_BLOCK_LENGTH]);
! 65: void SHA384Update(SHA2_CTX *ctx, const uint8_t *data, size_t len);
! 66: void SHA384Final(uint8_t digest[SHA384_DIGEST_LENGTH], SHA2_CTX *ctx);
! 67:
! 68: void SHA512Init(SHA2_CTX *ctx);
! 69: void SHA512Pad(SHA2_CTX *ctx);
! 70: void SHA512Transform(uint64_t state[8], const uint8_t buffer[SHA512_BLOCK_LENGTH]);
! 71: void SHA512Update(SHA2_CTX *ctx, const uint8_t *data, size_t len);
! 72: void SHA512Final(uint8_t digest[SHA512_DIGEST_LENGTH], SHA2_CTX *ctx);
! 73:
! 74: #endif /* _SUDOERS_SHA2_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>