src/main/java/org/tinyradius/packet/AccessRequest.java
private boolean verifyChapPassword(String plaintext)
        throws RadiusException {
        if (plaintext == null || plaintext.length() == 0) {
            throw new IllegalArgumentException("plaintext must not be empty");
        }
        if (chapChallenge == null || chapChallenge.length != 16) {
            throw new RadiusException("CHAP challenge must be 16 bytes");
        }
        if (chapPassword == null || chapPassword.length != 17) {
            throw new RadiusException("CHAP password must be 17 bytes");
        }

        byte chapIdentifier = chapPassword[0];
        MessageDigest md5 = getMd5Digest();
        md5.reset();
        md5.update(chapIdentifier);
        md5.update(RadiusUtil.getUtf8Bytes(plaintext));
        byte[] chapHash = md5.digest(chapChallenge);

        // compare
        for (int i = 0; i < 16; i++) {
            if (chapHash[i] != chapPassword[i + 1]) {
                return false;
            }
        }
        return true;
    }
/**
     * Verifies a CHAP password against the given plaintext password.
     *
     * @return plain-text password
     */
Verifies a CHAP password against the given plaintext password.

@return plain-text password
Verifies a CHAP password against the given plaintext password . @return plain - text password
private boolean verifyChapPassword(String plaintext)
        throws RadiusException {
        if (plaintext == null || plaintext.length() == 0) {
            throw new IllegalArgumentException("plaintext must not be empty");
        }
        if (chapChallenge == null || chapChallenge.length != 16) {
            throw new RadiusException("CHAP challenge must be 16 bytes");
        }
        if (chapPassword == null || chapPassword.length != 17) {
            throw new RadiusException("CHAP password must be 17 bytes");
        }
        byte chapIdentifier = chapPassword[0];
        MessageDigest md5 = getMd5Digest();
        md5.reset();
        md5.update(chapIdentifier);
        md5.update(RadiusUtil.getUtf8Bytes(plaintext));
        byte[] chapHash = md5.digest(chapChallenge);
        for (int i = 0; i < 16; i++) {
            if (chapHash[i] != chapPassword[i + 1]) {
                return false;
            }
        }
        return true;
    }
private boolean verifyChapPassword ( String plaintext ) throws RadiusException { if ( plaintext == null || plaintext . length ( ) == 0 ) { throw new IllegalArgumentException ( "plaintext must not be empty" ) ; } if ( chapChallenge == null || chapChallenge . length != 16 ) { throw new RadiusException ( "CHAP challenge must be 16 bytes" ) ; } if ( chapPassword == null || chapPassword . length != 17 ) { throw new RadiusException ( "CHAP password must be 17 bytes" ) ; } byte chapIdentifier = chapPassword [ 0 ] ; MessageDigest md5 = getMd5Digest ( ) ; md5 . reset ( ) ; md5 . update ( chapIdentifier ) ; md5 . update ( RadiusUtil . getUtf8Bytes ( plaintext ) ) ; byte [ ] chapHash = md5 . digest ( chapChallenge ) ; for ( int i = 0 ; i < 16 ; i ++ ) { if ( chapHash [ i ] != chapPassword [ i + 1 ] ) { return false ; } } return true ; }
Verifies a CHAP password against the given plaintext password.
Verifies a CHAP password against the given plaintext password .
// compare
