Code example for ShortBufferException

0
 
        byte[]  secret = bigIntToBytes(result);
 
        if (sharedSecret.length - offset < secret.length)
        { 
            throw new ShortBufferException("DHKeyAgreement - buffer too short");
        } 
 
        System.arraycopy(secret, 0, sharedSecret, offset, secret.length);
 
        return secret.length;
    } 
 
    protected SecretKey engineGenerateSecret(
        String algorithm) 
    { 
        if (x == null)
        { 
            throw new IllegalStateException("Diffie-Hellman not initialised.");
        }