if ( buffer.hasArray() ) {
byte[] bufferBytes = buffer.array();
int offset = buffer.arrayOffset();
int position = buffer.position();
int limit = buffer.limit();
signatureGenerator.update( bufferBytes, offset + position, limit - position );
buffer.position( limit );
} else {
int length = buffer.remaining();
byte[] bytes = new byte[JCAUtil.getTempArraySize( length )];
while ( length > 0 ) {