/// <summary> /// Update the digest using the specified ByteBuffer. The digest is /// updated using the {@code input.remaining()} bytes starting /// at {@code input.position()}. /// Upon return, the buffer's position will be equal to its limit; /// its limit will not have changed. /// </summary> /// <param name="input"> the ByteBuffer /// @since 1.5 </param> protected internal virtual void EngineUpdate(ByteBuffer input) { if (input.HasRemaining() == false) { return; } if (input.HasArray()) { sbyte[] b = input.Array(); int ofs = input.ArrayOffset(); int pos = input.Position(); int lim = input.Limit(); EngineUpdate(b, ofs + pos, lim - pos); input.Position(lim); } else { int len = input.Remaining(); int n = JCAUtil.getTempArraySize(len); if ((TempArray == null) || (n > TempArray.Length)) { TempArray = new sbyte[n]; } while (len > 0) { int chunk = System.Math.Min(len, TempArray.Length); input.Get(TempArray, 0, chunk); EngineUpdate(TempArray, 0, chunk); len -= chunk; } } }
/// <summary> /// Updates the data to be signed or verified using the specified /// ByteBuffer. Processes the {@code data.remaining()} bytes /// starting at at {@code data.position()}. /// Upon return, the buffer's position will be equal to its limit; /// its limit will not have changed. /// </summary> /// <param name="input"> the ByteBuffer /// @since 1.5 </param> protected internal virtual void EngineUpdate(ByteBuffer input) { if (input.HasRemaining() == false) { return; } try { if (input.HasArray()) { sbyte[] b = input.Array(); int ofs = input.ArrayOffset(); int pos = input.Position(); int lim = input.Limit(); EngineUpdate(b, ofs + pos, lim - pos); input.Position(lim); } else { int len = input.Remaining(); sbyte[] b = new sbyte[JCAUtil.getTempArraySize(len)]; while (len > 0) { int chunk = System.Math.Min(len, b.Length); input.Get(b, 0, chunk); EngineUpdate(b, 0, chunk); len -= chunk; } } } catch (SignatureException e) { // is specified to only occur when the engine is not initialized // this case should never occur as it is caught in Signature.java throw new ProviderException("update() failed", e); } }