public final byte[] doFinal() throws IllegalStateException {
        chooseFirstProvider();
        if (initialized == false) {
            throw new IllegalStateException("MAC not initialized");
        }
        byte[] mac = spi.engineDoFinal();
        spi.engineReset();
        return mac;
    }
public final byte [ ] doFinal ( ) throws IllegalStateException { chooseFirstProvider ( ) ; if ( initialized == false ) { throw new IllegalStateException ( "MAC not initialized" ) ; } byte [ ] mac = spi . engineDoFinal ( ) ; spi . engineReset ( ) ; return mac ; }
Finishes the MAC operation.

<p>A call to this method resets this <code>Mac</code> object to the
state it was in when previously initialized via a call to
<code>init(Key)</code> or
<code>init(Key, AlgorithmParameterSpec)</code>.
That is, the object is reset and available to generate another MAC from
the same key, if desired, via new calls to <code>update</code> and
<code>doFinal</code>.
(In order to reuse this <code>Mac</code> object with a different key,
it must be reinitialized via a call to <code>init(Key)</code> or
<code>init(Key, AlgorithmParameterSpec)</code>.

@return the MAC result.

@exception IllegalStateException if this <code>Mac</code> has not been
initialized.