![]() |
ATLAS Offline Software
|
Provide simple asymmetric encryption for blinding of float values. More...
#include <SimpleEncrypter.h>
Public Types | |
| typedef long long int | LLI_t |
| Useful typedefs. | |
| typedef unsigned long long int | ULLI_t |
Public Member Functions | |
| SimpleEncrypter (const std::string &name="SimpleEncrypter") | |
| Main constructor. | |
| virtual | ~SimpleEncrypter () |
| Default destructor. | |
| virtual std::pair< std::string, std::string > | genKeyPair () |
| Generate private and public keys. | |
| virtual void | setPrivKey (std::string keystr) |
| Set private key. | |
| virtual void | setPubKey (std::string keystr) |
| Set public key. | |
| virtual std::string | getPrivKey () const |
| Get private key. | |
| virtual std::string | getPubKey () const |
| Get public key. | |
| virtual ULLI_t | encrypt (ULLI_t x) |
| Encrypt a positive integer value. | |
| virtual ULLI_t | decrypt (ULLI_t x) |
| Decrypt a positive integer value. | |
| virtual float | encrypt (float x) |
| Encrypt a positive float value. | |
| virtual float | decrypt (float x) |
| Decrypt a positive float value. | |
| void | setLevel (MSG::Level lvl) |
| Change the current logging level. | |
Functions providing the same interface as AthMessaging | |
| bool | msgLvl (const MSG::Level lvl) const |
| Test the output level of the object. | |
| MsgStream & | msg () const |
| The standard message stream. | |
| MsgStream & | msg (const MSG::Level lvl) const |
| The standard message stream. | |
Private Member Functions | |
| void | initMessaging () const |
| Initialize our message level and MessageSvc. | |
Key generation utilities | |
Internally generate numeric representation of key pair | |
| virtual void | genKeyPairInternal () |
| virtual ULLI_t | genPrime () const |
| Find a prime number. | |
| virtual bool | isPrime (ULLI_t n) const |
| Check for being a prime number. | |
| virtual ULLI_t | greatestCommonDenominator (ULLI_t n1, ULLI_t n2) const |
| Find greatest common denominator. | |
| virtual ULLI_t | genCoprime (ULLI_t n) const |
| Find a coprime number. | |
| virtual ULLI_t | genDecryptionExponent (ULLI_t phi, ULLI_t e) const |
| Find decryption exponent. | |
Key conversion utilities | |
Convert key to hex string | |
| virtual std::string | keyToString (ULLI_t a, ULLI_t b) const |
| virtual std::pair< ULLI_t, ULLI_t > | decodeKeyString (std::string str) const |
| Decode hex string to two integers. | |
float <-> int conversion utilities | |
Interpret bits of floating point number as integer | |
| virtual ULLI_t | floatBitsToInt (float val) const |
| virtual float | intBitsToFloat (ULLI_t val) const |
| Interpret bits of integer as floating point number. | |
Internal en-/decryption methods | |
Encrypt using format preserving encryption w.r.t. RSA modulus | |
| ULLI_t | encryptFPECycle (ULLI_t a) const |
| ULLI_t | decryptFPECycle (ULLI_t a) const |
| Decrypt using format preserving encryption w.r.t. | |
| ULLI_t | encryptInternal (ULLI_t x) const |
| Encrypt integer (internal) | |
| ULLI_t | decryptInternal (ULLI_t x) const |
| Decrypt integer (internal) | |
| ULLI_t | powerMod (ULLI_t a, ULLI_t d, ULLI_t n) const |
| Exponentiate a with d observing modulus n. | |
| bool | isOkForEnc () |
| Check setup readiness for encryption. | |
| bool | isOkForDec () |
| Check setup readiness for decryption. | |
Private Attributes | |
| std::string | m_nm |
| Message source name. | |
| boost::thread_specific_ptr< MsgStream > | m_msg_tls |
| MsgStream instance (a std::cout like with print-out levels) | |
| std::atomic< IMessageSvc * > | m_imsg { nullptr } |
| MessageSvc pointer. | |
| std::atomic< MSG::Level > | m_lvl { MSG::NIL } |
| Current logging level. | |
| std::atomic_flag m_initialized | ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT |
| Messaging initialized (initMessaging) | |
Internal member variables | |
RSA modulus: common part of both keys | |
| ULLI_t | m_n |
| ULLI_t | m_e |
| encryption exponent: public key part II | |
| ULLI_t | m_d |
| decryption exponent: private key part II | |
| bool | m_isOkForEnc |
| indicates that keys are set and range checks are ok | |
| bool | m_isOkForDec |
Static Private Attributes | |
Internal static consts | |
Approximate range for prime numbers to be generated in | |
| static const ULLI_t | m_MAXRANGE |
| static const ULLI_t | m_MINRANGE |
| static const unsigned int | m_MAXHEXDIGITS |
| maximum number of hex digits for key parts | |
Provide simple asymmetric encryption for blinding of float values.
Provides asymmetric key encryption for blinding of positive float values. Internally it uses a simple RSA encryption of bits in the floating point numbers. This class is used by the BPhysBlindingTool.
Definition at line 36 of file SimpleEncrypter.h.
| typedef long long int xAOD::SimpleEncrypter::LLI_t |
Useful typedefs.
Definition at line 40 of file SimpleEncrypter.h.
| typedef unsigned long long int xAOD::SimpleEncrypter::ULLI_t |
Definition at line 41 of file SimpleEncrypter.h.
| xAOD::SimpleEncrypter::SimpleEncrypter | ( | const std::string & | name = "SimpleEncrypter" | ) |
Main constructor.
| [in] | name | of instance |
Definition at line 42 of file SimpleEncrypter.cxx.
|
virtual |
|
privatevirtual |
Decode hex string to two integers.
Definition at line 310 of file SimpleEncrypter.cxx.
Decrypt a positive float value.
| [in] | positive | float value to be decrypted |
Definition at line 162 of file SimpleEncrypter.cxx.
|
virtual |
Decrypt a positive integer value.
| [in] | unsigned | integer value to be decrypted |
Definition at line 130 of file SimpleEncrypter.cxx.
|
private |
Decrypt using format preserving encryption w.r.t.
RSA modulus
Definition at line 440 of file SimpleEncrypter.cxx.
|
private |
Decrypt integer (internal)
Definition at line 465 of file SimpleEncrypter.cxx.
Encrypt a positive float value.
| [in] | positive | float value to be encrypted |
Definition at line 142 of file SimpleEncrypter.cxx.
|
virtual |
Encrypt a positive integer value.
| [in] | unsigned | integer value to be encrypted |
Definition at line 118 of file SimpleEncrypter.cxx.
|
private |
Definition at line 421 of file SimpleEncrypter.cxx.
|
private |
|
privatevirtual |
Definition at line 339 of file SimpleEncrypter.cxx.
|
privatevirtual |
Find a coprime number.
Definition at line 260 of file SimpleEncrypter.cxx.
|
privatevirtual |
Find decryption exponent.
Definition at line 274 of file SimpleEncrypter.cxx.
|
virtual |
Generate private and public keys.
Definition at line 60 of file SimpleEncrypter.cxx.
|
privatevirtual |
Definition at line 187 of file SimpleEncrypter.cxx.
|
privatevirtual |
Find a prime number.
Definition at line 217 of file SimpleEncrypter.cxx.
|
virtual |
Get private key.
Definition at line 104 of file SimpleEncrypter.cxx.
|
virtual |
Get public key.
Definition at line 111 of file SimpleEncrypter.cxx.
|
privatevirtual |
Find greatest common denominator.
Definition at line 245 of file SimpleEncrypter.cxx.
|
privateinherited |
Initialize our message level and MessageSvc.
This method should only be called once.
Definition at line 39 of file AthMessaging.cxx.
Interpret bits of integer as floating point number.
Definition at line 380 of file SimpleEncrypter.cxx.
|
private |
Check setup readiness for decryption.
Definition at line 515 of file SimpleEncrypter.cxx.
|
private |
Check setup readiness for encryption.
Definition at line 499 of file SimpleEncrypter.cxx.
Definition at line 286 of file SimpleEncrypter.cxx.
|
inherited |
The standard message stream.
Definition at line 49 of file AsgMessaging.cxx.
|
inherited |
The standard message stream.
| lvl | The message level to set the stream to |
Definition at line 57 of file AsgMessaging.cxx.
|
inherited |
Test the output level of the object.
| lvl | The message level to test against |
true If messages at level "lvl" will be printed Definition at line 41 of file AsgMessaging.cxx.
|
private |
Exponentiate a with d observing modulus n.
Definition at line 473 of file SimpleEncrypter.cxx.
|
inherited |
Change the current logging level.
Use this rather than msg().setLevel() for proper operation with MT.
Definition at line 28 of file AthMessaging.cxx.
|
virtual |
Set private key.
| [in] | hex | string with private key |
Definition at line 78 of file SimpleEncrypter.cxx.
|
virtual |
Set public key.
| [in] | hex | string with public key |
Definition at line 92 of file SimpleEncrypter.cxx.
|
mutableprivateinherited |
Messaging initialized (initMessaging)
Definition at line 141 of file AthMessaging.h.
|
private |
decryption exponent: private key part II
Definition at line 233 of file SimpleEncrypter.h.
|
private |
encryption exponent: public key part II
Definition at line 231 of file SimpleEncrypter.h.
|
mutableprivateinherited |
|
private |
Definition at line 237 of file SimpleEncrypter.h.
|
private |
indicates that keys are set and range checks are ok
Definition at line 236 of file SimpleEncrypter.h.
|
mutableprivateinherited |
maximum number of hex digits for key parts
Definition at line 223 of file SimpleEncrypter.h.
|
staticprivate |
Definition at line 220 of file SimpleEncrypter.h.
|
staticprivate |
Definition at line 221 of file SimpleEncrypter.h.
|
mutableprivateinherited |
MsgStream instance (a std::cout like with print-out levels)
Definition at line 132 of file AthMessaging.h.
|
private |
Definition at line 229 of file SimpleEncrypter.h.
|
privateinherited |
Message source name.
Definition at line 129 of file AthMessaging.h.