Skip to content

Commit

Permalink
[all] Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurlimaye committed Oct 25, 2018
0 parents commit 3f4ddb1
Show file tree
Hide file tree
Showing 1,196 changed files with 282,317 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# HERMIT-BenchmarkSuite

A benchmark suite consisting of Internet of Medical Things (IoMT) applications.

> Stable release: https://github.com/ankurlimaye/HERMIT-BenchmarkSuite/releases/tag/v1.0
### Links:

> Journal Paper: https://ieeexplore.ieee.org/document/8392676
> Download Link: http://www2.engr.arizona.edu/~tosiron/downloads.php
44 changes: 44 additions & 0 deletions src/activity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

------------------------------
Install wfdb
------------------------------

1. Install pre-requisites

gcc --version
curl-config --version
ls /usr/include/expat.h

If these commands work, go to step 2, else:

apt-get install gcc libcurl4-openssl-dev libexpat1-dev

2. Configure, install and test package:

cd ../sqrs_wabp
tar xfvz wfdb.tar.gz
cd wfdb-10.m.n
./configure
make install
make check

------------------------------
Compile activity.c File
------------------------------

cd activity
g++ -o activity activity.c

------------------------------
Run perf
------------------------------

Run perf on 'tach -r record -a annotator | activity [-m] [len]'
where record, annotator can be found in wfdb database; default len value = 600

------------------------------
Source
------------------------------

