Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mysql.jdbc
Class Security

    java.lang.Object
      com.mysql.jdbc.Security

     class Security

extends java.lang.Object

Methods for doing secure authentication with MySQL-4.1 and newer.

Method Summary
`(package private) static byte[]` | `createKeyFromOldPassword(java.lang.String passwd)` Creates key from old password to decode scramble Used in 4.1 authentication with passwords stored pre-4.1 hashing.
`(package private) static byte[]` | `getBinaryPassword(int[] salt, boolean usingNewPasswords)` DOCUMENT ME!
`(package private) static java.lang.String` | `makeScrambledPassword(java.lang.String password)` Creates password to be stored in user database from raw string.
`(package private) static void` | `passwordCrypt(byte[] from, byte[] to, byte[] password, int length)` Encrypt/Decrypt function used for password encryption in authentication Simple XOR is used here but it is OK as we crypt random strings
`(package private) static byte[]` | `passwordHashStage1(java.lang.String password)` Stage one password hashing, used in MySQL 4.1 password handling
`(package private) static byte[]` | `passwordHashStage2(byte[] hashedPassword, byte[] salt)` Stage two password hashing used in MySQL 4.1 password handling
`(package private) static byte[]` | `scramble411(java.lang.String password, java.lang.String seed)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### createKeyFromOldPassword

    static byte[] createKeyFromOldPassword(java.lang.String passwd)
                                    throws java.security.NoSuchAlgorithmException

  Creates key from old password to decode scramble Used in 4.1 authentication with passwords stored pre-4.1 hashing.

  Parameters:
    `passwd` - the password to create the key from
  Returns:
    20 byte generated key
  Throws:
    `java.security.NoSuchAlgorithmException` - if the message digest 'SHA-1' is not available.

### getBinaryPassword

    static byte[] getBinaryPassword(int[] salt,
                                    boolean usingNewPasswords)
                             throws java.security.NoSuchAlgorithmException

  DOCUMENT ME!

  Parameters:
    `salt` - DOCUMENT ME!
    `usingNewPasswords` - DOCUMENT ME!
  Returns:
    DOCUMENT ME!
  Throws:
    `java.security.NoSuchAlgorithmException` - if the message digest 'SHA-1' is not available.

### makeScrambledPassword

    static java.lang.String makeScrambledPassword(java.lang.String password)
                                           throws java.security.NoSuchAlgorithmException

  Creates password to be stored in user database from raw string. Handles Pre-MySQL 4.1 passwords.

  Parameters:
    `password` - plaintext password
  Returns:
    scrambled password
  Throws:
    `java.security.NoSuchAlgorithmException` - if the message digest 'SHA-1' is not available.

### passwordCrypt

    static void passwordCrypt(byte[] from,
                              byte[] to,
                              byte[] password,
                              int length)

  Encrypt/Decrypt function used for password encryption in authentication Simple XOR is used here but it is OK as we crypt random strings

  Parameters:
    `from` - IN Data for encryption
    `to` - OUT Encrypt data to the buffer (may be the same)
    `password` - IN Password used for encryption (same length)
    `length` - IN Length of data to encrypt

### passwordHashStage1

    static byte[] passwordHashStage1(java.lang.String password)
                              throws java.security.NoSuchAlgorithmException

  Stage one password hashing, used in MySQL 4.1 password handling

  Parameters:
    `password` - plaintext password
  Returns:
    stage one hash of password
  Throws:
    `java.security.NoSuchAlgorithmException` - if the message digest 'SHA-1' is not available.

### passwordHashStage2

    static byte[] passwordHashStage2(byte[] hashedPassword,
                                     byte[] salt)
                              throws java.security.NoSuchAlgorithmException

  Stage two password hashing used in MySQL 4.1 password handling

  Parameters:
    `hash` - from passwordHashStage1
    `salt` - salt used for stage two hashing
  Returns:
    result of stage two password hash
  Throws:
    `java.security.NoSuchAlgorithmException` - if the message digest 'SHA-1' is not available.

### scramble411

    static byte[] scramble411(java.lang.String password,
                              java.lang.String seed)
                       throws java.security.NoSuchAlgorithmException

  Throws:
    `java.security.NoSuchAlgorithmException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD