Generated by JsDoc Toolkit 2.3.3-beta on Wed Nov 06 2013 17:43:36 GMT+0100 (MEZ)
HTML template: Codeview

Namespace sjcl.bitArray

Arrays of bits, encoded as arrays of Numbers.
Defined in: bitArray.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 

These objects are the currency accepted by SJCL's crypto functions.

Method Summary
Method Attributes Method Name and Description
<static>  
sjcl.bitArray.bitLength(a)
Find the length of an array of bits.
<static>  
sjcl.bitArray.bitSlice(a, bstart, bend)
Array slices in units of bits.
<static>  
sjcl.bitArray.clamp(a, len)
Truncate an array.
<static>  
sjcl.bitArray.concat(a1, a2)
Concatenate two bit arrays.
<static>  
sjcl.bitArray.equal(a, b)
Compare two arrays for equality in a predictable amount of time.
<static>  
sjcl.bitArray.extract(a, bstart, length)
Extract a number packed into a bit array.
<static>  
sjcl.bitArray.getPartial(x)
Get the number of bits used by a partial word.
<static>  
sjcl.bitArray.partial(len, x, 0)
Make a partial word for a bit array.
Namespace Detail
sjcl.bitArray

These objects are the currency accepted by SJCL's crypto functions.

Most of our crypto primitives operate on arrays of 4-byte words internally, but many of them can take arguments that are not a multiple of 4 bytes. This library encodes arrays of bits (whose size need not be a multiple of 8 bits) as arrays of 32-bit words. The bits are packed, big-endian, into an array of words, 32 bits at a time. Since the words are double-precision floating point numbers, they fit some extra data. We use this (in a private, possibly-changing manner) to encode the number of bits actually present in the last word of the array.

Because bitwise ops clear this out-of-band data, these arrays can be passed to ciphers like AES which want arrays of words.

Method Detail
<static> {Number} sjcl.bitArray.bitLength(a)
Find the length of an array of bits.
Parameters:
{bitArray} a
The array.
Returns:
{Number} The length of a, in bits.
<static> {bitArray} sjcl.bitArray.bitSlice(a, bstart, bend)
Array slices in units of bits.
Parameters:
{bitArray} a
The array to slice.
{Number} bstart
The offset to the start of the slice, in bits.
{Number} bend
The offset to the end of the slice, in bits. If this is undefined, slice until the end of the array.
Returns:
{bitArray} The requested slice.
<static> {bitArray} sjcl.bitArray.clamp(a, len)
Truncate an array.
Parameters:
{bitArray} a
The array.
{Number} len
The length to truncate to, in bits.
Returns:
{bitArray} A new array, truncated to len bits.
<static> {bitArray} sjcl.bitArray.concat(a1, a2)
Concatenate two bit arrays.
Parameters:
{bitArray} a1
The first array.
{bitArray} a2
The second array.
Returns:
{bitArray} The concatenation of a1 and a2.
<static> {boolean} sjcl.bitArray.equal(a, b)
Compare two arrays for equality in a predictable amount of time.
Parameters:
{bitArray} a
The first array.
{bitArray} b
The second array.
Returns:
{boolean} true if a == b; false otherwise.
<static> {Number} sjcl.bitArray.extract(a, bstart, length)
Extract a number packed into a bit array.
Parameters:
{bitArray} a
The array to slice.
{Number} bstart
The offset to the start of the slice, in bits.
{Number} length
The length of the number to extract.
Returns:
{Number} The requested slice.
<static> {Number} sjcl.bitArray.getPartial(x)
Get the number of bits used by a partial word.
Parameters:
{Number} x
The partial word.
Returns:
{Number} The number of bits used by the partial word.
<static> {Number} sjcl.bitArray.partial(len, x, 0)
Make a partial word for a bit array.
Parameters:
{Number} len
The number of bits in the word.
{Number} x
The bits.
{Number} 0 Optional
_end Pass 1 if x has already been shifted to the high side.
Returns:
{Number} The partial word.