https://www.physionet.org/physiotools/activity/
https://www.physionet.org/physiotools/activity/activity.pdf
129 changes: 129 additions & 0 deletions src/activity/activity/activity.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* file: activity.c G. Moody 2 April 1992
-------------------------------------------------------------------------------
activity: Estimate activity level from heart rate signal
Copyright (C) 2002 George B. Moody
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
You may contact the author by e-mail ([email protected]) or postal mail
(MIT Room E25-505A, Cambridge, MA 02139 USA). For updates to this software,
please visit PhysioNet (http://www.physionet.org/).
_______________________________________________________________________________
This program derives an "activity index" from a time series of instantaneous
heart rate measurements, such as can be produced by 'tach'. 'tach' is included
in the WFDB Software Package; for details, see
http://www.physionet.org/physiotools/wag/tach-1.htm
For example:
tach -r RECORD -a ANNOTATOR | activity
Each value of the activity index is derived from 'len' values in the input
heart rate time series; by default, 5 minutes of input data are used to
produce each output value. The input windows overlap by 50%, so that the
interval between output values is half of that specified by 'len', or 2.5
minutes by default. Other values of 'len' can be specified on the command
line, as in:
tach -r RECORD -a ANNOTATOR | activity 240
which would yield outputs at 1-minute intervals, based on 2-minute windows.
Use activity's '-m' option to find and output only the interval for which
the activity index is minimum.
The activity index is based on mean heart rate, total power of the observed
heart rate signal, and a heart rate stationarity index. For details, see
"ECG-based indices of physical activity", pp. 403-406, Computers in Cardiology
1992.
*/

#include <stdio.h>
#include <math.h>
#define DEFLEN 600 /* 5 minutes at 2 samples/sec */

main(argc, argv)
int argc;
char *argv[];
{
char buf[80], *malloc();
double *t, *hr, activity,meanhr, meanhr0, meanhr1, p, tpower, stationarity;
double acmin = -1.0, hrmin, stmin, tpmin, tmin0, tmin1;
int i = 0, len = DEFLEN, mflag = 0, n;
long tt = 0L;

if (argc > 1) {
if (strcmp(argv[1], "-m") == 0)
mflag = 1;
}
if (argc > mflag+1) {
if ((len = atoi(argv[mflag+1])) < 2) {
fprintf(stderr, "usage: %s [ -m ] [ length ] <hr-time-series\n",
argv[0]);
exit(1);
}
}
if ((t = (double *)malloc(len * sizeof(double))) == NULL ||
(hr= (double *)malloc(len * sizeof(double))) == NULL) {
fprintf(stderr, "%s: insufficient memory\n", argv[0]);
exit(1);
}
while (fgets(buf, 80, stdin)) {
n = sscanf(buf, "%lf%lf", &t[i], &hr[i]);
if (n == 0) continue; /* skip empty lines in input */
if (n == 1) { hr[i] = t[i]; t[i] = tt/2.0; }
++tt;
if (++i >= len) { /* hr buffer full -- emit output and reset */
meanhr0 = meanhr1 = tpower = 0.0;
for (i = 0; i < len/2; i++)
meanhr0 += hr[i];
for ( ; i < len; i++)
meanhr1 += hr[i];
meanhr0 /= len/2; meanhr1 /= len/2;
meanhr = (meanhr0 + meanhr1)/2;
stationarity = meanhr0 - meanhr1;
if (stationarity < 0) stationarity = -stationarity;
for (i = 0; i < len; i++) {
p = hr[i] - meanhr;
tpower += p*p;
}
tpower /= len;
if (tpower > 100.) tpower = 100.;
activity = sqrt((meanhr - 40.)*(meanhr - 40.) +
10. * stationarity * stationarity + 100.*tpower);
if (meanhr < 25.) /* penalty for unbelievably low heart rates */
activity += 25. - meanhr;
if (!mflag) {
printf("%g\t%g\t%g\t%g\t%g\n",
t[len/4-1], meanhr, tpower, stationarity, activity);
printf("%g\t%g\t%g\t%g\t%g\n",
t[3*len/4-1], meanhr, tpower, stationarity, activity);
}
else if (activity < acmin || acmin < 0.) {
acmin = activity;
hrmin = meanhr;
stmin = stationarity;
tpmin = tpower;
tmin0 = t[0];
tmin1 = t[len-1];
}
for (i = 0; i < len/2; i++) {
hr[i] = hr[i+len/2];
t[i] = t[i+len/2];
}
}
}
if (mflag)
printf("%g\t%g\t%g\t%g\t%g\t%g\n", tmin0, tmin1, hrmin, tpmin, stmin,
acmin);
}
28 changes: 28 additions & 0 deletions src/aes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

------------------------------
Install cryptopp
------------------------------

cd cryptopp
make static cryptest.exe
./cryptest.exe v
./cryptest.exe tv
sudo make install PREFIX=/usr/local

------------------------------
Compile Example File
------------------------------

g++ -o aesExampleBin aesExample.cpp -lcryptopp

------------------------------
Run perf
------------------------------

Run perf on 'aesExampleBin'

------------------------------
Source
------------------------------

https://www.cryptopp.com/
146 changes: 146 additions & 0 deletions src/aes/cryptopp/3way.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// 3way.cpp - modifed by Wei Dai from Joan Daemen's 3way.c
// The original code and all modifications are in the public domain.

#include "pch.h"
#include "3way.h"
#include "misc.h"

NAMESPACE_BEGIN(CryptoPP)

#if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void ThreeWay_TestInstantiations()
{
ThreeWay::Encryption x1;
ThreeWay::Decryption x2;
}
#endif

namespace
{
const word32 START_E = 0x0b0b; // round constant of first encryption round
const word32 START_D = 0xb1b1; // round constant of first decryption round
#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
const word32 RC_MODULUS = 0x11011;
#endif
}

static inline word32 reverseBits(word32 a)
{
a = ((a & 0xAAAAAAAA) >> 1) | ((a & 0x55555555) << 1);
a = ((a & 0xCCCCCCCC) >> 2) | ((a & 0x33333333) << 2);
return ((a & 0xF0F0F0F0) >> 4) | ((a & 0x0F0F0F0F) << 4);
}

#define mu(a0, a1, a2) \
{ \
a1 = reverseBits(a1); \
word32 t = reverseBits(a0); \
a0 = reverseBits(a2); \
a2 = t; \
}

#define pi_gamma_pi(a0, a1, a2) \
{ \
word32 b0, b2; \
b2 = rotlFixed(a2, 1U); \
b0 = rotlFixed(a0, 22U); \
a0 = rotlFixed(b0 ^ (a1|(~b2)), 1U); \
a2 = rotlFixed(b2 ^ (b0|(~a1)), 22U);\
a1 ^= (b2|(~b0)); \
}

// thanks to Paulo Barreto for this optimized theta()
#define theta(a0, a1, a2) \
{ \
word32 b0, b1, c; \
c = a0 ^ a1 ^ a2; \
c = rotlFixed(c, 16U) ^ rotlFixed(c, 8U); \
b0 = (a0 << 24) ^ (a2 >> 8) ^ (a1 << 8) ^ (a0 >> 24); \
b1 = (a1 << 24) ^ (a0 >> 8) ^ (a2 << 8) ^ (a1 >> 24); \
a0 ^= c ^ b0; \
a1 ^= c ^ b1; \
a2 ^= c ^ (b0 >> 16) ^ (b1 << 16); \
}

#define rho(a0, a1, a2) \
{ \
theta(a0, a1, a2); \
pi_gamma_pi(a0, a1, a2); \
}

void ThreeWay::Base::UncheckedSetKey(const byte *uk, unsigned int length, const NameValuePairs &params)
{
AssertValidKeyLength(length);

m_rounds = GetRoundsAndThrowIfInvalid(params, this);

for (unsigned int i=0; i<3; i++)
m_k[i] = (word32)uk[4*i+3] | ((word32)uk[4*i+2]<<8) | ((word32)uk[4*i+1]<<16) | ((word32)uk[4*i]<<24);

if (!IsForwardTransformation())
{
theta(m_k[0], m_k[1], m_k[2]);
mu(m_k[0], m_k[1], m_k[2]);
m_k[0] = ByteReverse(m_k[0]);
m_k[1] = ByteReverse(m_k[1]);
m_k[2] = ByteReverse(m_k[2]);
}
}

void ThreeWay::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{
typedef BlockGetAndPut<word32, BigEndian> Block;

word32 a0, a1, a2;
Block::Get(inBlock)(a0)(a1)(a2);

word32 rc = START_E;

for(unsigned i=0; i<m_rounds; i++)
{
a0 ^= m_k[0] ^ (rc<<16);
a1 ^= m_k[1];
a2 ^= m_k[2] ^ rc;
rho(a0, a1, a2);

rc <<= 1;
if (rc&0x10000) rc ^= 0x11011;
}
a0 ^= m_k[0] ^ (rc<<16);
a1 ^= m_k[1];
a2 ^= m_k[2] ^ rc;
theta(a0, a1, a2);

Block::Put(xorBlock, outBlock)(a0)(a1)(a2);
}

void ThreeWay::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{
typedef BlockGetAndPut<word32, LittleEndian> Block;

word32 a0, a1, a2;
Block::Get(inBlock)(a0)(a1)(a2);

word32 rc = START_D;

mu(a0, a1, a2);
for(unsigned i=0; i<m_rounds; i++)
{
a0 ^= m_k[0] ^ (rc<<16);
a1 ^= m_k[1];
a2 ^= m_k[2] ^ rc;
rho(a0, a1, a2);

rc <<= 1;
if (rc&0x10000) rc ^= 0x11011;
}
a0 ^= m_k[0] ^ (rc<<16);
a1 ^= m_k[1];
a2 ^= m_k[2] ^ rc;
theta(a0, a1, a2);
mu(a0, a1, a2);

Block::Put(xorBlock, outBlock)(a0)(a1)(a2);
}

NAMESPACE_END
Loading

0 comments on commit 3f4ddb1

Please sign in to comment.