CMS 3D CMS Logo

Macros | Functions | Variables
blowfish.cc File Reference
#include "blowfish.h"

Go to the source code of this file.

Macros

#define N   16
 

Functions

void Blowfish_Decrypt (BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr)
 
void Blowfish_Encrypt (BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr)
 
void Blowfish_Init (BLOWFISH_CTX *ctx, unsigned char *key, int keyLen)
 
static uInt32 F (BLOWFISH_CTX *ctx, uInt32 x)
 

Variables

static const uInt32 ORIG_P [16+2]
 
static const uInt32 ORIG_S [4][256]
 

Macro Definition Documentation

◆ N

#define N   16

Definition at line 9 of file blowfish.cc.

Function Documentation

◆ Blowfish_Decrypt()

void Blowfish_Decrypt ( BLOWFISH_CTX ctx,
uInt32 xl,
uInt32 xr 
)

Definition at line 207 of file blowfish.cc.

207  {
208  uInt32 Xl;
209  uInt32 Xr;
210  uInt32 temp;
211  short i;
212 
213  Xl = *xl;
214  Xr = *xr;
215 
216  for (i = N + 1; i > 1; --i) {
217  Xl = Xl ^ ctx->P[i];
218  Xr = F(ctx, Xl) ^ Xr;
219  /* Exchange Xl and Xr */
220  temp = Xl;
221  Xl = Xr;
222  Xr = temp;
223  }
224 
225  /* Exchange Xl and Xr */
226  temp = Xl;
227  Xl = Xr;
228  Xr = temp;
229  Xr = Xr ^ ctx->P[1];
230  Xl = Xl ^ ctx->P[0];
231  *xl = Xl;
232  *xr = Xr;
233 }

References F(), mps_fire::i, N, BLOWFISH_CTX::P, and groupFilesInBlocks::temp.

Referenced by cond::auth::Cipher::bf_process_alloc().

◆ Blowfish_Encrypt()

void Blowfish_Encrypt ( BLOWFISH_CTX ctx,
uInt32 xl,
uInt32 xr 
)

Definition at line 181 of file blowfish.cc.

181  {
182  uInt32 Xl;
183  uInt32 Xr;
184  uInt32 temp;
185  short i;
186 
187  Xl = *xl;
188  Xr = *xr;
189 
190  for (i = 0; i < N; ++i) {
191  Xl = Xl ^ ctx->P[i];
192  Xr = F(ctx, Xl) ^ Xr;
193  temp = Xl;
194  Xl = Xr;
195  Xr = temp;
196  }
197 
198  temp = Xl;
199  Xl = Xr;
200  Xr = temp;
201  Xr = Xr ^ ctx->P[N];
202  Xl = Xl ^ ctx->P[N + 1];
203  *xl = Xl;
204  *xr = Xr;
205 }

References F(), mps_fire::i, N, BLOWFISH_CTX::P, and groupFilesInBlocks::temp.

Referenced by cond::auth::Cipher::bf_process_alloc(), and Blowfish_Init().

◆ Blowfish_Init()

void Blowfish_Init ( BLOWFISH_CTX ctx,
unsigned char *  key,
int  keyLen 
)

Definition at line 235 of file blowfish.cc.

235  {
236  int i, j, k;
237  uInt32 data, datal, datar;
238 
239  for (i = 0; i < 4; i++) {
240  for (j = 0; j < 256; j++)
241  ctx->S[i][j] = ORIG_S[i][j];
242  }
243 
244  j = 0;
245 
246  for (i = 0; i < N + 2; ++i) {
247  data = 0x00000000;
248 
249  for (k = 0; k < 4; ++k) {
250  data = (data << 8) | key[j];
251  j = j + 1;
252  if (j >= keyLen)
253  j = 0;
254  }
255 
256  ctx->P[i] = ORIG_P[i] ^ data;
257  }
258 
259  datal = 0x00000000;
260  datar = 0x00000000;
261 
262  for (i = 0; i < N + 2; i += 2) {
263  Blowfish_Encrypt(ctx, &datal, &datar);
264  ctx->P[i] = datal;
265  ctx->P[i + 1] = datar;
266  }
267 
268  for (i = 0; i < 4; ++i) {
269  for (j = 0; j < 256; j += 2) {
270  Blowfish_Encrypt(ctx, &datal, &datar);
271  ctx->S[i][j] = datal;
272  ctx->S[i][j + 1] = datar;
273  }
274  }
275 }

References Blowfish_Encrypt(), data, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, crabWrapper::key, N, ORIG_P, ORIG_S, BLOWFISH_CTX::P, and BLOWFISH_CTX::S.

Referenced by cond::auth::Cipher::Cipher().

◆ F()

uInt32 F ( BLOWFISH_CTX ctx,
uInt32  x 
)
static

Definition at line 163 of file blowfish.cc.

163  {
164  unsigned short a, b, c, d;
165  uInt32 y;
166 
167  d = x & 0x00FF;
168  x >>= 8;
169  c = x & 0x00FF;
170  x >>= 8;
171  b = x & 0x00FF;
172  x >>= 8;
173  a = x & 0x00FF;
174 
175  y = ctx->S[0][a] + ctx->S[1][b];
176  y = y ^ ctx->S[2][c];
177  y = y + ctx->S[3][d];
178  return y;
179 }

