You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					121 lines
				
				4.1 KiB
			
		
		
			
		
	
	
					121 lines
				
				4.1 KiB
			| 
								 
											6 years ago
										 
									 | 
							
								'\" t
							 | 
						||
| 
								 | 
							
								.\"     Title: zdigest
							 | 
						||
| 
								 | 
							
								.\"    Author: [see the "AUTHORS" section]
							 | 
						||
| 
								 | 
							
								.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
							 | 
						||
| 
								 | 
							
								.\"      Date: 12/31/2016
							 | 
						||
| 
								 | 
							
								.\"    Manual: CZMQ Manual
							 | 
						||
| 
								 | 
							
								.\"    Source: CZMQ 4.0.2
							 | 
						||
| 
								 | 
							
								.\"  Language: English
							 | 
						||
| 
								 | 
							
								.\"
							 | 
						||
| 
								 | 
							
								.TH "ZDIGEST" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
							 | 
						||
| 
								 | 
							
								.\" -----------------------------------------------------------------
							 | 
						||
| 
								 | 
							
								.\" * Define some portability stuff
							 | 
						||
| 
								 | 
							
								.\" -----------------------------------------------------------------
							 | 
						||
| 
								 | 
							
								.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
							 | 
						||
| 
								 | 
							
								.\" http://bugs.debian.org/507673
							 | 
						||
| 
								 | 
							
								.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
							 | 
						||
| 
								 | 
							
								.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
							 | 
						||
