1 // Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef OPENSSL_HEADER_CRYPTO_PEM_INTERNAL_H
16 #define OPENSSL_HEADER_CRYPTO_PEM_INTERNAL_H
17 
18 #include <openssl/pem.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 // PEM_get_EVP_CIPHER_INFO decodes |header| as a PEM header block and writes the
26 // specified cipher and IV to |cipher|. It returns one on success and zero on
27 // error. |header| must be a NUL-terminated string. If |header| does not
28 // specify encryption, this function will return success and set
29 // |cipher->cipher| to NULL.
30 int PEM_get_EVP_CIPHER_INFO(const char *header, EVP_CIPHER_INFO *cipher);
31 
32 // PEM_do_header decrypts |*len| bytes from |data| in-place according to the
33 // information in |cipher|. On success, it returns one and sets |*len| to the
34 // length of the plaintext. Otherwise, it returns zero. If |cipher| specifies
35 // encryption, the key is derived from a password returned from |callback|.
36 int PEM_do_header(const EVP_CIPHER_INFO *cipher, uint8_t *data, long *len,
37                   pem_password_cb *callback, void *u);
38 
39 
40 #ifdef __cplusplus
41 }  // extern "C"
42 #endif
43 
44 #endif  // OPENSSL_HEADER_CRYPTO_PEM_INTERNAL_H
45