crypt

CRYPT(3)                   Linux Programmer's Manual                  CRYPT(3)



åå
       crypt, crypt_r - ãã¹ã¯ã¼ãã¨ãã¼ã¿ã®æå·å

æ¸å¼
       #define _XOPEN_SOURCE       /* feature_test_macros(7) åç§ */
       #include <unistd.h>

       char *crypt(const char *key, const char *salt);

       #define _GNU_SOURCE         /* See feature_test_macros(7) */
       #include <crypt.h>

       char *crypt_r(const char *key, const char *salt,
                     struct crypt_data *data);

       -lcrypt ã§ãªã³ã¯ããã

説æ
       crypt()  ã¯ãã¹ã¯ã¼ãæå·åé¢æ°ã§ããã
       éµæ¢ç´¢ã®ãã¼ãã¦ã§ã¢ã«ããå®è£ã妨ããããã«(ãã®ä»ã«ããããã)  å¤æ´ãã Data
       Encryption Standard ã¢ã«ã´ãªãºã ãåã«ãã¦ããã

       key ã¯ã¦ã¼ã¶ãå¥åãããã¹ã¯ã¼ãã§ããã

       salt ã¯éå [azAZ09./] ããé¸ã°ãã 2 æåã®æååã§ããã ãã®æå‐
       åã¯ã¢ã«ã´ãªãºã ã®åºåã 4096 éãã«ããä¹±ãã®ã«ä½¿ãããã

       key ã®æåã® 8 æåã®åæåããä¸ä½ 7 ããããã¨ã£ã¦ 56 ãããã®éµãå¾ãããã ãã® 56
       ãããã®éµã¯ç¹å®ã®æåå(ãµã¤ãã¯ãã¹ã¦ 0 ã®æåå)  ãç¹°ãè¿ãæå·åããã®ã«ç¨ããããã
       è¿ãå¤ã¯æå·åããããã¹ã¯ã¼ãã¸ã®ãã¤ã³ã¿ã§ã13 ã®å°åå¯è½ãª ASCII æå ãããªã(æåã®
       2 æå㯠salt ãã®ãã®)ã
       è¿ãå¤ã¯ãé¢æ°å¼åºãã®ãã³ã«ä¸æ¸ããããéçãªãã¼ã¿ã¸ã®ãã¤ã³ã¿ã§ããã

       è¦å: éµç©ºé㯠2**56 = 7.2e16 ã®å¯è½ãªå¤ããæãã
       ãã®éµç©ºéã®å¨æ¢ç´¢ã¯å¼·åãªä¸¦åè¨ç®æ©ã使ãã°å¯è½ã§ãããã¾ã crack(1)
       ã®ãããªã½ããã¦ã§ã¢ã¯ãã®éµç©ºéã®ä¸ã§ãå¤ãã®äººã«ãã¹ã¯ã¼ãã¨ãã¦
       使ããããããªéµã«ã¤ãã¦ã®å¨æ¢ç´¢ãå¯è½ã§ããã
       ããããããã¹ã¯ã¼ããé¸æããã¨ãã«ã¯ããããªãã¨ãã ä¸è¬çã«ä½¿ãããåèªã¨ååã¯é¿ããã¹ãã§ããã
       passwd(1) ã使ãæã«ã¯ã¯ã©ãã¯ãããããã¹ã¯ã¼ãã«ã¤ãã¦ã®æ¤æ»ããããã¨ã æ¨å¥¨ãããã

       DES ã¢ã«ã´ãªãºã ã«ã¯ããã¤ãã®çããããããã«ãã£ã¦ãã¹ã¯ã¼ãèªè¨¼ä»¥å¤ã« crypt()
       ã使ãã®ã¯ããã¸ããããªãé¸æã¨ãªã£ã¦ããããã crypt()  ãæå·ãã‐
       ã¸ã§ã¯ãã«ä½¿ããã¨ããæ¡ããã£ã¦ãããªãã°ãããã¯ãããã»ãã
       ãããæå·åã«ã¤ãã¦ã®ããæ¬ã¨èª°ã§ãå¥æã§ãã DES ã©ã¤ãã©ãªã®ã²ã¨ã¤ã æã«ãããã¹ãã ã

       crypt_r()  㯠crypt()  ã®åå¥å¯è½çã§ããã data
       ã§ç¤ºãããæ§é ä½ã¯çµæãã¼ã¿ã®ä¿åã¨æå ±ã®ç®¡çã«ä½¿ãããã
       ãã®æ§é ä½ã«å¯¾ãã¦(ã¡ã¢ãªãå²ãå½ã¦ããã¨ä»¥å¤ã«)å¼ã³åºãåãããã¹ãå¯ä¸ã® ãã¨ã¯ã
       crypt_r()  ã®ååã®å¼ã³åºãã®åã« data->initialized ãã¼ãã«ãããã¨ã ãã§ããã