| 
								 | 
							
								.ie \n(.g .ds Aq \(aq
							 | 
						||
| 
								 | 
							
								.el       .ds Aq '
							 | 
						||
| 
								 | 
							
								.\" -----------------------------------------------------------------
							 | 
						||
| 
								 | 
							
								.\" * set default formatting
							 | 
						||
| 
								 | 
							
								.\" -----------------------------------------------------------------
							 | 
						||
| 
								 | 
							
								.\" disable hyphenation
							 | 
						||
| 
								 | 
							
								.nh
							 | 
						||
| 
								 | 
							
								.\" disable justification (adjust text to left margin only)
							 | 
						||
| 
								 | 
							
								.ad l
							 | 
						||
| 
								 | 
							
								.\" -----------------------------------------------------------------
							 | 
						||
| 
								 | 
							
								.\" * MAIN CONTENT STARTS HERE *
							 | 
						||
| 
								 | 
							
								.\" -----------------------------------------------------------------
							 | 
						||
| 
								 | 
							
								.SH "NAME"
							 | 
						||
| 
								 | 
							
								zdigest \- provides hashing functions (SHA\-1 at present)
							 | 
						||
| 
								 | 
							
								.SH "SYNOPSIS"
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								.nf
							 | 
						||
| 
								 | 
							
								//  This is a stable class, and may not change except for emergencies\&. It
							 | 
						||
| 
								 | 
							
								//  is provided in stable builds\&.
							 | 
						||
| 
								 | 
							
								//  Constructor \- creates new digest object, which you use to build up a
							 | 
						||
| 
								 | 
							
								//  digest by repeatedly calling zdigest_update() on chunks of data\&.
							 | 
						||
| 
								 | 
							
								CZMQ_EXPORT zdigest_t *
							 | 
						||
| 
								 | 
							
								    zdigest_new (void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//  Destroy a digest object
							 | 
						||
| 
								 | 
							
								CZMQ_EXPORT void
							 | 
						||
| 
								 | 
							
								    zdigest_destroy (zdigest_t **self_p);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//  Add buffer into digest calculation
							 | 
						||
| 
								 | 
							
								CZMQ_EXPORT void
							 | 
						||
| 
								 | 
							
								    zdigest_update (zdigest_t *self, const byte *buffer, size_t length);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//  Return final digest hash data\&. If built without crypto support,
							 | 
						||
| 
								 | 
							
								//  returns NULL\&.
							 | 
						||
| 
								 | 
							
								CZMQ_EXPORT const byte *
							 | 
						||
| 
								 | 
							
								    zdigest_data (zdigest_t *self);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//  Return final digest hash size
							 | 
						||
| 
								 | 
							
								CZMQ_EXPORT size_t
							 | 
						||
| 
								 | 
							
								    zdigest_size (zdigest_t *self);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//  Return digest as printable hex string; caller should not modify nor
							 | 
						||
| 
								 | 
							
								//  free this string\&. After calling this, you may not use zdigest_update()
							 | 
						||
| 
								 | 
							
								//  on the same digest\&. If built without crypto support, returns NULL\&.
							 | 
						||
| 
								 | 
							
								CZMQ_EXPORT char *
							 | 
						||
| 
								 | 
							
								    zdigest_string (zdigest_t *self);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//  Self test of this class\&.
							 | 
						||
| 
								 | 
							
								CZMQ_EXPORT void
							 | 
						||
| 
								 | 
							
								    zdigest_test (bool verbose);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zdigest\&.c\*(Aq\&.
							 | 
						||
| 
								 | 
							
								.fi
							 | 
						||
| 
								 | 
							
								.SH "DESCRIPTION"
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								The zdigest class generates a hash from zchunks of data\&. The current algorithm is SHA\-1, chosen for speed\&. We are aiming to generate a unique digest for a file, and there are no security issues in this use case\&.
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								The current code depends on OpenSSL, which might be replaced by hard coded SHA\-1 implementation to reduce build dependencies\&.
							 | 
						||
| 
								 | 
							
								.SH "EXAMPLE"
							 | 
						||
| 
								 | 
							
								.PP
							 | 
						||
| 
								 | 
							
								\fBFrom zdigest_test method\fR. 
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								.if n \{\
							 | 
						||
| 
								 | 
							
								.RS 4
							 | 
						||
| 
								 | 
							
								.\}
							 | 
						||
| 
								 | 
							
								.nf
							 | 
						||
| 
								 | 
							
								byte *buffer = (byte *) zmalloc (1024);
							 | 
						||
| 
								 | 
							
								memset (buffer, 0xAA, 1024);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								zdigest_t *digest = zdigest_new ();
							 | 
						||
| 
								 | 
							
								assert (digest);
							 | 
						||
| 
								 | 
							
								zdigest_update (digest, buffer, 1024);
							 | 
						||
| 
								 | 
							
								const byte *data = zdigest_data (digest);
							 | 
						||
| 
								 | 
							
								assert (data [0] == 0xDE);
							 | 
						||
| 
								 | 
							
								assert (data [1] == 0xB2);
							 | 
						||
| 
								 | 
							
								assert (data [2] == 0x38);
							 | 
						||
| 
								 | 
							
								assert (data [3] == 0x07);
							 | 
						||
| 
								 | 
							
								assert (streq (zdigest_string (digest),
							 | 
						||
| 
								 | 
							
								               "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671"));
							 | 
						||
| 
								 | 
							
								zdigest_destroy (&digest);
							 | 
						||
| 
								 | 
							
								free (buffer);
							 | 
						||
| 
								 | 
							
								.fi
							 | 
						||
| 
								 | 
							
								.if n \{\
							 | 
						||
| 
								 | 
							
								.RE
							 | 
						||
| 
								 | 
							
								.\}
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								.SH "AUTHORS"
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								The czmq manual was written by the authors in the AUTHORS file\&.
							 | 
						||
| 
								 | 
							
								.SH "RESOURCES"
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								Main web site: \m[blue]\fB\%\fR\m[]
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
							 | 
						||
| 
								 | 
							
								.SH "COPYRIGHT"
							 | 
						||
| 
								 | 
							
								.sp
							 | 
						||
| 
								 | 
							
								Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
							 | 
						||
| 
								 | 
							
								.SH "NOTES"
							 | 
						||
| 
								 | 
							
								.IP " 1." 4
							 | 
						||
| 
								 | 
							
								zeromq-dev@lists.zeromq.org
							 | 
						||
| 
								 | 
							
								.RS 4
							 | 
						||
| 
								 | 
							
								\%mailto:zeromq-dev@lists.zeromq.org
							 | 
						||
| 
								 | 
							
								.RE
							 |