/src/ghostpdl/base/gscrypt1.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2001-2023 Artifex Software, Inc. |
2 | | All Rights Reserved. |
3 | | |
4 | | This software is provided AS-IS with no warranty, either express or |
5 | | implied. |
6 | | |
7 | | This software is distributed under license and may not be copied, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* Adobe Type 1 encryption/decryption. */ |
18 | | #include "stdpre.h" |
19 | | #include "gstypes.h" |
20 | | #include "gscrypt1.h" |
21 | | |
22 | | /* Encrypt a string. */ |
23 | | int |
24 | | gs_type1_encrypt(byte * dest, const byte * src, uint len, crypt_state * pstate) |
25 | 0 | { |
26 | 0 | crypt_state state = *pstate; |
27 | 0 | const byte *from = src; |
28 | 0 | byte *to = dest; |
29 | 0 | uint count = len; |
30 | |
|
31 | 0 | while (count) { |
32 | 0 | encrypt_next(*from, state, *to); |
33 | 0 | from++, to++, count--; |
34 | 0 | } |
35 | 0 | *pstate = state; |
36 | 0 | return 0; |
37 | 0 | } |
38 | | /* Decrypt a string. */ |
39 | | int |
40 | | gs_type1_decrypt(byte * dest, const byte * src, uint len, crypt_state * pstate) |
41 | 17.7M | { |
42 | 17.7M | crypt_state state = *pstate; |
43 | 17.7M | const byte *from = src; |
44 | 17.7M | byte *to = dest; |
45 | 17.7M | uint count = len; |
46 | | |
47 | 628M | while (count) { |
48 | | /* If from == to, we can't use the obvious */ |
49 | | /* decrypt_next(*from, state, *to); */ |
50 | 610M | byte ch = *from++; |
51 | | |
52 | 610M | decrypt_next(ch, state, *to); |
53 | 610M | to++, count--; |
54 | 610M | } |
55 | 17.7M | *pstate = state; |
56 | 17.7M | return 0; |
57 | 17.7M | } |