References a, b, HltBtagPostValidation_cff::c, ztail::d, BLOWFISH_CTX::S, vertices_cff::x, and detailsBasic3DVector::y.

Referenced by L1TConfigDumper::analyze(), Blowfish_Decrypt(), Blowfish_Encrypt(), HcalHaloAlgo::Calculate(), hitfit::Fourvec_Constraint_Calculator::calculate_constraints(), hitfit::Base_Constrainer::call_constraint_fcn(), TangentCircle::charge(), clangcms::EDMPluginDumper::checkASTDecl(), funct::SimplSumOrd< A, B, ProductStruct< C, D > >::combine(), funct::combine(), funct::RatioP1< A, B, Numerical< n > >::combine(), funct::Product< ProductStruct< F, G >, H >::combine(), funct::RatioP2< A, B, ProductStruct< C, D > >::combine(), ForwardDiskSectorBuilderFromDet::computeBounds(), ForwardRingDiskBuilderFromDet::computeBounds(), BarrelDetLayer::computeSurface(), ForwardDetLayer::computeSurface(), TKinFitter::converged(), DAClusterizerInZ::dump(), DAClusterizerInZ_vect::dump(), DAClusterizerInZT_vect::dump(), TrackerTreeGenerator::endJob(), hitfit::Fourvec_Constraint_Calculator::eval(), DAClusterizerInZ_vect::evalF(), TrackerValidationVariables::fillHitQuantities(), ApeEstimator::fillHitVariables(), ApeEstimator::fillTrackVariables(), reco::findMethod(), edm::refitem::findRefItem(), hitfit::Chisq_Constrainer::fit(), reco::componenthelper::SingleComponent< C, T, F >::get(), reco::componenthelper::MultipleComponents< C, T, F, S >::get(), TKinFitter::getF(), edm::refitem::GetRefPtrImpl< C, T, F, KEY >::getRefPtr_(), edm::refitem::GetRefPtrImpl< C, T, F, unsigned int >::getRefPtr_(), LayerMeasurements::groupedMeasurements(), HelixBarrelCylinderCrossing::HelixBarrelCylinderCrossing(), HTXS::HTXSstage1_2_Fine_to_HTXSstage1_2_Fine_FineIndex(), HTXS::HTXSstage1_2_Fine_to_index(), HTXS::HTXSstage1_2_to_HTXSstage1_2_FineIndex(), HTXS::HTXSstage1_2_to_index(), HTXS::HTXSstage1_to_HTXSstage1FineIndex(), HTXS::HTXSstage1_to_index(), MagneticField::inInverseGeV(), math::cholesky::invert11(), math::cholesky::invert22(), math::cholesky::invert33(), math::cholesky::invert44(), math::cholesky::invert55(), LayerMeasurements::measurements(), TkGluedMeasurementDet::measurements(), TkPhase2OTMeasurementDet::measurements(), TkPixelMeasurementDet::measurements(), TkStripMeasurementDet::measurements(), fastsim::HelixTrajectory::nextCrossingTimeC(), HBHEPulseShapeFlagSetter::PerformNominalFit(), ApeEstimator::radialPositionAndError2(), ApeTreeCreateDefault::sectorBuilder(), ApeEstimator::sectorBuilder(), CPPFCluster::timeRMS(), RPCCluster::timeRMS(), RPCCluster::yRMS(), and CPPFCluster::yRMS().

Variable Documentation

◆ ORIG_P

const uInt32 ORIG_P[16+2]
static
Initial value:
= {0x243F6A88L,
0x85A308D3L,
0x13198A2EL,
0x03707344L,
0xA4093822L,
0x299F31D0L,
0x082EFA98L,
0xEC4E6C89L,
0x452821E6L,
0x38D01377L,
0xBE5466CFL,
0x34E90C6CL,
0xC0AC29B7L,
0xC97C50DDL,
0x3F84D5B5L,
0xB5470917L,
0x9216D5D9L,
0x8979FB1BL}

Definition at line 12 of file blowfish.cc.

Referenced by Blowfish_Init().

◆ ORIG_S

const uInt32 ORIG_S[4][256]
static

Definition at line 31 of file blowfish.cc.

Referenced by Blowfish_Init().

dttmaxenums::L
Definition: DTTMax.h:29
mps_fire.i
i
Definition: mps_fire.py:355
ORIG_S
static const uInt32 ORIG_S[4][256]
Definition: blowfish.cc:31
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
ORIG_P
static const uInt32 ORIG_P[16+2]
Definition: blowfish.cc:12
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
vertices_cff.x
x
Definition: vertices_cff.py:29
N
#define N
Definition: blowfish.cc:9
dqmdumpme.k
k
Definition: dqmdumpme.py:60
b
double b
Definition: hdecay.h:118
a
double a
Definition: hdecay.h:119
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
BLOWFISH_CTX::S
uInt32 S[4][256]
Definition: blowfish.h:41
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
ztail.d
d
Definition: ztail.py:151
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
crabWrapper.key
key
Definition: crabWrapper.py:19
uInt32
unsigned int uInt32
Definition: blowfish.h:25
BLOWFISH_CTX::P
uInt32 P[16+2]
Definition: blowfish.h:40
Blowfish_Encrypt
void Blowfish_Encrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr)
Definition: blowfish.cc:181