xref: /freebsd/sys/crypto/sha2/sha384.h (revision 95ee2897)
17a3f5d11SAllan Jude /*-
27a3f5d11SAllan Jude  * Copyright 2005 Colin Percival
37a3f5d11SAllan Jude  * All rights reserved.
47a3f5d11SAllan Jude  *
57a3f5d11SAllan Jude  * Redistribution and use in source and binary forms, with or without
67a3f5d11SAllan Jude  * modification, are permitted provided that the following conditions
77a3f5d11SAllan Jude  * are met:
87a3f5d11SAllan Jude  * 1. Redistributions of source code must retain the above copyright
97a3f5d11SAllan Jude  *    notice, this list of conditions and the following disclaimer.
107a3f5d11SAllan Jude  * 2. Redistributions in binary form must reproduce the above copyright
117a3f5d11SAllan Jude  *    notice, this list of conditions and the following disclaimer in the
127a3f5d11SAllan Jude  *    documentation and/or other materials provided with the distribution.
137a3f5d11SAllan Jude  *
147a3f5d11SAllan Jude  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
157a3f5d11SAllan Jude  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
167a3f5d11SAllan Jude  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
177a3f5d11SAllan Jude  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
187a3f5d11SAllan Jude  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
197a3f5d11SAllan Jude  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
207a3f5d11SAllan Jude  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
217a3f5d11SAllan Jude  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
227a3f5d11SAllan Jude  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
237a3f5d11SAllan Jude  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
247a3f5d11SAllan Jude  * SUCH DAMAGE.
257a3f5d11SAllan Jude  */
267a3f5d11SAllan Jude 
277a3f5d11SAllan Jude #ifndef _SHA384_H_
287a3f5d11SAllan Jude #define _SHA384_H_
297a3f5d11SAllan Jude 
307a3f5d11SAllan Jude #ifndef _KERNEL
317a3f5d11SAllan Jude #include <sys/types.h>
327a3f5d11SAllan Jude #endif
337a3f5d11SAllan Jude 
347a3f5d11SAllan Jude #define SHA384_BLOCK_LENGTH		128
357a3f5d11SAllan Jude #define SHA384_DIGEST_LENGTH		48
367a3f5d11SAllan Jude #define SHA384_DIGEST_STRING_LENGTH	(SHA384_DIGEST_LENGTH * 2 + 1)
377a3f5d11SAllan Jude 
387a3f5d11SAllan Jude typedef struct SHA384Context {
397a3f5d11SAllan Jude 	uint64_t state[8];
407a3f5d11SAllan Jude 	uint64_t count[2];
417a3f5d11SAllan Jude 	uint8_t buf[SHA384_BLOCK_LENGTH];
427a3f5d11SAllan Jude } SHA384_CTX;
437a3f5d11SAllan Jude 
447a3f5d11SAllan Jude __BEGIN_DECLS
457a3f5d11SAllan Jude 
467a3f5d11SAllan Jude /* Ensure libmd symbols do not clash with libcrypto */
477a3f5d11SAllan Jude #ifndef SHA384_Init
487a3f5d11SAllan Jude #define SHA384_Init		_libmd_SHA384_Init
497a3f5d11SAllan Jude #endif
507a3f5d11SAllan Jude #ifndef SHA384_Update
517a3f5d11SAllan Jude #define SHA384_Update		_libmd_SHA384_Update
527a3f5d11SAllan Jude #endif
537a3f5d11SAllan Jude #ifndef SHA384_Final
547a3f5d11SAllan Jude #define SHA384_Final		_libmd_SHA384_Final
557a3f5d11SAllan Jude #endif
567a3f5d11SAllan Jude #ifndef SHA384_End
577a3f5d11SAllan Jude #define SHA384_End		_libmd_SHA384_End
587a3f5d11SAllan Jude #endif
59de13c242SEd Maste #ifndef SHA384_Fd
60de13c242SEd Maste #define SHA384_Fd		_libmd_SHA384_Fd
61de13c242SEd Maste #endif
62de13c242SEd Maste #ifndef SHA384_FdChunk
63de13c242SEd Maste #define SHA384_FdChunk		_libmd_SHA384_FdChunk
64de13c242SEd Maste #endif
657a3f5d11SAllan Jude #ifndef SHA384_File
667a3f5d11SAllan Jude #define SHA384_File		_libmd_SHA384_File
677a3f5d11SAllan Jude #endif
687a3f5d11SAllan Jude #ifndef SHA384_FileChunk
697a3f5d11SAllan Jude #define SHA384_FileChunk	_libmd_SHA384_FileChunk
707a3f5d11SAllan Jude #endif
717a3f5d11SAllan Jude #ifndef SHA384_Data
727a3f5d11SAllan Jude #define SHA384_Data		_libmd_SHA384_Data
737a3f5d11SAllan Jude #endif
747a3f5d11SAllan Jude 
757a3f5d11SAllan Jude #ifndef SHA384_version
767a3f5d11SAllan Jude #define SHA384_version		_libmd_SHA384_version
777a3f5d11SAllan Jude #endif
787a3f5d11SAllan Jude 
797a3f5d11SAllan Jude void	SHA384_Init(SHA384_CTX *);
807a3f5d11SAllan Jude void	SHA384_Update(SHA384_CTX *, const void *, size_t);
818254c3c5SAlan Somers void	SHA384_Final(unsigned char [__min_size(SHA384_DIGEST_LENGTH)],
828254c3c5SAlan Somers     SHA384_CTX *);
837a3f5d11SAllan Jude #ifndef _KERNEL
847a3f5d11SAllan Jude char   *SHA384_End(SHA384_CTX *, char *);
857a3f5d11SAllan Jude char   *SHA384_Data(const void *, unsigned int, char *);
86de13c242SEd Maste char   *SHA384_Fd(int, char *);
87de13c242SEd Maste char   *SHA384_FdChunk(int, char *, off_t, off_t);
887a3f5d11SAllan Jude char   *SHA384_File(const char *, char *);
897a3f5d11SAllan Jude char   *SHA384_FileChunk(const char *, char *, off_t, off_t);
907a3f5d11SAllan Jude #endif
917a3f5d11SAllan Jude 
927a3f5d11SAllan Jude __END_DECLS
937a3f5d11SAllan Jude 
947a3f5d11SAllan Jude #endif /* !_SHA384_H_ */
95