{{위키데이터 속성 추적}}
{{다른 뜻|블로피시||bcrypt 파일 암호화 유틸리티}}
{{소문자}}
{{암호 방식 정보
| name = bcrypt
| image =
| caption =
<!-- General -->
| designers = [[Niels Provos]], David Mazières
| publish date = 1999
| series =
| derived from = [[블로피시]]
| derived to =
| related to =
| certification =
<!-- Detail -->
| digest size = 184비트
| block size = 
| structure = 
| rounds = 비용 변수에 따라 가변적
| cryptanalysis =
}}

'''bcrypt'''는 [[블로피시]] 암호에 기반을 둔 [[암호화 해시 함수]]로서 [[Niels Provos]]와 David Mazières가 설계하였으며 1999년 [[USENIX]]에서 발표되었다.<ref name=provos>{{저널 인용| url = http://www.usenix.org/events/usenix99/provos/provos_html/node1.html | title = A Future-Adaptable Password Scheme | first = Niels | last = Provos |author2=Mazières, David | year = 1999 |author3=Talan Jason Sutton 2012 | journal = Proceedings of 1999 USENIX Annual Technical Conference | pages = 81–92}}</ref> [[레인보 테이블]] 공격 방지를 위해 [[솔트 (암호학)|솔트]]를 통합한 bcrypt는 적응형 함수의 하나이다. 시간이 지남에 따라 속도 저하를 위해 반복 횟수가 증가가 수반될 수 있으므로 연산 파워의 증가에도 [[브루트 포스 검색]] 공격에 대한 저항을 유지하게 된다.

bcrypt 함수는 [[OpenBSD]]<ref name=original>{{웹 인용|url=//cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/crypt/bcrypt.c|title= Commit of first work to repo|date=13 Feb 1997}}</ref> 및 [[수세 리눅스]] 등의 일부 [[리눅스 배포판]]을 포함한 기타 시스템용 기본 암호 [[해시 함수]]이다.<ref>{{웹 인용|url=https://www.suse.com/support/security/advisories/2011_35_blowfish.html |title=SUSE Security Announcement: (SUSE-SA:2011:035) |date=23 August 2011 |access-date=20 August 2015 |quote=SUSE's crypt() implementation supports the blowfish password hashing function (id $2a) and system logins by default also use this method. |url-status=dead |archive-url=https://web.archive.org/web/20160304094921/https://www.suse.com/support/security/advisories/2011_35_blowfish.html |archive-date=4 March 2016 }}</ref>

[[C (프로그래밍 언어)|C]], [[C++]], [[C 샤프|C#]], [[Elixir]],<ref>{{웹 인용|last1=Whitlock |first1=David |title=Bcrypt Elixir: bcrypt password hashing algorithm for Elixir. |url=https://github.com/riverrun/bcrypt_elixir |website=GitHub |publisher=riverrun}}</ref> [[Go]],<ref>{{웹 인용|url=https://godoc.org/golang.org/x/crypto/bcrypt|title=Package bcrypt|website=godoc.org}}</ref> [[Java]],<ref>{{웹 인용|url=http://www.mindrot.org/projects/jBCrypt/|title=jBCrypt - strong password hashing for Java|website=www.mindrot.org|language=en|access-date=2017-03-11}}</ref><ref>{{웹 인용|url=https://github.com/patrickfav/bcrypt|title=bcrypt - A Java standalone implementation of the bcrypt password hash function|website=github.com|language=en|access-date=2018-07-19}}</ref> [[자바스크립트]],<ref>{{웹 인용|url=https://www.npmjs.com/package/bcryptjs|title=bcryptjs|website=npm}}</ref> [[펄]], [[PHP]], [[파이썬]],<ref>{{웹 인용|url=https://github.com/pyca/bcrypt/|title=bcrypt: Modern password hashing for your software and your servers|first=Donald|last=Stufft|via=PyPI}}</ref> [[Ruby]] 등의 언어용으로 bcrypt 구현체가 존재한다.

== 개요 ==
bcrypt 해시 문자열은 다음의 형태에 속한다:

 $2b$[cost]$[22 character salt][31 character hash]

예:

 $2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
  \/ \/ \____________________/\_____________________________/
 Alg Cost       Salt                        Hash

여기서
* <code>2a</code>: 해시 알고리즘 식별자 (bcrypt)
* <code>10</code>: Cost factor (2<sup><code>10</code></sup> ==> 1,024 rounds)
* <code>N9qo8uLOickgx2ZMRZoMye</code>: 16바이트(128비트) 솔트, base64-encoded to 22 characters
* <code>IjZAgcfl7p92ldGxad68LJZdL17lhWy</code>: 24바이트(192비트) 해시, base64-encoded to 31 characters

== 알고리즘 ==
 <span style="color: #004DBB;">'''Function'''</span> bcrypt
    <span style="color: #004DBB;">'''Input:'''</span>
       cost:     Number (4..31)                      <span style="color: green;">log<sub>2</sub>(Iterations). e.g. 12 ==> 2<sup>12</sup> = 4,096 iterations</span>
       salt:     array of Bytes (16 bytes)           <span style="color: green;">random salt</span>
       password: array of Bytes (1..72 bytes)        <span style="color: green;">UTF-8 encoded password</span>
    <span style="color: #004DBB;">'''Output:'''</span>
       hash:     array of Bytes (24 bytes)

    <span style="color: green;">//Initialize Blowfish state with expensive key setup algorithm</span>
    <span style="color: green;">//P: array of 18 subkeys (UInt32[18])</span>
    <span style="color: green;">//S: Four substitution boxes (S-boxes), S<sub>0</sub>...S<sub>3</sub>. Each S-box is 1,024 bytes (UInt32[256])</span>
    ''P'', ''S'' ← EksBlowfishSetup(''cost'', ''salt'', ''password'')

    <span style="color: green;">//Repeatedly encrypt the text "OrpheanBeholderScryDoubt" 64 times</span>
    ''ctext'' ← <span style="color: maroon">''"OrpheanBeholderScryDoubt"''</span>  <span style="color: green;">//24 bytes ==> three 64-bit blocks</span>
    <span style="color: #004DBB;">'''repeat'''</span> (64)
       ''ctext'' ← EncryptECB(''P'', ''S'', ''ctext'') <span style="color: green;">//encrypt using standard Blowfish in ECB mode</span>

    <span style="color: green;">//24-byte ''ctext'' is resulting password hash</span>
    <span style="color: #004DBB;">'''return'''</span> Concatenate(''cost'', ''salt'', ''ctext'')

== 같이 보기 ==
* [[Argon2]]
* [[PBKDF2]]
* [[scrypt]]

== 각주 ==
{{각주}}

== 외부 링크 ==
* [https://www.openwall.com/crypt/ crypt_blowfish, the implementation maintained by Openwall]

{{암호화 해시}}

[[분류:암호학]]
[[분류:암호 소프트웨어]]