1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_CRYPTO_CRYPTTOOLS_HXX
21 #define INCLUDED_OOX_CRYPTO_CRYPTTOOLS_HXX
23 #include <config_oox.h>
25 #include <rtl/ustring.hxx>
28 #include <openssl/evp.h>
29 #include <openssl/sha.h>
30 #endif // USE_TLS_OPENSSL
38 #include <rtl/digest.h>
58 EVP_CIPHER_CTX mContext
;
61 PK11Context
* mContext
;
67 const EVP_CIPHER
* getCipher(CryptoType type
);
71 std::vector
<sal_uInt8
>& key
,
72 std::vector
<sal_uInt8
>& iv
,
74 CK_ATTRIBUTE_TYPE operation
);
78 Crypto(CryptoType type
);
83 virtual sal_uInt32
update(
84 std::vector
<sal_uInt8
>& output
,
85 std::vector
<sal_uInt8
>& input
,
86 sal_uInt32 inputLength
= 0) = 0;
89 class Decrypt
: public Crypto
92 Decrypt(std::vector
<sal_uInt8
>& key
, CryptoType type
);
93 Decrypt(std::vector
<sal_uInt8
>& key
, std::vector
<sal_uInt8
>& iv
, CryptoType type
);
95 virtual sal_uInt32
update(
96 std::vector
<sal_uInt8
>& output
,
97 std::vector
<sal_uInt8
>& input
,
98 sal_uInt32 inputLength
= 0) SAL_OVERRIDE
;
101 static sal_uInt32
aes128ecb(
102 std::vector
<sal_uInt8
>& output
,
103 std::vector
<sal_uInt8
>& input
,
104 std::vector
<sal_uInt8
>& key
);
108 class Encrypt
: public Crypto
111 Encrypt(std::vector
<sal_uInt8
>& key
, CryptoType type
);
112 Encrypt(std::vector
<sal_uInt8
>& key
, std::vector
<sal_uInt8
>& iv
, CryptoType type
);
114 virtual sal_uInt32
update(
115 std::vector
<sal_uInt8
>& output
,
116 std::vector
<sal_uInt8
>& input
,
117 sal_uInt32 inputLength
= 0) SAL_OVERRIDE
;
130 static const sal_uInt32 DIGEST_LENGTH_SHA1
;
131 static const sal_uInt32 DIGEST_LENGTH_SHA512
;
137 EVP_MD_CTX
* mpContext
;
141 HASHContext
* mpContext
;
145 Digest(DigestType eType
);
148 bool update(std::vector
<sal_uInt8
>& input
);
149 bool finalize(std::vector
<sal_uInt8
>& digest
);
151 sal_uInt32
getLength();
153 static bool sha1( std::vector
<sal_uInt8
>& digest
, std::vector
<sal_uInt8
>& input
);
154 static bool sha512(std::vector
<sal_uInt8
>& digest
, std::vector
<sal_uInt8
>& input
);
157 bool sha1( std::vector
<sal_uInt8
>& digest
, std::vector
<sal_uInt8
>& input
);
158 bool sha512(std::vector
<sal_uInt8
>& digest
, std::vector
<sal_uInt8
>& input
);
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */