LibreOffice
LibreOffice 6.0 SDK C/C++ API Reference
digest.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_RTL_DIGEST_H
21 #define INCLUDED_RTL_DIGEST_H
22 
23 #include <sal/config.h>
24 
25 #include <sal/saldllapi.h>
26 #include <sal/types.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
34 typedef void* rtlDigest;
35 
36 
41 {
46 
49 
52 };
53 
57 
58 
62 {
70 };
71 
75 
76 
83 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_create (
84  rtlDigestAlgorithm Algorithm
86 
87 
93 SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroy (
94  rtlDigest Digest
96 
97 
102 SAL_DLLPUBLIC rtlDigestAlgorithm SAL_CALL rtl_digest_queryAlgorithm (
103  rtlDigest Digest
105 
106 
111 SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_digest_queryLength (
112  rtlDigest Digest
114 
115 
123 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_init (
124  rtlDigest Digest,
125  const sal_uInt8 *pData, sal_uInt32 nDatLen
127 
128 
136 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_update (
137  rtlDigest Digest,
138  const void *pData, sal_uInt32 nDatLen
140 
141 
154 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_get (
155  rtlDigest Digest,
156  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
158 
159 #define RTL_DIGEST_LENGTH_MD2 16
160 
169 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createMD2 (void) SAL_THROW_EXTERN_C();
170 
171 
175 SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroyMD2 (
176  rtlDigest Digest
177 ) SAL_THROW_EXTERN_C();
178 
182 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateMD2 (
183  rtlDigest Digest,
184  const void *pData, sal_uInt32 nDatLen
185 ) SAL_THROW_EXTERN_C();
186 
190 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getMD2 (
191  rtlDigest Digest,
192  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
193 ) SAL_THROW_EXTERN_C();
194 
210 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_MD2 (
211  const void *pData, sal_uInt32 nDatLen,
212  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
213 ) SAL_THROW_EXTERN_C();
214 
215 #define RTL_DIGEST_LENGTH_MD5 16
216 
225 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createMD5 (void) SAL_THROW_EXTERN_C();
226 
230 SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroyMD5 (
231  rtlDigest Digest
232 ) SAL_THROW_EXTERN_C();
233 
237 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateMD5 (
238  rtlDigest Digest,
239  const void *pData, sal_uInt32 nDatLen
240 ) SAL_THROW_EXTERN_C();
241 
245 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getMD5 (
246  rtlDigest Digest,
247  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
248 ) SAL_THROW_EXTERN_C();
249 
258 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_rawMD5 (
259  rtlDigest Digest,
260  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
261 ) SAL_THROW_EXTERN_C();
262 
278 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_MD5 (
279  const void *pData, sal_uInt32 nDatLen,
280  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
281 ) SAL_THROW_EXTERN_C();
282 
283 #define RTL_DIGEST_LENGTH_SHA 20
284 
293 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createSHA (void) SAL_THROW_EXTERN_C();
294 
298 SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroySHA (
299  rtlDigest Digest
300 ) SAL_THROW_EXTERN_C();
301 
302 
306 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA (
307  rtlDigest Digest,
308  const void *pData, sal_uInt32 nDatLen
309 ) SAL_THROW_EXTERN_C();
310 
314 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA (
315  rtlDigest Digest,
316  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
317 ) SAL_THROW_EXTERN_C();
318 
334 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_SHA (
335  const void *pData, sal_uInt32 nDatLen,
336  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
337 ) SAL_THROW_EXTERN_C();
338 
339 /*========================================================================
340  *
341  * rtl_digest_SHA1 interface.
342  *
343  *======================================================================*/
344 #define RTL_DIGEST_LENGTH_SHA1 20
345 
354 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createSHA1 (void) SAL_THROW_EXTERN_C();
355 
360  rtlDigest Digest
361 ) SAL_THROW_EXTERN_C();
362 
366 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA1 (
367  rtlDigest Digest,
368  const void *pData, sal_uInt32 nDatLen
369 ) SAL_THROW_EXTERN_C();
370 
374 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA1 (
375  rtlDigest Digest,
376  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
377 ) SAL_THROW_EXTERN_C();
378 
394 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_SHA1 (
395  const void *pData, sal_uInt32 nDatLen,
396  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
397 ) SAL_THROW_EXTERN_C();
398 
399 #define RTL_DIGEST_LENGTH_HMAC_MD5 RTL_DIGEST_LENGTH_MD5
400 
410 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createHMAC_MD5 (void) SAL_THROW_EXTERN_C();
411 
416  rtlDigest Digest
417 ) SAL_THROW_EXTERN_C();
418 
428 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_initHMAC_MD5 (
429  rtlDigest Digest,
430  const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen
431 ) SAL_THROW_EXTERN_C();
432 
436 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateHMAC_MD5 (
437  rtlDigest Digest,
438  const void *pData, sal_uInt32 nDatLen
439 ) SAL_THROW_EXTERN_C();
440 
444 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getHMAC_MD5 (
445  rtlDigest Digest,
446  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
447 ) SAL_THROW_EXTERN_C();
448 
467 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_HMAC_MD5 (
468  const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen,
469  const void *pData, sal_uInt32 nDatLen,
470  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
471 ) SAL_THROW_EXTERN_C();
472 
473 #define RTL_DIGEST_LENGTH_HMAC_SHA1 RTL_DIGEST_LENGTH_SHA1
474 
485 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createHMAC_SHA1 (void) SAL_THROW_EXTERN_C();
486 
491  rtlDigest Digest
492 ) SAL_THROW_EXTERN_C();
493 
503 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_initHMAC_SHA1 (
504  rtlDigest Digest,
505  const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen
506 ) SAL_THROW_EXTERN_C();
507 
511 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 (
512  rtlDigest Digest,
513  const void *pData, sal_uInt32 nDatLen
514 ) SAL_THROW_EXTERN_C();
515 
519 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 (
520  rtlDigest Digest,
521  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
522 ) SAL_THROW_EXTERN_C();
523 
542 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_HMAC_SHA1 (
543  const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen,
544  const void *pData, sal_uInt32 nDatLen,
545  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
546 ) SAL_THROW_EXTERN_C();
547 
564 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_PBKDF2 (
565  sal_uInt8 *pKeyData , sal_uInt32 nKeyLen,
566  const sal_uInt8 *pPassData, sal_uInt32 nPassLen,
567  const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen,
568  sal_uInt32 nCount
569 ) SAL_THROW_EXTERN_C();
570 
571 #ifdef __cplusplus
572 }
573 #endif
574 
575 #endif // INCLUDED_RTL_DIGEST_H
576 
577 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC rtlDigestError rtl_digest_HMAC_SHA1(const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, const void *pData, sal_uInt32 nDatLen, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Evaluate a HMAC_SHA1 digest value from given data.
SAL_DLLPUBLIC rtlDigest rtl_digest_create(rtlDigestAlgorithm Algorithm) SAL_THROW_EXTERN_C()
Create a digest handle for the given algorithm.
#define SAL_DLLPUBLIC
Definition: saldllapi.h:30
SAL_DLLPUBLIC rtlDigest rtl_digest_createMD5(void) SAL_THROW_EXTERN_C()
Create a MD5 digest handle.
SAL_DLLPUBLIC rtlDigestError rtl_digest_MD2(const void *pData, sal_uInt32 nDatLen, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Evaluate a MD2 digest value from given data.
SAL_DLLPUBLIC rtlDigestError rtl_digest_MD5(const void *pData, sal_uInt32 nDatLen, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Evaluate a MD5 digest value from given data.
SAL_DLLPUBLIC rtlDigestError rtl_digest_initHMAC_SHA1(rtlDigest Digest, const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen) SAL_THROW_EXTERN_C()
Initialize a HMAC_SHA1 digest.
SAL_DLLPUBLIC rtlDigestError rtl_digest_getHMAC_SHA1(rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Finalize a HMAC_SHA1 digest and retrieve the digest value.
__rtl_DigestAlgorithm
Digest Algorithm enumeration.
Definition: digest.h:40
SAL_DLLPUBLIC void rtl_digest_destroyMD5(rtlDigest Digest) SAL_THROW_EXTERN_C()
Destroy a MD5 digest handle.
SAL_DLLPUBLIC rtlDigest rtl_digest_createSHA(void) SAL_THROW_EXTERN_C()
Create a SHA digest handle.
Definition: digest.h:47
Definition: digest.h:42
Definition: digest.h:45
void * rtlDigest
Digest Handle opaque type.
Definition: digest.h:34
enum __rtl_DigestAlgorithm rtlDigestAlgorithm
Digest Algorithm type.
Definition: digest.h:56
SAL_DLLPUBLIC rtlDigestError rtl_digest_updateSHA1(rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) SAL_THROW_EXTERN_C()
Update a SHA1 digest with given data.
#define SAL_MAX_ENUM
Definition: types.h:228
SAL_DLLPUBLIC rtlDigestError rtl_digest_getSHA1(rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Finalize a SHA1 digest and retrieve the digest value.
SAL_DLLPUBLIC rtlDigestError rtl_digest_update(rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) SAL_THROW_EXTERN_C()
Update a digest with given data.
SAL_DLLPUBLIC rtlDigestError rtl_digest_HMAC_MD5(const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, const void *pData, sal_uInt32 nDatLen, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Evaluate a HMAC_MD5 digest value from given data.
unsigned char sal_uInt8
Definition: types.h:45
Definition: digest.h:65
Definition: digest.h:67
SAL_DLLPUBLIC rtlDigestError rtl_digest_initHMAC_MD5(rtlDigest Digest, const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen) SAL_THROW_EXTERN_C()
Initialize a HMAC_MD5 digest.
SAL_DLLPUBLIC rtlDigestError rtl_digest_getSHA(rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Finalize a SHA digest and retrieve the digest value.
SAL_DLLPUBLIC rtlDigestError rtl_digest_get(rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Finalize a digest and retrieve the digest value.
SAL_DLLPUBLIC void rtl_digest_destroySHA1(rtlDigest Digest) SAL_THROW_EXTERN_C()
Destroy a SHA1 digest handle.
SAL_DLLPUBLIC void rtl_digest_destroySHA(rtlDigest Digest) SAL_THROW_EXTERN_C()
Destroy a SHA digest handle.
SAL_DLLPUBLIC rtlDigestError rtl_digest_SHA(const void *pData, sal_uInt32 nDatLen, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Evaluate a SHA digest value from given data.
SAL_DLLPUBLIC void rtl_digest_destroyMD2(rtlDigest Digest) SAL_THROW_EXTERN_C()
Destroy a MD2 digest handle.
__rtl_DigestError
Error Code enumeration.
Definition: digest.h:61
SAL_DLLPUBLIC rtlDigestError rtl_digest_updateMD2(rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) SAL_THROW_EXTERN_C()
Update a MD2 digest with given data.
SAL_DLLPUBLIC rtlDigestError rtl_digest_updateHMAC_MD5(rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) SAL_THROW_EXTERN_C()
Update a HMAC_MD5 digest with given data.
Definition: digest.h:50
SAL_DLLPUBLIC void rtl_digest_destroy(rtlDigest Digest) SAL_THROW_EXTERN_C()
Destroy a digest handle.
SAL_DLLPUBLIC rtlDigest rtl_digest_createSHA1(void) SAL_THROW_EXTERN_C()
Create a SHA1 digest handle.
SAL_DLLPUBLIC rtlDigestError rtl_digest_updateSHA(rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) SAL_THROW_EXTERN_C()
Update a SHA digest with given data.
SAL_DLLPUBLIC rtlDigestError rtl_digest_init(rtlDigest Digest, const sal_uInt8 *pData, sal_uInt32 nDatLen) SAL_THROW_EXTERN_C()
Initialize a digest with given data.
SAL_DLLPUBLIC rtlDigest rtl_digest_createHMAC_SHA1(void) SAL_THROW_EXTERN_C()
Create a HMAC_SHA1 digest handle.
Definition: digest.h:48
SAL_DLLPUBLIC rtlDigest rtl_digest_createHMAC_MD5(void) SAL_THROW_EXTERN_C()
Create a HMAC_MD5 digest handle.
SAL_DLLPUBLIC rtlDigestError rtl_digest_getMD5(rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Finalize a MD5 digest and retrieve the digest value.
Definition: digest.h:68
SAL_DLLPUBLIC rtlDigestError rtl_digest_updateHMAC_SHA1(rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) SAL_THROW_EXTERN_C()
Update a HMAC_SHA1 digest with given data.
Definition: digest.h:66
Definition: digest.h:64
SAL_DLLPUBLIC sal_uInt32 rtl_digest_queryLength(rtlDigest Digest) SAL_THROW_EXTERN_C()
Query the length of a given digest.
SAL_DLLPUBLIC rtlDigestError rtl_digest_getHMAC_MD5(rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Finalize a HMAC_MD5 digest and retrieve the digest value.
Definition: digest.h:69
Definition: digest.h:63
SAL_DLLPUBLIC void rtl_digest_destroyHMAC_SHA1(rtlDigest Digest) SAL_THROW_EXTERN_C()
Destroy a HMAC_SHA1 digest handle.
SAL_DLLPUBLIC rtlDigest rtl_digest_createMD2(void) SAL_THROW_EXTERN_C()
Create a MD2 digest handle.
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:352
Definition: digest.h:43
SAL_DLLPUBLIC rtlDigestAlgorithm rtl_digest_queryAlgorithm(rtlDigest Digest) SAL_THROW_EXTERN_C()
Query the algorithm of a given digest.
SAL_DLLPUBLIC rtlDigestError rtl_digest_updateMD5(rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) SAL_THROW_EXTERN_C()
Update a MD5 digest with given data.
SAL_DLLPUBLIC rtlDigestError rtl_digest_getMD2(rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Finalize a MD2 digest and retrieve the digest value.
SAL_DLLPUBLIC void rtl_digest_destroyHMAC_MD5(rtlDigest Digest) SAL_THROW_EXTERN_C()
Destroy a HMAC_MD5 digest handle.
Definition: digest.h:44
enum __rtl_DigestError rtlDigestError
Error Code type.
Definition: digest.h:74
SAL_DLLPUBLIC rtlDigestError rtl_digest_rawMD5(rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Retrieve the raw (not finalized) MD5 digest value.
SAL_DLLPUBLIC rtlDigestError rtl_digest_PBKDF2(sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, const sal_uInt8 *pPassData, sal_uInt32 nPassLen, const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen, sal_uInt32 nCount) SAL_THROW_EXTERN_C()
Password-Based Key Derivation Function.
SAL_DLLPUBLIC rtlDigestError rtl_digest_SHA1(const void *pData, sal_uInt32 nDatLen, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C()
Evaluate a SHA1 digest value from given data.