Squeak Class Documentation category index | class index  
 
DSAPlugin
  category: VMConstruction-Plugins
  superclass: InterpreterPlugin
  subclasses:

This plugin defines primitives that support the DigitalSignatureAlgorithm class. Three of these primitives support fast multiplication and division of very large integers, three others support the SecureHashAlgorithm.

instance methods
  primitives-SHA
  primitiveExpandBlock
primitiveHasSecureHashPrimitive
primitiveHashBlock

  primitives-integers
  primitiveBigDivide
primitiveBigMultiply
primitiveHighestNonZeroDigitIndex

  private
  addBackDivisorDigitShift:
bigDivideLoop
leftRotate:by:
subtractDivisorMultipliedByDigit:digitShift:

class methods
  plugin translation
  declareCVarsIn:
moduleName

instance methods
  primitives-SHA top  
 

primitiveExpandBlock

Expand a 64 byte ByteArray (the first argument) into and an Bitmap of 80 32-bit words (the second argument). When reading a 32-bit integer from the ByteArray, consider the first byte to contain the most significant bits of the word (i.e., use big-endian byte ordering).


 

primitiveHasSecureHashPrimitive

Answer true if the secure hash primitive is implemented.


 

primitiveHashBlock

Hash a Bitmap of 80 32-bit words (the first argument), using the given state (the second argument).


  primitives-integers top  
 

primitiveBigDivide

Called with three LargePositiveInteger arguments, rem, div, quo. Divide div into rem and store the quotient into quo, leaving the remainder in rem.


 

primitiveBigMultiply

Multiple f1 by f2, placing the result into prod. f1, f2, and prod must be LargePositiveIntegers, and the length of prod must be the sum of the lengths of f1 and f2.


 

primitiveHighestNonZeroDigitIndex

Called with one LargePositiveInteger argument. Answer the index of the top-most non-zero digit.


  private top  
 

addBackDivisorDigitShift:

Add back the divisor shifted left by the given number of digits. This is done only when the estimate of quotient digit was one larger than the correct value.


 

bigDivideLoop

This is the core of the divide algorithm. This loop steps through the digit positions of the quotient, each time estimating the right quotient digit, subtracting from the remainder the divisor times the quotient digit shifted left by the appropriate number of digits. When the loop terminates, all digits of the quotient have been filled in and the remainder contains a value less than the divisor. The tricky bit is estimating the next quotient digit. Knuth shows that the digit estimate computed here will never be less than it should be and cannot be more than one over what it should be. Furthermore, the case where the estimate is one too large is extremely rare. For example, in a typical test of 100000 random 60-bit division problems, the rare case only occured five times. See Knuth, volume 2 ('Semi-Numerical Algorithms') 2nd edition, pp. 257-260


 

leftRotate:by:

Rotate the given 32-bit integer left by the given number of bits and answer the result.


 

subtractDivisorMultipliedByDigit:digitShift:

Multiply the divisor by the given digit (an integer in the range 0..255), shift it left by the given number of digits, and subtract the result from the current remainder. Answer true if there is an excess borrow, indicating that digit was one too large. (This case is quite rare.)


class methods
  plugin translation top  
 

declareCVarsIn:

Note: This method must be implemented by all subclasses to declare variables.


 

moduleName

Time millisecondsToRun: [
DSAPlugin translateDoInlining: true]