ATLAS Offline Software
Loading...
Searching...
No Matches
SimpleEncrypter.h
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
5*/
6
13
14#ifndef BPHYSTOOLS_SIMPLEENCRYPTER_H
15#define BPHYSTOOLS_SIMPLEENCRYPTER_H
16
17// Framework includes
19
20// System includes
21#include <string>
22#include <set>
23
24namespace xAOD {
37
38 public:
40 typedef long long int LLI_t;
41 typedef unsigned long long int ULLI_t;
42
48 SimpleEncrypter(const std::string& name = "SimpleEncrypter");
49
53 virtual ~SimpleEncrypter();
54
60 virtual std::pair<std::string, std::string> genKeyPair();
61
67 virtual void setPrivKey(std::string keystr);
68
74 virtual void setPubKey(std::string keystr);
75
81 virtual std::string getPrivKey() const;
82
88 virtual std::string getPubKey() const;
89
97 virtual ULLI_t encrypt(ULLI_t x);
98
106 virtual ULLI_t decrypt(ULLI_t x);
107
115 virtual float encrypt(float x);
116
124 virtual float decrypt(float x);
125
126
127 private:
134 virtual void genKeyPairInternal();
138 virtual ULLI_t genPrime() const;
142 virtual bool isPrime(ULLI_t n) const;
146 virtual ULLI_t greatestCommonDenominator(ULLI_t n1, ULLI_t n2) const;
150 virtual ULLI_t genCoprime(ULLI_t n) const;
163 virtual std::string keyToString(ULLI_t a, ULLI_t b) const;
167 virtual std::pair<ULLI_t, ULLI_t> decodeKeyString(std::string str) const;
175 virtual ULLI_t floatBitsToInt(float val) const;
179 virtual float intBitsToFloat(ULLI_t val) const;
203 ULLI_t powerMod(ULLI_t a, ULLI_t d, ULLI_t n) const;
207 bool isOkForEnc();
211 bool isOkForDec();
214
215 private:
220 static const ULLI_t m_MAXRANGE;
221 static const ULLI_t m_MINRANGE;
223 static const unsigned int m_MAXHEXDIGITS;
224
234
238
239 }; // class
240
241} // namespace xAOD
242
243#endif // BPHYSTOOLS_SIMPLEENCRYPTER_H
244
static Double_t a
#define x
Class mimicking the AthMessaging class from the offline software.
ULLI_t powerMod(ULLI_t a, ULLI_t d, ULLI_t n) const
Exponentiate a with d observing modulus n.
ULLI_t encryptInternal(ULLI_t x) const
Encrypt integer (internal)
bool isOkForDec()
Check setup readiness for decryption.
bool m_isOkForEnc
indicates that keys are set and range checks are ok
virtual ULLI_t greatestCommonDenominator(ULLI_t n1, ULLI_t n2) const
Find greatest common denominator.
ULLI_t decryptInternal(ULLI_t x) const
Decrypt integer (internal)
ULLI_t decryptFPECycle(ULLI_t a) const
Decrypt using format preserving encryption w.r.t.
virtual void genKeyPairInternal()
virtual ULLI_t encrypt(ULLI_t x)
Encrypt a positive integer value.
virtual void setPrivKey(std::string keystr)
Set private key.
virtual ULLI_t decrypt(ULLI_t x)
Decrypt a positive integer value.
static const ULLI_t m_MAXRANGE
static const unsigned int m_MAXHEXDIGITS
maximum number of hex digits for key parts
unsigned long long int ULLI_t
virtual std::string getPrivKey() const
Get private key.
virtual ULLI_t genCoprime(ULLI_t n) const
Find a coprime number.
virtual void setPubKey(std::string keystr)
Set public key.
virtual std::string keyToString(ULLI_t a, ULLI_t b) const
static const ULLI_t m_MINRANGE
ULLI_t encryptFPECycle(ULLI_t a) const
virtual std::string getPubKey() const
Get public key.
virtual ULLI_t genPrime() const
Find a prime number.
bool isOkForEnc()
Check setup readiness for encryption.
virtual std::pair< std::string, std::string > genKeyPair()
Generate private and public keys.
ULLI_t m_e
encryption exponent: public key part II
SimpleEncrypter(const std::string &name="SimpleEncrypter")
Main constructor.
virtual ULLI_t genDecryptionExponent(ULLI_t phi, ULLI_t e) const
Find decryption exponent.
virtual float intBitsToFloat(ULLI_t val) const
Interpret bits of integer as floating point number.
ULLI_t m_d
decryption exponent: private key part II
virtual ~SimpleEncrypter()
Default destructor.
virtual std::pair< ULLI_t, ULLI_t > decodeKeyString(std::string str) const
Decode hex string to two integers.
long long int LLI_t
Useful typedefs.
virtual bool isPrime(ULLI_t n) const
Check for being a prime number.
virtual ULLI_t floatBitsToInt(float val) const
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.