OpenGL® ES is a royalty-free, cross-platform API for full-function 2D and 3D graphics on embedded systems - including consoles, phones, appliances and vehicles. It consists of well-defined subsets of desktop OpenGL, creating a flexible and powerful low-level interface between software and graphics acceleration. OpenGL ES includes profiles for floating-point and fixed-point systems and the EGL™ specification for portably binding to native windowing systems. OpenGL ES 1.X is for fixed function hardware and offers acceleration, image quality and performance. OpenGL ES 2.X enables full programmable 3D graphics.
OpenCL (Open Computing Language) is a multi- vendor open standard for general-purpose parallel programming of heterogeneous systems that include CPUs, GPUs and other processors. OpenCL provides a uniform programming environment for software developers to write efficient, portable code for high-performance compute servers, desktop computer systems and handheld devices.
OpenGL® ES is a royalty-free, cross-platform API for full-function 2D and 3D graphics on embedded systems - including consoles, phones, appliances and vehicles. It consists of well-defined subsets of desktop OpenGL, creating a flexible and powerful low-level interface between software and graphics acceleration. OpenGL ES includes profiles for floating-point and fixed-point systems and the EGL™ specification for portably binding to native windowing systems. OpenGL ES 1.X is for fixed function hardware and offers acceleration, image quality and performance. OpenGL ES 2.X enables full programmable 3D graphics.
OpenCL (Open Computing Language) is a multi- vendor open standard for general-purpose parallel programming of heterogeneous systems that include CPUs, GPUs and other processors. OpenCL provides a uniform programming environment for software developers to write efficient, portable code for high-performance compute servers, desktop computer systems and handheld devices.
Asterisk: PVS-Studio Takes Up TelephonyAndrey Karpov
Asterisk is a software implementation of a telephone private branch exchange (PBX); it was created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services, such as the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, *.
Asterisk is released under a dual license model, using the GNU General Public License (GPL) as a free software license and a proprietary software license to permit licensees to distribute proprietary, unpublished system components.
In this article, we are going to discuss the results of the check of the Asterisk project by PVS-Studio 5.18.
The project seems to be regularly checked by the Coverity analyzer, which is indicated by comments like this one:
/* Ignore check_return warning from Coverity for ast_exists_extension below */
However, I still found some disappointing typos in the code. Let's try to figure them out as well as other potential issues. The source code was downloaded from the project's SVN repository.
The OpenCL C++ Wrapper is designed to be built on top of the OpenCL 1.2 C API and is not a replacement. The C++ Wrapper API corresponds closely to the underlying C API and introduces no additional execution overhead.
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
C++ programming language notes for beginners and Collage students. Written for beginners. Colored graphics. Function by Function explanation with complete examples. Well commented examples. Illustrations are made available for data dealing at memory level.
OSX/Flashback
El sistema operativo Apple OS X, al igual que todos los sistemas operativos, puede convertirse en una víctima de software malicioso. Antes de la aparición de OSX/Flashback, hubo varios casos documentados de malware dirigido a OS X; pero hasta ahora, OSX/Flashback fue el que cobró la mayor cantidad de víctimas. En este artículo se describen las características técnicas más interesantes de la amenaza, en especial el método utilizado para espiar las comunicaciones de red y los algoritmos para la generación dinámica de nombres de dominio. También se incluye una línea de tiempo con los puntos más importantes del malware, cuyo ciclo de vida persistió durante tantos meses.
This is a small note on the results of checking the OpenSSL project with the PVS-Studio analyzer. I analyzed the openssl-0.9.8-stable-SNAP-20121208 version.
Asterisk: PVS-Studio Takes Up TelephonyAndrey Karpov
Asterisk is a software implementation of a telephone private branch exchange (PBX); it was created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services, such as the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, *.
Asterisk is released under a dual license model, using the GNU General Public License (GPL) as a free software license and a proprietary software license to permit licensees to distribute proprietary, unpublished system components.
In this article, we are going to discuss the results of the check of the Asterisk project by PVS-Studio 5.18.
The project seems to be regularly checked by the Coverity analyzer, which is indicated by comments like this one:
/* Ignore check_return warning from Coverity for ast_exists_extension below */
However, I still found some disappointing typos in the code. Let's try to figure them out as well as other potential issues. The source code was downloaded from the project's SVN repository.
The OpenCL C++ Wrapper is designed to be built on top of the OpenCL 1.2 C API and is not a replacement. The C++ Wrapper API corresponds closely to the underlying C API and introduces no additional execution overhead.
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
C++ programming language notes for beginners and Collage students. Written for beginners. Colored graphics. Function by Function explanation with complete examples. Well commented examples. Illustrations are made available for data dealing at memory level.
OSX/Flashback
El sistema operativo Apple OS X, al igual que todos los sistemas operativos, puede convertirse en una víctima de software malicioso. Antes de la aparición de OSX/Flashback, hubo varios casos documentados de malware dirigido a OS X; pero hasta ahora, OSX/Flashback fue el que cobró la mayor cantidad de víctimas. En este artículo se describen las características técnicas más interesantes de la amenaza, en especial el método utilizado para espiar las comunicaciones de red y los algoritmos para la generación dinámica de nombres de dominio. También se incluye una línea de tiempo con los puntos más importantes del malware, cuyo ciclo de vida persistió durante tantos meses.
This is a small note on the results of checking the OpenSSL project with the PVS-Studio analyzer. I analyzed the openssl-0.9.8-stable-SNAP-20121208 version.
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2PVS-Studio
This is the second and last part of the large article about analysis of the Haiku operating system. In the first article, we discussed a variety of possible errors all of which one way or another deal with conditions. In this article, we will discuss the remaining analyzer warnings I have selected for you. The bug examples are grouped into several categories.
A Decompiler for Blackhain-Based Smart Contracts BytecodeShakacon
Ethereum is gaining a significant popularity in the blockchain community, mainly due to fact that it is design in a way that enables developers to write decentralized applications (Dapps) and smart-contract using blockchain technology.
Ethereum blockchain is a consensus-based globally executed virtual machine, also referred as Ethereum Virtual Machine (EVM) by implemented its own micro-kernel supporting a handful number of instructions, its own stack, memory and storage. This enables the radical new concept of distributed applications.
Contracts live on the blockchain in an Ethereum-specific binary format (EVM bytecode). However, contracts are typically written in some high-level language such as Solidity and then compiled into byte code to be uploaded on the blockchain. Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript.
This new paradigm of applications opens the door to many possibilities and opportunities. Blockchain is often referred as secure by design, but now that blockchains can embed applications this raise multiple questions regarding architecture, design, attack vectors and patch deployments.
As we, reverse engineers, know having access to source code is often a luxury. Hence, the need for an open-source tool like Porosity: decompiler for EVM bytecode into readable Solidity-syntax contracts – to enable static and dynamic analysis of compiled contracts but also vulnerability discovery.
Introduce Brainf*ck, another Turing complete programming language. Then, try to implement the following from scratch: Interpreter, Compiler [x86_64 and ARM], and JIT Compiler.
The slide introduce some of the Rust concept that are necessary to write a kernel. Including wrapping an CSRs operation, locking mutable static variable, memory allocator, and pointer in Rust.
Please visit the project github to see the source code of the rrxv6 projects:
https://github.com/yodalee/rrxv6
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
3. Abstract
Code of the project is explained, as well as a graph is presented, comparing the
three different versions used for getting access after entering password. First
one is the simple one without any cryptography, second one is the version with
SHA-1 and the last one is the one using blockchain.
A small not for the code; in all of the 3 scheme the DCache is disabled and
this was done, because code wouldn’t run, and when core A90 change a variable
and could print the right value, in the same time core A91 always print the
wrong value(old one).
4. 1Code analysis
1.1 Simple scheme
In the simple scheme, A90 places the password given by the user in the buffer0,
and then changes the shared variable a0 to signal A91 to do the authentication.
1.1.1 Processor A90
"a90.c"
#include "xparameters.h"
#include "xgpio.h"
#include "xscutimer.h"
#include <sleep.h>
#include <xil_cache.h>
#include "ZedboardOLED.h"
#include <stdio.h>
XScuTimer Timer;
void writeBuf(unsigned char *buf0, char *s, uint8_t len)
{
for(int i = 0; i < len; i++)
buf0[i] = s[i];
return ;
}
void readBuf(unsigned char *dest, unsigned char *s, uint8_t len)
{
for(int i=0; i < len; i++)
dest[i] = s[i];
return;
}
void printBuf(unsigned char *buf, uint8_t len) {
for(int i = 0; i < len; i++)
xil_printf("%c", buf[i]);
xil_printf("n");
}
int main (void)
1
5. {
unsigned char tmpbuf[16];
unsigned int Status, newvalue, this;
unsigned int * a0 = (unsigned int *) 0x1BF00000;
unsigned int * a1 = (unsigned int *) 0x1BF00008;
unsigned char *buffer0 = ( unsigned char *)0x1BF01000;
unsigned char *buffer1 = ( unsigned char *) 0x1BF01030;
*a0 = 0;
*a1 = 0;
Xil_DCacheDisable();
xil_printf("-- Start of the Program --rn");
xil_printf("a0 : %d a1: %d rn", *a0, *a1);
//xil_printf("%x a %x b rn", a0, a1);
usleep(400);
// PS Timer related definitions
XScuTimer_Config *ConfigPtr;
XScuTimer *TimerInstancePtr = &Timer;
// Initialize the timer
ConfigPtr = XScuTimer_LookupConfig (XPAR_PS7_SCUTIMER_0_DEVICE_ID);
Status = XScuTimer_CfgInitialize
(TimerInstancePtr, ConfigPtr, ConfigPtr->BaseAddr);
if(Status != XST_SUCCESS){
xil_printf("Timer init() failedrn");
return XST_FAILURE;
}
///XScuTimer_LoadTimer(TimerInstancePtr, 32500000);
XScuTimer_LoadTimer(TimerInstancePtr, 4000000000);
// Set AutoLoad mode
XScuTimer_EnableAutoReload(TimerInstancePtr);
xil_printf("Enter your password please: ");
char userinput[16];
scanf("%s",userinput);
writeBuf( buffer0, userinput,16);
//writeBuf( buffer0, "0123456789abcdef",16);
xil_printf("-- Written buffer0 rn");
readBuf(tmpbuf, userinput, 16);
//readBuf(tmpbuf, buffer0, 16);
printBuf(tmpbuf,16);
*a0 = 1; //changing the value of shared variable.
// Start the timer
XScuTimer_Start (TimerInstancePtr);
while( (*a1 != 1) ) {
2
6. usleep(500);
}
XScuTimer_Stop(TimerInstancePtr);
newvalue = XScuTimer_GetCounterValue(TimerInstancePtr);
this = 4000000000 - newvalue;
xil_printf("Cycles counted: %d for reply.rn", this);
*a1 = 0;
*a0 = 0;
readBuf(tmpbuf, buffer1, 8);
xil_printf("Status : rn");
printBuf(tmpbuf, 8);
return 0;
}
After including all the required libraries for each function used, a Timer is
created that will help to calculate the machine cycles.
Function writeBuf writes a character array within another, something like
string copy from the C library with given lenght(like strncpy).
Function printBuf prints a string, one character at a time for a given lenght.
In the code, we do disable the DCache(had various problems to synchronize the
2 processors;tried Invalidating and Flushing, but in the end to get the meassur-
ments, it became disabled.)
Values a0, a1 are used to synchronize the actions between the 2 proces-
sors(A90,A91) and are shared among them. Buffer0 and buffer1 are also shared
between the 2 processors and the first one is used for the input to A91 while
the second one holds the output. Output is a simple character array ’accepted’
or ’declined’.
Next the configuration of the Scu timer takes place. Timer is loaded with
value 4000000000 that is close enough to the largest 32-bit value that it can
hold to avoid underflows in the meassurment process.
User enters the 16 character password, and that is written in buffer0. Chang-
ing the value a0 to 1, so the A91 processor which is polling the variable can start
working on the authentication. Timer starts counting, while the processor(A90)
polls now the shared variable a1.
When (A91) changes the variable to 1, A90 stops the timer and counts the
cycles spent and prints them to the debug terminal.
1.1.2 Processor A91
"a91.c"
#include "xparameters.h"
#include "xgpio.h"
#include <sleep.h>
#include "xscutimer.h"
#include <xil_cache.h>
#include "ZedboardOLED.h"
3
9. xil_printf("-- Start of the Program --rn");
xil_printf("a0 : %d a1: %d rn", *a0, *a1);
//xil_printf("%x a %x b rn", a0, a1);
unsigned char input[16];
xil_printf("nWaiting to read buffer0rn");
///Xil_DCacheInvalidate();
while( (*a0) != 1) {
;
//xil_printf("a0 : %drn", *a0);
//xil_printf("a1 : %drn", *a1);
//xil_printf("wait..rn");
///Xil_DCacheInvalidate();
//Xil_DCacheInvalidate();
//sleep(1);
}
readBuf(input, buffer0 , 16);
//xil_printf("Read the buffer0 rn");
//printBuf(input, 16);
int ret = matches(input);
xil_printf("ret value: %drn",ret);
clear_OLED();
if( ret != 0) {
xil_printf("Accept authorization. rn");
print_message("Access Granted",1);
sprintf(thesi, "%4d",ret);
for(int j = 0; j < 4; j++)
print_char(thesi[j],2,j);
writeBuf(buffer1, ACCEPT, strlen(ACCEPT));
}else {
xil_printf("Decline authorization. rn");
print_message("Access Declined",1);
writeBuf(buffer1, DECLINE, strlen(DECLINE));
}
*a1 = 1;
///Xil_DCacheFlush();
return 0 ;
}
The code for the A91 processor also includes the specific header files needed.
Defines the number of users as well as the output character arrays.
In the first loop of the main(), we have a part of the code that will create
passwords of the form "xxxxafghabcdefgh" where xxxx will be the number of
the element in the array(f.e 9 will be "0009afghabcdefgh" while 1013 will be
stored as password "1013afghabcdefgh) ; to avoid writing big arrays and though
increasing the text size of the application. Also the array called passwords
stores the valid passwords that will be accepted. Function readBuf copies into
the first argument pointer len number of bytes from the character array which
starts at the pointer argument ’s’.
Funtion matches search linear throught the password’s array and compares
6
10. the input given by the user to each one of the elemnts of the array. It does
return the position found since we need to print that possition on the screen.
In the main(), again DCache is disabled, and the OLED screen is cleared.
Then the prompt "Enter password:" appears on the on-board screen.
input array will hold the input given by the user and copied from the buffer0,
where A90 processor will store the user’s input.
The processor then starts polling the a0 variable. When it becomes 1, is
copying the buffer0 to the input. and calls the function matches. On board
screen is cleared and based in the return value of the previously called function
will write "Access Granted" and will print the possition found or it will print
"Access Declined".
1.2 SHA1 scheme
In the SHA1 scheme, A91 core, do not compare the input with the users raw
password, but it precalculates the 20-bytes SHA1 on each valid password and
then compares the input fetched from buffer0 to the SHA1-encrypted array. In
A90 core now, after getting user’s input, the encryption is created and placed
into the buffer0.
1.2.1 Processor A90
"a90sha1.c"
#include "xparameters.h"
#include "xgpio.h"
#include "xscutimer.h"
#include <sleep.h>
#include <xil_cache.h>
#include "ZedboardOLED.h"
#include <stdio.h>
#include "sha1.h"
XScuTimer Timer; /* Cortex A9 SCU Private Timer Instance */
void writeBuf(unsigned char *buf0, char *s, uint8_t len)
{
for(int i = 0; i < len; i++)
buf0[i] = s[i];
return ;
}
void readBuf(unsigned char *dest, unsigned char *s, uint8_t len)
{
for(int i=0; i < len; i++)
dest[i] = s[i];
return;
}
void printBuf(unsigned char *buf, uint8_t len) {
for(int i = 0; i < len; i++)
xil_printf("%x ", buf[i]);
xil_printf("n");
}
7
11. int main (void)
{
unsigned char tmpbuf[16];
unsigned char encrypted[SHA1_BLOCK_SIZE];
unsigned int Status, newvalue, this;
unsigned int * a0 = (unsigned int *) 0x1BF00000;
unsigned int * a1 = (unsigned int *) 0x1BF00008;
unsigned char *buffer0 = ( unsigned char *) 0x1BF01000;
unsigned char *buffer1 = ( unsigned char *) 0x1BF01030;
*a0 = 0;
//Xil_DCacheFlush();
Xil_DCacheDisable();
Xil_ICacheDisable();
xil_printf("-- Start of the Program --rn");
xil_printf("a0 : %d a1: %d rn", *a0, *a1);
//xil_printf("%x a %x b rn", a0, a1);
//usleep(400);
// PS Timer related definitions
XScuTimer_Config *ConfigPtr;
XScuTimer *TimerInstancePtr = &Timer;
// Initialize the timer
ConfigPtr = XScuTimer_LookupConfig (XPAR_PS7_SCUTIMER_0_DEVICE_ID);
Status = XScuTimer_CfgInitialize (TimerInstancePtr, ConfigPtr,
ConfigPtr->BaseAddr);
if(Status != XST_SUCCESS){
xil_printf("Timer init() failedrn");
return XST_FAILURE;
}
XScuTimer_LoadTimer(TimerInstancePtr, 4000000000);
// Set AutoLoad mode
XScuTimer_EnableAutoReload(TimerInstancePtr);
xil_printf("Enter your password please: ");
char userinput[16];
scanf("%s",userinput);
SHA1_CTX ctx;
sha1_init(&ctx);
sha1_update(&ctx, userinput, 16);
sha1_final(&ctx, encrypted);
writeBuf( buffer0, encrypted,SHA1_BLOCK_SIZE);
//writeBuf( buffer0, "0123456789abcdef",16);
xil_printf("-- Written buffer0 rn");
readBuf(tmpbuf, encrypted, SHA1_BLOCK_SIZE);
//readBuf(tmpbuf, buffer0, 16);
printBuf(tmpbuf,SHA1_BLOCK_SIZE);
*a0 = 1; //changing the value of shared variable.
8
12. //Xil_DCacheFlush();
// Start the timer
XScuTimer_Start (TimerInstancePtr);
while( (*a1 != 1) ) {
// Xil_DCacheInvalidate();
usleep(500);
}
XScuTimer_Stop(TimerInstancePtr);
newvalue = XScuTimer_GetCounterValue(TimerInstancePtr);
this = 4000000000 - newvalue;
xil_printf("Cycles counted: %d for reply.rn", this);
*a1 = 0;
*a0 = 0;
//Xil_DCacheFlush();
//Xil_DCacheInvalidate();
readBuf(tmpbuf, buffer1, 8);
xil_printf("Status : rn");
printBuf(tmpbuf, 8);
return 0;
}
In the processor A90’s code, there are not many differences than the previous
one. All needed libraries are included, and the shared memory addresses remain
the same.
One is the encrypted array which will hold the encryption under SHA-1 of
the user’s input. The output will be 20 bytes long as we can see by inspecting
the sha1.c code provided. SHA1 process take place in lines[68-72] and from the
16-bit user input we end up with a 20 byte long encrypted hash.
The rest remains as in the previous simple scheme. DCache and ICache are
also disabled in this scheme as well. The main difference from the previous
scheme is that in this scheme, A90 processor do not share with the A91 the
users input but the SHA1 applied on that input.
1.2.2 Processor A91
"a91sha1.c"
#include "xparameters.h"
#include "xgpio.h"
#include <sleep.h>
#include "xscutimer.h"
#include <xil_cache.h>
#include "ZedboardOLED.h"
#include <string.h>
#include <stdio.h>
9
15. fill_encrypted();
//Xil_DCacheInvalidate();
Xil_DCacheDisable();
Xil_ICacheDisable();
clear_OLED(); // clear the OLED
print_message("Enter password2:",1);
unsigned int * a0 = (unsigned int *) 0x1BF00000;
unsigned int * a1 = (unsigned int *) 0x1BF00008;
unsigned char *buffer0 = ( unsigned char *) 0x1BF01000;
unsigned char *buffer1 = ( unsigned char *) 0x1BF01030;
char thesi[4];
*a0 = 0;
memcpy(thesi, 32, 4); // in a non printable char.
usleep(1000000);
xil_printf("-- Start of the Program --rn");
xil_printf("a0 : %d a1: %d rn", *a0, *a1);
//xil_printf("%x a %x b rn", a0, a1);
unsigned char input[16];
xil_printf("nWaiting to read buffer0rn");
//Xil_DCacheInvalidate();
while( (*a0) != 1) {
//xil_printf("a0 : %drn", *a0);
//xil_printf("a1 : %drn", *a1);
//xil_printf("wait..rn");
//Xil_DCacheInvalidate();
//Xil_DCacheInvalidate();
//sleep(1);
}
readBuf(input, buffer0 , 20);
xil_printf("Read the buffer0 rn");
printBuf(input, 20);
int ret = matches(input);
xil_printf("ret value: %drn",ret);
clear_OLED();
if( ret != 0) {
xil_printf("Accept authorization. rn");
print_message("Access Granted",1);
sprintf(thesi, "%4d",ret);
for(int j = 0; j < 4; j++)
print_char(thesi[j],2,j);
writeBuf(buffer1, ACCEPT, strlen(ACCEPT));
}else {
xil_printf("Decline authorization. rn");
print_message("Access Declined",1);
writeBuf(buffer1, DECLINE, strlen(DECLINE));
}
12
16. *a1 = 1;
//Xil_DCacheFlush();
return 0 ;
}
As for the code on the A91 processor for the SHA1 scheme, the main differ-
ence is the existance of encrypted array, that has length same with the number
of the valid users.
Function fill_encrypted traverses througth the passwords array and cre-
ated the SHA1 hash of each one, storing it on the encrypted array.
Function matches in this code, search again in a linear way, througth en-
crypted array this time and compares the shared hash from A90 to each one
stored into the matrix.
There is not many to explain in the main() that are different from the simple
scheme described in the previous section, expept that fill_encrypted is called
at first to initiate and create the hashes of the passwords; to be ready for the
comparison latter on.
1.3 SHA1-Blockchain scheme
In the last scheme, processor A90, provides three inputs to the A91 core each
time. The first one is the encrypted(SHA1) password that the user entered.
The other two are the cycles counted from the last success log-in, as well as the
hash of the hashed password incremented by the cycles time provided as the
second argument.
Of course in the first log-in attempt, cycles counted are zero.
When A91 gets the signal, fetches the encrypted password, will check it
against to its encypted passwords and in anycase will call the function fill_blockchain
to save the new calculations for each element in the matrix. Afterwards in func-
tion matches ; if encrypted password passes the test, the blockchain array will
also be tested before accepting and authenticating the request.
1.3.1 Processor A90
"a90sha1_blockchain.c"
#include "xparameters.h"
#include "xgpio.h"
#include "xscutimer.h"
#include <sleep.h>
#include <xil_cache.h>
#include "ZedboardOLED.h"
#include <stdio.h>
#include "sha1.h"
XScuTimer Timer; /* Cortex A9 SCU Private Timer Instance */
void writeBuf(unsigned char *buf0, char *s, uint8_t len)
{
for(int i = 0; i < len; i++)
buf0[i] = s[i];
13
17. return ;
}
void readBuf(unsigned char *dest, unsigned char *s, uint8_t len)
{
for(int i=0; i < len; i++)
dest[i] = s[i];
return;
}
void printBuf(unsigned char *buf, uint8_t len) {
for(int i = 0; i < len; i++)
xil_printf("%x ", buf[i]);
xil_printf("n");
}
int main (void)
{
unsigned char tmpbuf[16];
unsigned char encrypted[SHA1_BLOCK_SIZE];
unsigned char hashed_block_array[SHA1_BLOCK_SIZE];
unsigned int Status, newvalue, this, test_this;
unsigned int * a0 = (unsigned int *) 0x1BF00000;
unsigned int * a1 = (unsigned int *) 0x1BF00008;
unsigned char *buffer0 = ( unsigned char *) 0x1BF01000;
unsigned char *buffer1 = ( unsigned char *) 0x1BF01030;
unsigned int *time_i = (unsigned int *) 0x1BF01050;
unsigned char *hashed_block = (unsigned char *) 0x1BF01070;
int turn = 0;
this = 0; // just to be sure in case of first failed attempt,
// wont take any random value as time_i.
Xil_DCacheDisable();
while(1) {
*a0 = 0;
//Xil_DCacheFlush();
xil_printf("-- Start of the Program --rn");
xil_printf("a0 : %d a1: %d rn", *a0, *a1);
//xil_printf("%x a %x b rn", a0, a1);
//usleep(400);
// PS Timer related definitions
XScuTimer_Config *ConfigPtr;
XScuTimer *TimerInstancePtr = &Timer;
// Initialize the timer
ConfigPtr = XScuTimer_LookupConfig (XPAR_PS7_SCUTIMER_0_DEVICE_ID);
Status = XScuTimer_CfgInitialize (TimerInstancePtr, ConfigPtr,
ConfigPtr->BaseAddr);
if(Status != XST_SUCCESS){
14
19. printBuf(tmpbuf,SHA1_BLOCK_SIZE);
xil_printf("--n’r");
}
*a0 = 1; //changing the value of shared variable.
//Xil_DCacheFlush();
// Start the timer
XScuTimer_Start (TimerInstancePtr);
while( (*a1 != 1) ) {
// Xil_DCacheInvalidate();
usleep(500);
}
XScuTimer_Stop(TimerInstancePtr);
newvalue = XScuTimer_GetCounterValue(TimerInstancePtr);
test_this = 4000000000 - newvalue;
xil_printf("Cycles counted: %d for reply.rn", test_this);
*a1 = 0;
*a0 = 0;
//Xil_DCacheFlush();
//Xil_DCacheInvalidate();
readBuf(tmpbuf, buffer1, 8);
xil_printf("Status : rn");
printBuf(tmpbuf, 8);
if( !strncmp(tmpbuf, "accepted", 8)) {
this = test_this;
xil_printf("keeping the timern");
} else {
xil_printf("declined, not keeping the timenr");
}
turn = 1;
}
return 0;
}
In main program, we disable data cache, and we go into an endless loop.
Instructions are like the previous schemes initializing all required things for the
scu_timer and getting input from the user. After, the SHA-1 encryption of the
input is stored into encrypted array, and written in buffer0 shared address so
A91 core can access it. If there is the first time running, time_i and hash_block
are having the values 0.
If not, we copy the encrypted password into the hashed_block_array and
then we assign an unsigned int pointer( uints have 4 bytes lenght in this
machine) to the 16th byte of the hashed_block_array.
This happens, to be able with the next instruction *add_pointer = *add_pointer
+ this; to be able to make the addition of the cycles meassured from previous
authentication to the hash.
In the end the whole result is again hashed one more time with SHA-1
16
20. algorithm and the 20 bytes output is stored into hashed_block shared address
with the A91 core. Then the value of the variable a0 is modified to signal the
A91 core. Timer starts to count the cycles and after polling the shared variable
a1 ; timer stops to take the meassurment. An extra test follows since we do not
intent keeping the values of the timer when there is not a succesful attempt. In
the end turn variable is used as a flag and always stays to 1. Is used to escape
the first part of the if statement which is only used on the first log-in.
1.3.2 Processor A91
"a91sha1_blockchain.c"
#include "xparameters.h"
#include "xgpio.h"
#include <sleep.h>
#include "xscutimer.h"
#include <xil_cache.h>
#include "ZedboardOLED.h"
#include <string.h>
#include <stdio.h>
#include "sha1.h"
#define ACCEPT "accepted"
#define DECLINE "declined"
//#define DEBUG_PRINT 1
XScuTimer Timer; /* Cortex A9 SCU Private Timer Instance */
unsigned int * a0 = (unsigned int *) 0x1BF00000;
unsigned int * a1 = (unsigned int *) 0x1BF00008;
unsigned char *buffer0 = ( unsigned char *) 0x1BF01000;
unsigned char *buffer1 = ( unsigned char *) 0x1BF01030;
unsigned int *time_i = (unsigned int *) 0x1BF01050;
unsigned char *hashed_block = (unsigned char *) 0x1BF01070;
int turn = 0;
#define USERS 1024
unsigned char passwords[USERS][16];
unsigned char encrypted[USERS][SHA1_BLOCK_SIZE]; // storing the sha1 of
each password.
unsigned char blockchain[USERS][SHA1_BLOCK_SIZE]; // storing the
blockchain_stuff(time_i hashed after added on the hased password)
unsigned char blockchain2[USERS][SHA1_BLOCK_SIZE];
// fill_encrypted: creates the hashes of the values that will be needed
to
// compare agaist the hash(value) of the given password.
void fill_encrypted(void)
{
for(int i = 0; i < USERS; i++) {
17
21. SHA1_CTX ctx;
sha1_init(&ctx);
sha1_update(&ctx, passwords[i], 16);
sha1_final(&ctx, encrypted[i]);
#ifdef DEBUG_PRINT
xil_printf("SHA1[");
for( int j = 0; j < 16; j++) {
xil_printf("%c",passwords[i][j]);
}
xil_printf("] = ");
for(int w = 0; w < SHA1_BLOCK_SIZE; w++)
xil_printf("%4x", encrypted[i][w]);
xil_printf("n");
#endif
}
}
// filling the array with hash( hash(password_i +time_i))
void fill_blockchain(void)
{
for(int i = 0; i < USERS; i++) {
//getting the hash(password) in each element.
//for(int k = 0; k < SHA1_BLOCK_SIZE; k++)
memcpy(blockchain[i], encrypted[i], 20);
//blockchain[i][0] = encrypted[k];
SHA1_CTX ctx;
sha1_init(&ctx);
// add time_i received from the shared memory.
//printBuf(blockchain[i],20);
unsigned int *add_pointer = (unsigned int
*)&blockchain[i][SHA1_BLOCK_SIZE-4];
*add_pointer = *add_pointer + (*time_i);
sha1_update(&ctx, blockchain[i], 20);
sha1_final(&ctx, blockchain[i]); // could work for blockchain
array also? i should look the code in sha1.c
#ifdef DEBUG_PRINT
xil_printf("BlockSHA1[");
for( int j = 0; j < 16; j++) {
xil_printf("%c",passwords[i][j]);
}
xil_printf("] = ");
18
22. for(int w = 0; w < SHA1_BLOCK_SIZE; w++)
xil_printf("%4x", blockchain[i][w]);
xil_printf("n");
#endif
}
}
void writeBuf(unsigned char *buf0, char *s, uint8_t len)
{
for(int i = 0; i < len; i++)
buf0[i] = s[i];
return ;
}
void readBuf(unsigned char *dest, unsigned char *s, uint8_t len)
{
for(int i=0; i < len; i++)
dest[i] = s[i];
return;
}
void printBuf(unsigned char *buf, uint8_t len) {
for(int i = 0; i < len; i++)
xil_printf("%x ", buf[i]);
xil_printf("n");
}
int matches(unsigned char *in) {
if(turn == 0) {
for( int i = 0; i < USERS; i++){
//xil_printf("Testing0: %drn", i);
//printBuf(encrypted[i],20);
if( strncmp( (const char *)in, (const char *) encrypted[i],
SHA1_BLOCK_SIZE) == 0)
return i+1;
}
} else {
for( int i = 0; i < USERS; i++){
//xil_printf("Testing1: %drn", i);
if( strncmp( (const char *)in, (const char *) encrypted[i],
SHA1_BLOCK_SIZE) == 0)
{
#ifdef DEBUG_PRINT
xil_printf("Passed first test--printing hashblockrn");
printBuf(hashed_block, 20);
xil_printf("Passed first test--printing blockchain[i]rn");
19
26. 2Results with linear search
It is important to define the way the results were obtained: for variable number
of users, the worst case in terms of machine cycles were meassured. Since the
algorithm searchs within the matrix to compare character arrays; the worst case
always is when the desired password lies last.
As one can observe, the SHA1/blockchain scheme has significant more over-
head than the 2 other schemes. As well that very quick the line related to the
SHA1, is increasing because in contrast to the simple scheme it doesn’t compare
16 bytes but 20 bytes each time, as the 20-byte output of SHA1.
Figure 2.1: Results meassured for the 3 different schemes of log in.
23
27. 3Theoretical question: Scaling the synchronization
into more than 2 processors
In the event that there are more than two processors involved into the con-
structed scheme, we could separate different cases.
3.1 Two processors require access for different
purpose each
One case is when 2 or more cores require to get access with their password on
another processor’s resources.
According to the shared memory paradigm used in the above implemen-
tation, a system could be defined, where the processors(f.e A90,A91) get user
inputs and A93 has responsible to reply with ACCESS/DECLINE of their au-
thentication request. We could have shared variable a0,a1 that are accessed in
RoundRobin way by the processor A93; checking the variables this time and
not polling forever.
3.2 Two processors contribute together into a
single authentication access
Another case could be that in fact for the authentication to be complete more
than 1 cores need to contribute with their inputs. Using shared variables with
polling this time (till the A93 extracts both buffers as the inputs) and different
address locations for each buffer respective to the contirbuting to input processor
could solve the problem. For the reply, both(A90, A91) can poll the same
variable, and when detect that it has changed they can check for the result.
24