LibreOffice
LibreOffice 6.2 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 
296 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createSHA (void) SAL_THROW_EXTERN_C();
297 
305 SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroySHA (
306  rtlDigest Digest
307 ) SAL_THROW_EXTERN_C();
308 
309 
317 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA (
318  rtlDigest Digest,
319  const void *pData, sal_uInt32 nDatLen
320 ) SAL_THROW_EXTERN_C();
321 
329 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA (
330  rtlDigest Digest,
331  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
332 ) SAL_THROW_EXTERN_C();
333 
352 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_SHA (
353  const void *pData, sal_uInt32 nDatLen,
354  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
355 ) SAL_THROW_EXTERN_C();
356 
357 /*========================================================================
358  *
359  * rtl_digest_SHA1 interface.
360  *
361  *======================================================================*/
362 #define RTL_DIGEST_LENGTH_SHA1 20
363 
375 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createSHA1 (void) SAL_THROW_EXTERN_C();
376 
385  rtlDigest Digest
386 ) SAL_THROW_EXTERN_C();
387 
395 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA1 (
396  rtlDigest Digest,
397  const void *pData, sal_uInt32 nDatLen
398 ) SAL_THROW_EXTERN_C();
399 
407 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA1 (
408  rtlDigest Digest,
409  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
410 ) SAL_THROW_EXTERN_C();
411 
430 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_SHA1 (
431  const void *pData, sal_uInt32 nDatLen,
432  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
433 ) SAL_THROW_EXTERN_C();
434 
435 #define RTL_DIGEST_LENGTH_HMAC_MD5 RTL_DIGEST_LENGTH_MD5
436 
446 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createHMAC_MD5 (void) SAL_THROW_EXTERN_C();
447 
452  rtlDigest Digest
453 ) SAL_THROW_EXTERN_C();
454 
464 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_initHMAC_MD5 (
465  rtlDigest Digest,
466  const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen
467 ) SAL_THROW_EXTERN_C();
468 
472 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateHMAC_MD5 (
473  rtlDigest Digest,
474  const void *pData, sal_uInt32 nDatLen
475 ) SAL_THROW_EXTERN_C();
476 
480 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getHMAC_MD5 (
481  rtlDigest Digest,
482  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
483 ) SAL_THROW_EXTERN_C();
484 
503 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_HMAC_MD5 (
504  const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen,
505  const void *pData, sal_uInt32 nDatLen,
506  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
507 ) SAL_THROW_EXTERN_C();
508 
509 #define RTL_DIGEST_LENGTH_HMAC_SHA1 RTL_DIGEST_LENGTH_SHA1
510 
524 SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createHMAC_SHA1 (void) SAL_THROW_EXTERN_C();
525 
534  rtlDigest Digest
535 ) SAL_THROW_EXTERN_C();
536 
550 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_initHMAC_SHA1 (
551  rtlDigest Digest,
552  const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen
553 ) SAL_THROW_EXTERN_C();
554 
562 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 (
563  rtlDigest Digest,
564  const void *pData, sal_uInt32 nDatLen
565 ) SAL_THROW_EXTERN_C();
566 
574 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 (
575  rtlDigest Digest,
576  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
577 ) SAL_THROW_EXTERN_C();
578 
600 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_HMAC_SHA1 (
601  const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen,
602  const void *pData, sal_uInt32 nDatLen,
603  sal_uInt8 *pBuffer, sal_uInt32 nBufLen
604 ) SAL_THROW_EXTERN_C();
605 
627 SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_PBKDF2 (
628  sal_uInt8 *pKeyData , sal_uInt32 nKeyLen,
629  const sal_uInt8 *pPassData, sal_uInt32 nPassLen,
630  const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen,
631  sal_uInt32 nCount
632 ) SAL_THROW_EXTERN_C();
633 
634 #ifdef __cplusplus
635 }
636 #endif
637 
638 #endif // INCLUDED_RTL_DIGEST_H
639 
640 /* 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:223
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:44
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:346
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.