Code example for Mac

Methods: doFinal, reset, update

0
                                                                    SecurityException { 
        Mac mac = currentMAC == null ? defaultMAC : currentMAC;
        if (mac == null) {
            throw new SecurityException("no key for mac calculation");
        } 
        mac.reset();
        mac.update(data, start, end - start + 1);
        mac.doFinal(data, end + 1);
    } 
 
    /** 
     * validate a mac that is at the end of a piece of byte array data 
     *  
     * @param data 
     *            to validate 
     * @param start 
     *            of the data - inclusive 
     * @param end 
     *            of the data - inlcusive, mac present after this 
     * @throws SecurityException 
     *             - the mac does not match