Code example for ShortBufferException

0
        byte[] secret = engineGenerateSecret();
 
        if (sharedSecret.length - offset < secret.length)
        { 
            throw new ShortBufferException(kaAlgorithm + " key agreement: need " + secret.length + " bytes");
        } 
 
        System.arraycopy(secret, 0, sharedSecret, offset, secret.length);
         
        return secret.length;
    } 
 
    protected SecretKey engineGenerateSecret(
        String algorithm)
        throws NoSuchAlgorithmException 
    { 
        byte[] secret = bigIntToBytes(result);
 
        // BEGIN android-removed 
        // if (kdf != null) 
        // {