API Reference | developer.brewmp.com API Reference | developer.brewmp.com


API Reference


Brew Release
Brew MP 1.0.2
A "BN Engine" is a interface that provides access to a big number arithmetic library base implementation. Big number arithmetics are operations such as addition, multiplication and modular exponentiation of very large numbers. It is used in some cryptographic algorithms such as RSA, Diffie-Helman and DSA. It can also be used to implement an arbitrary precision calculator.
The class that implements the IBNEng interface can represent access to some accelerator hardware or a software module that manages multiple simultaneous operations or one that caches data between operations. Operations are performed by obtaining an operation context from the engine. The contexts have the IBN interface. Values are set on the context and then the operation is invoked with inputs. Only one operation is allowed outstanding at a time per context, though a context may be re used serially.
Basically the engine affords the BN implementor the full generality to create a BN implementation that shares and manages resources across a number of potentially simultaneous BN operations. This allows for handling of hardware contention, managing the number of operations outstanding at one time or, caching previous calculations. BN Engines may be configured if need be by setting parameters. Setting a parameter on the BN engine generally affects all outstanding operation contexts.
A simpler class implementing big numbers with a simpler interface is usually also available. It does not have an engine interface. Instead it simply has an IBN interface, the same interface as the engine operation contexts. Only one operation is possible at a time. It is not able to cache previous calculations. However, it is sufficient for most implementations.
An implementor of a BN Engine should also provide the simpler non-engine class.
Callers or users of the big number implementation usually have to choose between using the engine interface or the simple non-engine interface because both are usually available. The rule is that implementors of very general purpose services, classes or libraries should use the engine interface. Examples are implementors of RSA, DSA, or Diffie-Helman algorithms. This is to take advantage of implementations that are hardware-based or that provide caching. Implementors of end applications can use the simple non-engine implementations unless the engine implementation provides something the simpler one doesn't.
A good use of "BN engine" can be to switch between implementations. To do so, call IBNEng_GetOperationContext(). It returns a new BN operation context populated with the original BN's contents. This can also be used to make sure to use a specific implementation of BN.
An implementation using BNEng allows: 1) An easily switch between implementation engines 2) Using a crypto implementation that caches operations done with the same key