mysql의 password 함수

purewell의 이미지

MySQL 5.x 에서 PASSWORD 함수가 보안을 빌미삼아
4.x 에서 쓰던 것과 다른 알고리즘을 사용하였습니다.

물론 OLD_PASSWORD라는 함수를 두어 4.x와 호환을
주고 있긴 하지만 쓸 수 없는 아주 알딸딸한 상태입니다.

PHP에 보니 Strings 관련 함수에 암호화/해쉬 함수가 많이
있긴 한데 테스트 해보니 4.x 에서 PASSWORD와 동일한
행동을 하는 것이 없습니다.

PHP로 이미 구현한 MySQL 4.x PASSWORD 함수가 어딨는지 알고 싶습니다.

(* 구글님께 빌었더니 잘못된 결과만 뽑아주셔서...)

정태영의 이미지

원하시는 답은 아니고... 패스워드 관련해서는 4.0.x->4.1.x 로 넘어가는 과정에서 바뀐 겁니다 :)

4.1.x 와 5.x 는 호환이 될거에요

오랫동안 꿈을 그리는 사람은 그 꿈을 닮아간다...

http://mytears.org ~(~_~)~
나 한줄기 바람처럼..

purewell의 이미지

정태영 wrote:
원하시는 답은 아니고... 패스워드 관련해서는 4.0.x->4.1.x 로 넘어가는 과정에서 바뀐 겁니다 :)

4.1.x 와 5.x 는 호환이 될거에요

흠... 그럼 4.1.x의 PASSWORD 함수를 구현할 수 있는 방법을 없을까요?

_____________________________
언제나 맑고픈 샘이가...
http://purewell.biz

lifthrasiir의 이미지

mysql 소스 코드의 sql/password.c를 참고하시길 바랍니다. 해당하는 함수는 다음과 같습니다.

void
make_scrambled_password(char *to, const char *password)
{
  SHA1_CONTEXT sha1_context;
  uint8 hash_stage2[SHA1_HASH_SIZE];

  sha1_reset(&sha1_context);
  /* stage 1: hash password */
  sha1_input(&sha1_context, (uint8 *) password, strlen(password));
  sha1_result(&sha1_context, (uint8 *) to);
  /* stage 2: hash stage1 output */
  sha1_reset(&sha1_context);
  sha1_input(&sha1_context, (uint8 *) to, SHA1_HASH_SIZE);
  /* separate buffer is used to pass 'to' in octet2hex */
  sha1_result(&sha1_context, hash_stage2);
  /* convert hash_stage2 to hex string */
  *to++= PVERSION41_CHAR;
  octet2hex(to, hash_stage2, SHA1_HASH_SIZE);
}

요약하자면 sha1 hash에 대한 sha1 hash를 구하는 방법인데... 파이썬에서 해 보니 재현이 잘 안 되네요 -_-;

- 토끼군

익명 사용자의 이미지

purewell wrote:

...
물론 OLD_PASSWORD라는 함수를 두어 4.x와 호환을
주고 있긴 하지만 쓸 수 없는 아주 알딸딸한 상태입니다.
...

혹시, 3.x 대와 호환 아니었나요?

쓰신 글을 보면, 4.x대에 다시 패스워드 메카니즘이 바뀌고, 5.x대에 또 바뀐것으로 보이는데요.
저는 4.x대에서 한번 바뀌고, 이를 위해 old_password를 두었던 것으로 기억(follow up이 여기까지... -- ; )됩니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.