ENCRYPT(3POSIX)

πŸ’– ENCRYPT(3POSIX) β€” the POSIX Programmer's Manual one, bestie πŸ’–

okay so before we even get into it: this page lives inside the POSIX Programmer's Manual, bestie. and like β€” huge heads up β€” the Linux implementation of this interface may differ (so go check the matching Linux man page for the actual Linux tea), or honestly the interface might just not be implemented on Linux at all. so keep that in mind before you start coding like it's guaranteed. πŸ™ˆ


✨ PROLOG ✨

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β€” consult the corresponding Linux manual page for details of Linux behavior β€” or the interface may not be implemented on Linux.


🌸 NAME 🌸

encrypt β€” encoding function (CRYPT)


πŸŽ€ SYNOPSIS πŸŽ€

#include <unistd.h>

void encrypt(char block[64], int edflag);

πŸ’… DESCRIPTION πŸ’…

So encrypt() shall give you access to an implementation-defined encoding algorithm. The key that setkey() generated? Yeah, that's the one encrypt() uses to encrypt the string block. iconic teamwork honestly. πŸ”₯

The block argument to encrypt() shall be an array of length 64 bytes, and it's gotta contain only the bytes with values of 0 and 1. that's it. no other values, bestie. The array gets modified in place into a similar array using the key that setkey() set. πŸ’«

Now for edflag, this is the part you actually need to pay attention to:

  • If edflag is 0, the argument is encoded.
  • If edflag is 1, the argument may be decoded (peep the APPLICATION USAGE section for why that "may" is doing so much heavy lifting); and if the argument is not decoded, errno shall be set to [ENOSYS].

encrypt() shall not change the setting of errno if it's successful. so if you're the type who wants to check for error situations, set errno to 0 before you call encrypt(). Then, if errno is non-zero on return? an error has occurred, periodt.

Also, encrypt() need not be thread-safe. just so you know. no cap. πŸ’€


🌈 RETURN VALUE 🌈

encrypt() shall not return a value. that's it, that's the whole section. she's void, she's mysterious, she gives nothing back. 🫢


πŸ’œ ERRORS πŸ’œ

encrypt() shall fail if:

  • ENOSYS β€” The functionality is not supported on this implementation.
The following sections are informative. πŸ‘€ (yes, that means the vibes shift from "rules" to "lore")

⭐ EXAMPLES ⭐

None.

like literally none. nothing. empty. the void. πŸ•³οΈ


πŸ¦‹ APPLICATION USAGE πŸ¦‹

Historical implementations of encrypt() used a rather primitive encoding algorithm. ngl, lowkey embarrassing for them. 😭

In some environments, decoding might not be implemented at all. And the reason is kind of wild: it's related to some Government restrictions on encryption and decryption routines. Historical practice has been to ship a different version of the encryption library without the decryption feature in the routines supplied. So the exported version of encrypt() does encoding but not decoding. iykyk. πŸ™ˆ


πŸ“ RATIONALE πŸ“

None.


πŸ’€ FUTURE DIRECTIONS πŸ’€

A future version of the standard may mark this interface as obsolete or remove it altogether. so like… don't build your whole personality around it, bestie. πŸ’…


🌟 SEE ALSO 🌟

  • crypt()
  • setkey()

The Base Definitions volume of POSIX.1‐2017, <unistd.h>


Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie!! this one's brought to you by IEEE/The Open Group, 2017, and it's the ENCRYPT(3POSIX) page β€” go forth and encrypt responsibly, mwah πŸ’–βœ¨πŸŽ€