RTEMS | Re-import libcrypt as a proper 3rd-party library (#5332)
Wayne Thornton (@wmthornton-dev)
gitlab at rtems.org
Fri Sep 5 22:27:04 UTC 2025
Wayne Thornton commented: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5332#note_130511
Update: I've merged the newest upstream 'crypt.h' with the changes already made in the RTEMS source tree. I've separated out the code using the __rtems__ preprocessor directive and updated the RTEMS APIs to allow (future) use of the newer additions, such as Blowfish and NTHash from upstream. I've the entire cpukit/libcrypt directory to contrib/cpukit/libcrypt and compiled from source for Sparc on my local machine and ran tests. Everything compiles, but as has always happened for me, 'crypt01.exe' fails testing. This occurred even prior to these changes so I assume it's something expected. The source code of the modified 'crypt.h' header is below:
`/* LINTLIBRARY */
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999
* Mark Murray. All rights reserved.
*
* Copyright (C) 2025
* Wayne Michael Thornton (WMT). <wmthornton-dev at outlook.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY MARK MURRAY AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL MARK MURRAY OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef _CRYPT_H
#define _CRYPT_H
#ifdef __rtems__
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/cdefs.h>
#define __BEGIN_DECLS
#define __END_DECLS
#else
/* magic sizes */
#define MD4_SIZE 16
#define MD5_SIZE 16
#endif /* __rtems__ */
#ifdef __rtems__
__BEGIN_DECLS
struct crypt_data {
char buffer[256];
};
struct crypt_format {
SLIST_ENTRY(crypt_format) link;
char *(*func)(const char *, const char *, struct crypt_data *);
const char *magic;
};
#define CRYPT_FORMAT_INITIALIZER(func, magic) { { NULL }, (func), (magic) }
extern struct crypt_format crypt_des_format;
extern struct crypt_format crypt_md5_format;
extern struct crypt_format crypt_nthash_format;
extern struct crypt_format crypt_blowfish_format;
extern struct crypt_format crypt_sha256_format;
extern struct crypt_format crypt_sha512_format;
void crypt_add_format(struct crypt_format *);
char *crypt_r(const char *, const char *, struct crypt_data *);
char *crypt_des_r(const char *, const char *, struct crypt_data *);
char *crypt_md5_r(const char *, const char *, struct crypt_data *);
char *crypt_nthash_r(const char *, const char *, struct crypt_data *);
char *crypt_blowfish_r(const char *, const char *, struct crypt_data *);
char *crypt_sha256_r(const char *, const char *, struct crypt_data *);
char *crypt_sha512_r(const char *, const char *, struct crypt_data *);
void _crypt_to64(char *s, u_long v, int n);
#define b64_from_24bit _crypt_b64_from_24bit
void _crypt_b64_from_24bit(uint8_t, uint8_t, uint8_t, int, int *, char **);
__END_DECLS
#else
int crypt_des(const char *pw, const char *salt, char *buf);
int crypt_md5(const char *pw, const char *salt, char *buf);
int crypt_nthash(const char *pw, const char *salt, char *buf);
int crypt_blowfish(const char *pw, const char *salt, char *buf);
int crypt_sha256 (const char *pw, const char *salt, char *buf);
int crypt_sha512 (const char *pw, const char *salt, char *buf);
extern void _crypt_to64(char *s, u_long v, int n);
extern void b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, char **cp);
#endif /* __rtems__ */
#endif /* _CRYPT_H */
`
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5332#note_130511
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250905/3bb83b92/attachment-0001.htm>
More information about the bugs
mailing list