/* Copyright (C) 2001-2023 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of the license contained in the file LICENSE in this distribution. Refer to licensing information at http://www.artifex.com or contact Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, CA 94129, USA, for further information. */ /* Adobe Type 1 encryption/decryption. */ #include "stdpre.h" #include "gstypes.h" #include "gscrypt1.h" /* Encrypt a string. */ int gs_type1_encrypt(byte * dest, const byte * src, uint len, crypt_state * pstate) { crypt_state state = *pstate; const byte *from = src; byte *to = dest; uint count = len; while (count) { encrypt_next(*from, state, *to); from++, to++, count--; } *pstate = state; return 0; } /* Decrypt a string. */ int gs_type1_decrypt(byte * dest, const byte * src, uint len, crypt_state * pstate) { crypt_state state = *pstate; const byte *from = src; byte *to = dest; uint count = len; while (count) { /* If from == to, we can't use the obvious */ /* decrypt_next(*from, state, *to); */ byte ch = *from++; decrypt_next(ch, state, *to); to++, count--; } *pstate = state; return 0; }