ENCRYPT(3P)

πŸ’– ENCRYPT(3P) β€” the POSIX Programmer's Manual girlie πŸ’–

okay bestie, so this is encrypt(3P) from the POSIX Programmer's Manual (IEEE/The Open Group, 2017 β€” more on that at the bottom πŸŽ€). Sit down, hydrate, let's get into it.

✨ PROLOG ✨

so like, this 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. πŸ’€ yeah. it's giving "maybe not even here."


πŸ‘‘ NAME πŸ‘‘

encrypt β€” encoding function (CRYPT)

like. that's the name. it encodes. it's part of CRYPT. periodt.


🌸 SYNOPSIS 🌸

#include <unistd.h>

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

two arguments, no return value, no drama (well, some drama, see ERRORS).


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so encrypt() shall provide access to an implementation-defined encoding algorithm. note that: implementation-defined. it's not telling you what the algorithm is, it's just telling you there is one. the key generated by setkey() is used to encrypt the string block with encrypt().

the block argument to encrypt() shall be an array of length 64 bytes containing only the bytes with values of 0 and 1. yes bestie, only 0s and 1s. bit values, not characters, not vibes. the array is modified in place to a similar array using the key set by setkey().

now the flag, because there's always a flag:

  • if edflag is 0, the argument is encoded ✨
  • if edflag is 1, the argument may be decoded (see the APPLICATION USAGE section, it's important i promise); if the argument is not decoded, errno shall be set to [ENOSYS].
🚨 and here's the sneaky part: encrypt() shall not change the setting of errno if successful. so if you wanna actually catch errors, an application wishing to check for error situations should set errno to 0 before calling encrypt(). if errno is non-zero on return, an error has occurred. set it to zero first or you're just reading stale vibes, fr fr.

also: the encrypt() function need not be thread-safe. ngl that's a bit of a red flag but it is what it is. πŸ’…


πŸ’« RETURN VALUE πŸ’«

the encrypt() function shall not return a value. it's void. it gives you nothing back. it just changes your array. main character energy honestly, doing the work and taking zero credit. πŸ’…


πŸ”₯ ERRORS πŸ”₯

the encrypt() function shall fail if:

  • ENOSYS β€” the functionality is not supported on this implementation. like, it's just not here bestie. 🫢

the following sections are informative. (translation: the standard said "this part is just lore, not law" ✨)


πŸ“ EXAMPLES πŸ“

None. 😭 yeah. nothing. zero examples. we're on our own, bestie. good luck out there.


🧚 APPLICATION USAGE 🧚

historical implementations of the encrypt() function used a rather primitive encoding algorithm. so like. don't build your whole security model on this, okay? i'm just the messenger. πŸ™ˆ

in some environments, decoding might not be implemented. this is 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. thus the exported version of encrypt() does encoding but not decoding.

so when edflag is 1? yeah. that's the "may be decoded" from before. it might not be. that's why [ENOSYS] exists. iykyk. 🌈


πŸ’œ RATIONALE πŸ’œ

None. nothing. the rationale section said "no thoughts, head empty." πŸŽ€


⭐ FUTURE DIRECTIONS ⭐

a future version of the standard may mark this interface as obsolete or remove it altogether. so like... this whole page might get yeeted from the standard one day. πŸ’€ not to be dramatic but that's exactly what it says. enjoy it while it lasts bestie.


πŸ’… SEE ALSO πŸ’…

  • crypt()
  • setkey()

and from The Base Definitions volume of POSIX.1‐2017: <unistd.h> β€” that's where the #include comes from, obviously. ✨


okay so legal time, but make it cute:

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 .


🫢 bestie disclaimer: if this version and the real IEEE/The Open Group Standard ever disagree, the Standard wins. it's the referee. i'm just the hype girl.

and that's the page!! IEEE/The Open Group, 2017, ENCRYPT(3P) β€” slay, stay encoded, and set your errno to 0 before you call anything. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from