è¿ãå¤
       æåã®å ´åã«ã¯ãæå·åããããã¹ã¯ã¼ãã¸ã®ãã¤ã³ã¿ã¼ãè¿ãããã ã¨ã©ã¼ã®å ´åã«ã¯ NULL
       ãè¿ãããã

ã¨ã©ã¼
       ENOSYS crypt()  é¢æ°ãå®è£ããã¦ããªããå¤åã¢ã¡ãªã«ã®è¼¸åºè¦å¶ã®ããã«ã

æºæ
       crypt(): SVr4, 4.3BSD, POSIX.1-2001.  crypt_r()  㯠GNU æ¡å¼µã§ããã

注æ
   glibc ã§ã®æ³¨æ
       ãã®é¢æ°ã® glibc2 çã¯è¿½å ã®æå·åã¢ã«ã´ãªãºã ã«å¯¾å¿ãã¦ããã

       ãã salt ã®æååã "$id$" ã§å§ã¾ã£ã¦ãã¦ã"$" ã§çµãã£ã¦ããæååã ç¶ãã¦ããå ´å:

              $id$salt$encrypted

       DES ã使ã代ããã«ã id ã§ä½¿ç¨ããæå·åææ³ãèå¥ããããããã¹ã¯ã¼ãæå‐
       åã®æ®ãã®é¨åã解éãã æ¹æ³ã決å®ããã id ã®å¤ã¨ãã¦ã以ä¸ã®å¤ã«å¯¾å¿ãã¦ãã:

              ID  | Method
              ──────────────────────────────────────────────────────────
              1   | MD5
              2a  | Blowfish (æ¬æµã® glibc ã«ã¯å¥ã£ã¦ããªã;
                  | ããã¤ãã® Linux ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã§è¿½å ããã¦ãã)
              5   | SHA-256 (glibc 2.7 以é)
              6   | SHA-512 (glibc 2.7 以é)

       å¾ã£ã¦ã$5$salt$encrypted 㯠SHA-256 ã§ã¨ã³ã³ã¼ãããã
       ãã¹ã¯ã¼ãã§ããã$6$salt$encrypted 㯠SHA-512 㧠ã¨ã³ã³ã¼ãããããã¹ã¯ã¼ãã§ããã

       "salt" 㯠salt ã«ããã "$id$" ã«å¼ãç¶ã 16 æå以ä¸ã® æååã§ããã ãã¹ã¯ã¼ãæå‐
       åã®æå·åé¨åã¯å®éã«è¨ç®ããããã¹ã¯ã¼ãã§ããã ãã®æååã®ãµã¤ãºã¯åºå®ã§ãã:

       MD5     | 22 characters
       SHA-256 | 43 characters
       SHA-512 | 86 characters

       "salt" 㨠"encrypted" ã®æå㯠[azAZ09./] ã®éåãã é¸ã°ããã MD5 㨠SHA
       ã®å®è£ã§ã¯ã key å¨ä½ãæå³ããã (DES ã®å ´åã«ã¯æåã® 8 æåã ãã«æå³ããã)ã

é¢é£é ç®
       login(1), passwd(1), encrypt(3), getpass(3), passwd(5)

ãã®ææ¸ã«ã¤ãã¦
       ãã® man ãã¼ã¸ã¯ Linux man-pages ããã¸ã§ã¯ãã®ãªãªã¼ã¹ 3.51 ã®ä¸é¨
       ã§ãããããã¸ã§ã¯ãã®èª¬æã¨ãã°å ±åã«é¢ããæå ±ã¯
       http://www.kernel.org/doc/man-pages/ ã«æ¸ããã¦ããã



                                  2011-09-15                          CRYPT(3)