The document contains code snippets for Java network security programming. Experiment 1 deals with network security programming using TCP/IP protocols for different layers. Experiment 2 focuses on socket security programming involving address structures and functions. Experiment 3 is about APIs security programming for non-blocking sockets and timeouts. Experiment 4 implements a basic web server for firewall programming. The remaining experiments cover CORBA, cryptography, digital signatures and Java network security in general.
Security+ Guide to Network Security Fundamentals, 3rd Edition, by Mark Ciampa
Knowledge and skills required for Network Administrators and Information Technology professionals to be aware of security vulnerabilities, to implement security measures, to analyze an existing network environment in consideration of known security threats or risks, to defend against attacks or viruses, and to ensure data privacy and integrity. Terminology and procedures for implementation and configuration of security, including access control, authorization, encryption, packet filters, firewalls, and Virtual Private Networks (VPNs).
CNIT 120: Network Security
http://samsclass.info/120/120_S09.shtml#lecture
Policy: http://samsclass.info/policy_use.htm
Many thanks to Sam Bowne for allowing to publish these presentations.
The document discusses the motivation and design of file system implementations. It describes how file systems map the logical structure to physical storage, using various on-disk and in-memory data structures. These include boot blocks, superblocks, directories, inodes/file control blocks, buffer caches, open file tables, and more. Common operations like creating, opening, reading and closing files are also outlined.
The presentation describes basics of cryptography and information security. It covers goals of cryptography, history of cipher symmetric and public key cryptography
This document provides information about the CS8792 CRYPTOGRAPHY & NETWORK SECURITY course. It discusses cryptography, the course outcomes, syllabus, and key concepts in cryptography including symmetric encryption, asymmetric encryption, data integrity algorithms, and authentication protocols. It also covers essential network and computer security requirements, legal and ethical issues, security policies, OSI security architecture including security attacks, mechanisms, and services.
Introduction to Public key Cryptosystems with block diagrams
Reference : Cryptography and Network Security Principles and Practice , Sixth Edition , William Stalling
This document discusses block ciphers, including their definition, structure, design principles, and avalanche effect. A block cipher operates on fixed-length blocks of bits and uses a symmetric key. It encrypts bits in blocks rather than one by one. Block ciphers have advantages like high diffusion but are slower than stream ciphers. They are built using the Feistel cipher structure with a number of rounds and keys. Important design principles for block ciphers include the number of rounds, design of the round function, and key schedule algorithm. The avalanche effect causes a small input change to result in a significant output change.
Computer networks a tanenbaum - 5th editioneepawan1809
This document is the front matter of a textbook on computer networks. It includes the title, copyright information, dedication, and table of contents. The textbook covers topics such as the physical layer, data link layer, network layer, transport layer, and examples of computer networks including the Internet, mobile networks, Ethernet, and wireless networks. It is intended to introduce students to the fundamental concepts and protocols of computer networking.
This document discusses protocol layering in communication networks. It introduces the need for protocol layering when communication becomes complex. Protocol layering involves dividing communication tasks across different layers, with each layer having its own protocol. The document then discusses two principles of protocol layering: 1) each layer must support bidirectional communication and 2) the objects under each layer must be identical at both sites. It provides an overview of the OSI 7-layer model and describes the basic functions of each layer.
The document describes a program to simulate the sliding window protocol for Go back n. It generates random numbers to determine the total number of frames and window size. Frames up to the window size are transmitted and acknowledgements are received. If an acknowledgement is not received, the frames are retransmitted. This continues until all frames are successfully transmitted.
The document discusses constructing a directed acyclic graph (DAG) to represent the computation of values in a basic block of code. It describes how to build the DAG by processing each statement and creating nodes for operators and values. The DAG makes it possible to analyze the code block to optimize computations by removing duplicate subexpressions and determine which values are used inside and outside the block.
This document discusses various inter-process communication (IPC) mechanisms in Linux, including pipes, FIFOs, and message queues. Pipes allow one-way communication between related processes, while FIFOs (named pipes) allow communication between unrelated processes through named pipes that persist unlike anonymous pipes. Message queues provide more robust messaging between unrelated processes by allowing messages to be queued until received and optionally retrieved out-of-order or by message type. The document covers the key functions and system calls for creating and using each IPC mechanism in both shell and C programming.
Key management is the set of techniques and procedures for establishing and maintaining secure key relationships between parties. It involves generating, distributing, storing, updating, and revoking cryptographic keys. The objectives of key management are to maintain secure keying material and relationships to counter relevant threats like key compromise, in accordance with a security policy. Techniques include symmetric and public-key encryption, key hierarchies, certificates, and life cycle processes around user registration and key installation, update, and destruction.
High level overview of CoAP or Constrained Application Protocol. CoAP is a HTTP like protocol suitable for constrained environment like IoT. CoAP uses HTTP like request response model, status code etc.
- DES (Data Encryption Standard) is a symmetric block cipher algorithm that encrypts data in 64-bit blocks using a 56-bit key. It was the first encryption standard adopted by the U.S. government for protecting sensitive unclassified federal government information.
- DES works by performing 16 rounds of complex substitutions and permutations on each data block, encrypting it using the key. It has various modes of operation like ECB, CBC, CFB, OFB, and CTR that specify how it operates on data.
- In 1998, DES was broken using a brute force attack by the Electronic Frontier Foundation in just 3 days, showing the need for stronger algorithms like AES which replaced DES as the encryption standard
This document discusses subnetting and provides examples. It describes subnetting as breaking up a large network into smaller subnets. Subnetting allows creating multiple networks from a single address block and maximizes addressing efficiency. The document then provides examples of subnetting a network using CIDR notation and calculating the number of subnets, hosts per subnet, valid IP ranges, and broadcast addresses. It also discusses an example of optimally subnetting the IP addresses needed across different departments within a university based on their host requirements.
The document contains source code and instructions for 8 experiments on GUI programming lab. The experiments include designing a student information card, an interest calculator, a basic calculator, formatting text using checkboxes and option buttons, calculating factorials, displaying regional languages of Indian states, creating a menu, and developing a simple notepad application. The experiments demonstrate concepts like labels, textboxes, buttons, lists, event handling procedures and printing messages.
This document provides an overview of advanced I/O functions for network programming in UNIX, including socket timeouts, recv/send functions, readv/writev functions, recvmsg/sendmsg functions, ancillary data, determining queued data amounts, sockets and standard I/O, and T/TCP. It describes various ways to implement timeouts for socket I/O, flags and parameters for different I/O functions, using scatter-gather I/O, receiving ancillary protocol-specific data, and how T/TCP can avoid the three-way handshake for repeat clients and servers.
The document describes an experiment on linear search in C programming. It explains the theory of linear search through pseudocode. The program allows the user to input elements into an array, search for a target element, and output whether the element was found and its position. It searches each element sequentially until a match is found or the whole array is traversed. Sample runs show it finding and not finding elements correctly.
This document provides information about the 8th semester Network Security lab practical course for Computer Science and Engineering students at Shri Rawatpura Sarkar Institute of Technology-II in New Raipur, Chhattisgarh, India. It lists 10 experiments to be performed related to network security programming using TCP/IP, sockets, APIs, web security, cryptography, and more. It also provides sample code for some of the experiments and recommends books for reference.
The document contains 10 programming experiments involving basic C programming concepts like functions, arrays, loops, conditional statements, etc. Each experiment has the aim, code implementation, and sample output for programs to calculate sphere volume and area, sum of digits in a number, triangle properties, Pythagorean triplets, prime numbers in a range, recursive functions to reverse a number, sum even numbers, bubble sort an array, and find common elements between two arrays.
The document discusses the Telnet protocol, which provides a standard method for connecting terminal devices at one site to processes at another site. It describes the key components of Telnet, including the Initial Connection Protocol (ICP) for establishing connections, the Network Virtual Terminal (NVT) specification, and Telnet control signals. Specific control signals like DATA MARK and BREAK are also defined.
The document discusses recapturing the South African narrative through a brand summit and awards. It provides background on South Africa's history, from the end of apartheid to the current day. The summit aims to understand South Africa's current brand image, identify factors impacting its brand, discuss brand narratives and benchmark South Africa against other countries. It will recognize brands helping South Africa shine and facilitate discussions on South Africa's ideal brand identity. The summit includes panels on business, politics, communities and global benchmarking to discuss these topics from a nation brand perspective.
This document contains code for several C++ programs related to civil engineering applications. The first program calculates pipe flow distributions using the Hardy Cross method. The second program determines the friction factor of a circular pipe. The third program performs network analysis and critical path determination for a CPM network. The fourth program calculates vertical effective stress at a given depth for different soil profiles and water table conditions. The fifth program determines the bearing capacity of soil given soil and water table properties.
The document contains the source code for 7-10 experiments in an ASP.NET Software Technology Lab Manual. The experiments cover topics like using dropdown lists, listboxes, textbox events, radio buttons, validation in textboxes, and data list controls in ASP.NET. It also includes a longer experiment on performing CRUD (create, read, update, delete) operations on a student database using ADO.NET Entity Framework. The experiments provide the ASP.NET code and screenshots of the output for each program.
Unit Testing on Android involves testing individual units or components of code to find and fix bugs early. There are several test frameworks for Android like JUnit and Mockito that make unit testing easier. JUnit provides annotations to mark test methods and assertions to validate results. Mockito allows mocking dependencies to isolate and focus on the code being tested. Robolectric runs tests directly on a JVM without needing an emulator for faster testing. Code coverage tools like JaCoCo measure how much code is executed during tests.
The document contains programs and outputs from 7 experiments involving numerical methods:
1) A program to calculate the area and perimeter of a rectangle and area and circumference of a circle.
2) A program to determine if a character entered is a capital letter, small letter, digit or symbol.
3) A menu-driven program with options to calculate factorial, check if prime, and check if even/odd.
4) A program to sort an array using bubble sort.
5) A program to find roots of an equation using Newton-Raphson method.
6) A program to solve a differential equation using the Runge-Kutta method.
7) A program
The document contains a list of 16 experiments to be performed in Java programming. It includes programs to check Armstrong numbers, sort strings, multiply matrices, calculate volume and surface area of a box, use copy constructors, create abstract classes for shapes and inherit subclasses, handle exceptions, create custom exceptions, create and run threads, use network classes, handle mouse events using applets, implement remote methods using RMI, create servlets, perform student mark list processing using JDBC, and create a basic text editor. It also provides sample code for 10 programs related to number swapping, multiplication tables, checking Armstrong numbers, calculating sum, checking palindromes, reversing numbers, finding largest of 3 numbers, printing prime numbers, Floyd
Computer Hardware lab help us demonstrate and learn cpu and other device very well.It also help to learn the installation concept of both operating system and Windows office.
The document is a lab manual for an Object Oriented Programming Language (C++) class. It contains descriptions of 6 experiments covering topics like checking if a number is prime, finding the largest of two numbers, calculating sums using loops, calculating a series using functions, matrix multiplication, and passing variables by value vs reference. The experiments provide code snippets to demonstrate the concepts and expected output.
The document provides details for performing a system analysis for a software engineering project. It outlines the following steps:
1. Introduction including purpose, intended audience, project scope.
2. Overall description of the product including perspective, features, user classes, operating environment, and design/implementation constraints.
3. Functional requirements organized by user class/feature including descriptions, conditions, business rules.
4. External interface requirements including user interfaces, hardware interfaces, software interfaces, communications interfaces.
5. System features including reliability, security, performance, supportability, design constraints.
The document specifies requirements for a software engineering project and provides guidance on performing requirement analysis and developing a software requirements specification (SR
Hey! Socket programming got you down? Is this stuff just a little too difficult to figure out
from the man pages? You want to do cool Internet programming, but you don't have time to wade
through a gob of structs trying to figure out if you have to call bind() before you connect(),
etc., etc.
Well, guess what! I've already done this nasty business, and I'm dying to share the information
with everyone! You've come to the right place. This document should give the average competent C
programmer the edge s/he needs to get a grip on this networking noise.
And check it out: I've finally caught up with the future (just in the nick of time, too!) and have
updated the Guide for IPv6! Enjoy!
The document provides information about MATLAB (Matrix Laboratory), including what it is, its typical uses, and its main components. MATLAB is a high-level technical computing language and environment. It is used for a wide range of applications like math and computation, algorithm development, data analysis, modeling and simulation, and more. The key parts of MATLAB include its development environment, mathematical function library, programming language, graphics capabilities, and API. It also discusses MATLAB toolboxes which provide specialized functions for domains like signal processing, control systems, and others.
Beyond breakfast is a white paper by Eurest that discusses trends in breakfast eating and the importance of breakfast. It finds that while breakfast is important for health and productivity, up to a third of people skip it due to lack of time. Working habits have changed with longer hours and commutes, pushing breakfast later. However, organizations can encourage earlier starts, breakfast meetings, and convenient healthy options to help people prioritize breakfast.
The document discusses Java network programming and communication between applications. It covers topics like Java source code compilation, client-server models, sockets, ports, TCP and UDP clients and servers in Java code. It provides examples of Java code for TCP client, TCP server, UDP client and UDP server. It also discusses Remote Procedure Calls (RPC) and gives an example of implementing average calculation using RPC.
The document discusses Berkeley socket network programming in TCP. It covers how to create server and client sockets in TCP, including the socket(), bind(), listen(), accept(), and connect() functions. It also covers converting between host and network byte order, socket options like SO_REUSEADDR, and the TCP connection states including TIME_WAIT.
The document discusses the TCP/IP protocol suite and its layers - application, transport, internet and link layer. It describes the functionality of each layer and the data encapsulation between layers. It also discusses protocols like TCP, UDP, IP, ICMP and their usage. Network concepts like routers, bridges, classes of networks and sockets are explained along with examples.
The document discusses network programming with sockets. It outlines basic socket programming concepts like client-server models, TCP and UDP services, and BSD sockets. It then describes key socket functions for creation and setup, establishing connections, sending/receiving data, and tearing down connections.
ObjectiveResource is an Objective-C port of Ruby on Rails' ActiveResource. It provides a way to serialize objects to and from Rails' standard RESTful web-services (via XML or JSON) and handles much of the complexity involved with invoking web-services of any language from the iPhone.
This talk shows you how easy it is to create a 2-way communication channel between a very basic Rails application and an iPhone app.
This project uses a Raspberry Pi and Arduino to measure temperature throughout the day and record maximum and minimum temperatures. An LM35 temperature sensor measures the surrounding temperature and sends the data to an Arduino Uno board, which converts it to Celsius and sends it to a Raspberry Pi. The Pi runs a Node.js server to send the temperature data to a client like a mobile or desktop app, which displays the data in a graph using D3.js.
Socket programming allows two programs to communicate over a network. It uses file descriptors and structs like sockaddr to define endpoints. There are two main socket types - stream sockets for TCP and datagram sockets for UDP. Key functions include socket(), bind(), listen(), accept(), send(), recv(), sendto(), and receivefrom(). A TCP server will create a socket, bind to a port, listen for connections, accept requests, and send/receive data. A TCP client connects and sends/receives similarly. A UDP server and client use sendto()/receivefrom() instead of connect().
The document discusses Unix domain sockets and provides examples of client-server communication using Unix domain streams and datagrams, including passing file descriptors between processes and receiving sender credentials; it also describes the socket address structure for Unix domain sockets and functions like socketpair() and socket() for Unix domain communication on a single host.
This document discusses using Ethernet with Arduino. It provides code examples for using Arduino as an Ethernet server and client. It also discusses using the ENC28J60 Ethernet shield and its ethercard library, which provides higher performance than the standard Ethernet shield. Examples are given for an Ethernet server that handles client connections and reads/writes data, an Ethernet client that makes an HTTP request to Google, and an ENC28J60 client example.
This is all about socket programming in java using TCP and UDP socket and an example of simple Echo Server.
Also includes concepts of the socket, Socket class and methods and use of those.
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdfajay1317
This document describes code for a multi-threaded web proxy. The proxy receives HTTP requests from clients, forwards the requests to the intended web server, receives the response, and sends the response back to the client. Each client request is handled by a separate thread. Key functions include processing each request in a thread, connecting to the destination web server, parsing the URI to extract host/path/port, and logging each request.
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docxMARRY7
/* Lab Assignment 4 CSE330 Spring 2014 */
/* Skeleton Code for ex0 of lab4 */
/* No code will be provided for ex1 of lab4 */
#include <stdio.h> /* for NULL */
#include <ctype.h> /* for atoi() */
#include <errno.h> /* for perror() */
#include <signal.h> /* for sigvec() etc. */
#include <sys/types.h> /* for <arpa/inet.h> */
#include <sys/socket.h> /* for PF_INET, etc. */
#include <netinet/in.h> /* for struct sockaddr_in */
#include <arpa/inet.h> /* for inet_addr() */
#include <sys/time.h>
#include "lab4.h"
/* this is in netinet/in.h; included here for reference only.
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
*/
/***************************************************************************/
#define LINESIZE 80
#define TYPE0TIMEOUT 3
#define TYPE1TIMEOUT 30
/* You should give a long timeout, like 30sec, otherwise */
/* duplicated responses from the server may cause some problem */
#define MAXRETRY 3
/***************************************************************************/
static char *RCSId="$Id: client2.c,v 4 2014/04/20 03:15:07 cse3300 Exp $";
/***************************************************************************/
/* some functions you may find useful if you implement them */
extern int stringToAddress(char *s, struct sockaddr_in *a);
extern int msgok(LABMSG *);
extern u_short msgchecksum(u_short *);
extern void alarmCatcher(void);
extern int tries; /* for retransmission routines */
int numtries;
/***** this will die ****/
FILE *logFile;
void die(char *s)
{
perror(s);
exit(2);
}
void startTimer(int secs)
{
alarm(secs);
}
void stopTimer(void)
{
alarm(0);
}
/* should change it by yourself if needed!!! */
void printResponse(LABMSG *mp, int ck)
{
int type;
mp->courseEtc = ntohs(mp->courseEtc);
type = ( (mp->courseEtc & MESSAGETYPE) !=0)?1:0;
printf("course=%d, Type=%d\n", mp->courseEtc&0x3fff,type);
if (ntohl(mp->cookie) != ck)
printf("Cookies don't match: sent %x received %x\n",mp->cookie,ck);
if (mp->courseEtc & REQRESP)
printf("response ");
else {
printf("request??\n");
return;
}
mp->result = ntohs(mp->result);
/*printf(" result = %x: ",mp->result);*/
if (mp->result&TRANSOUTCOME) { /* Check outcome */
printf("error: ");
switch (mp->result & 0x7fff) {
case ERROR_CHECKSUM:
printf("checksum failure\n");
break;
case ERROR_SYNTAX:
printf("syntax error\n");
break;
case ERROR_UNKSSN:
printf("unknown SSN %d\n", ntohl(mp->reqSSN) );
break;
case ERROR_SERVER:
printf("Unspecified Server Error\n");
default:
printf("Unknown Error.\n");
} /* case switch */
} else { /* successful transaction */
if(type)printf("Test succeeded.");
if (!type) /* Type 0 -- print SSN and Response */
printf(": %d -> %d\n", ntohl(mp->reqSSN), mp->result&0x7fff);
else
printf("\n"); /* XXX print number of responses */
}
}
/*-----------------------------------*/
/* added by ZXC:
this fun ...
Introduction
This Tutorial is On Socket Programming In C Language for Linux. Instructions Give Below will only work On Linux System not in windows.
Socket API In windows is called Winsock and there we can discuss about that in another tutorial.
What is Socket?
Sockets are a method for communication between a client program and a server program in a network.
A socket is defined as "the endpoint in a connection." Sockets are created and used with a set of programming requests or "function calls" sometimes called the sockets application programming interface (API).
The most common sockets API is the Berkeley UNIX C interface for sockets.
Sockets can also be used for communication between processes within the same computer.
Socket programming allows applications on networked computers to communicate reliably using TCP or unreliably using UDP. A socket represents an open connection between two endpoints and has methods to get input/output streams, the remote host/port, and local port. A client socket connects to a server, while a server socket listens on a port and accepts connections from clients.
This document contains code for a server-client program that allows communication between a server and multiple clients.
The ServerProgram class handles listening for new client connections on the server socket. When a client connects, it sends a greeting message and begins receiving data from the client. Received data is passed to a delegate to update UI controls.
The ClientProgram class manages connecting to the server, receiving data which is passed to a delegate, and sending data to the server.
The serverForm and clientForm classes create instances of the server and client programs, and contain UI elements and button click handlers to control connection, disconnection, and sending/receiving data.
The document discusses distributed programming using Java sockets and RMI. It describes UDP and TCP protocols, with UDP being connectionless and less reliable while TCP is connection-oriented. It then covers socket programming using DatagramSocket and DatagramPacket for UDP, and Socket and input/output streams for TCP. The document also discusses implementing a remote interface using RMI to allow method calls between JVMs.
Byte ordering refers to the ordering of bytes in memory for numeric values. There are two types: network byte ordering stores the most significant byte at the lowest memory address, while host byte ordering is the opposite. Sockets provide an interface between processes and the transport layer, allowing processes to communicate over a network. Common socket types are stream sockets for reliable connected communication using TCP and datagram sockets for unreliable communication using UDP. Functions like bind(), listen(), accept(), send(), and recv() are used to set up and communicate over sockets.
The document contains a lab manual for computer networks that lists various experiments to be conducted. It includes experiments on socket programming, TCP and UDP communication using one-way and two-way protocols, file transfer using TCP, sliding window protocols, broadcasting, checksum calculations, routing algorithms, and remote method invocation. The experiments are scheduled to take place between December 2012 to February 2013. The lab manual provides details of each experiment such as its aim, algorithm, source code, and expected output.
forwarder.java.txt java forwarder class waits for an in.docxbudbarber38650
forwarder.java.txt
// java forwarder class
// waits for an inbound connection A on port INPORT
// when it is received, it launches a connection B to <OUTHOST,OUTPORT>
// and creates threads to read-B-write-A and read-A-write-B.
import java.net.*;
import java.io.*;
import java.util.*;
import java.text.*;
class forwarder {
public static String OUTHOST;
public static InetAddress OUTDEST;
public static short OUTPORT = 22;
public static short INPORT = 2345;
public static boolean DEBUG = true;
public static void main(String[] v) {
// get command-line parameters
if (v.length < 3) {
System.err.println("args: inport outhost outport");
return;
}
INPORT = (short)(new Integer(v[0])).intValue();
OUTHOST = v[1];
OUTPORT = (short)(new Integer(v[2])).intValue();
// DNS lookup, done just once!
System.err.print("Looking up address of " + OUTHOST + "...");
try {
OUTDEST = InetAddress.getByName(OUTHOST);
}
catch (UnknownHostException uhe) {
System.err.println("unknown host: " + OUTHOST);
return;
}
System.err.println(" got it!");
// initialize LISTENER socket
// wait for connection
ServerSocket ss = null;
ss = new ServerSocket(INPORT);// needs try-catch
Socket s1;
while(true) { // accept loop
s1 = ss.accept();// needs try-catch
// now set up the second connection from here to <OUTDEST,OUTPORT>,
// represented by a second socket s2
// Then create the two Copier instances, as described in the
// project description, and start() the two threads.
// At that point, this main loop simply continues
// by going back to the ss.accept() call.
} // accept loop
}// main
/**
* The Copier class handles unidirectional copying from one socket to another.
* You will need to create two of these in the main loop above,
* one for each direction. You create the Copier object, and then
* create and start a Thread object that runs that Copier.
* If c is your Copier instance (created with Copier c = new Copier(sock1, sock2)),
* then the thread is Thread t = new Thread(c), and you start the thread
* with t.start(). Or, in one step, (new Thread(c)).start()
*/
static class Copier implements Runnable {
private Socket _from;
private Socket _to;
public Copier (Socket from, Socket to) {
_from = from;
_to = to;
}
public void run() {
InputStream fis;
OutputStream tos;
try {
fis = _from.getInputStream();
tos = _to.getOutputStream();
} catch (IOException ioe) {
System.err.println("can't get IO streams from sockets");
return;
}
byte[] buf = new byte[2048];
int readsize;
while (true) {
try {
readsize = fis.read(buf);
} catch (IOException ioe) {
break;
}
if (readsize <= 0) break;
try {
tos.write(buf, 0, readsize);
} catch (IOException ioe) {
break;
}
}
// these should be safe close() calls!!
try {
fis.close();
tos.close();
_from.close();
_to.close();
} catch (IOException ioe) {
Syst.
1. The document discusses software testing and provides definitions, objectives, and types of testing. It defines testing as analyzing software to detect bugs and differences from requirements.
2. The primary objectives of testing are to design tests that systematically uncover errors with minimal time and effort. Exhaustive testing all possible inputs is not possible due to the large number of combinations.
3. White box testing uses the internal logic and structure of code to design test cases that execute all independent paths, loops, and internal data structures to ensure validity. It helps optimize code but does not ensure requirements are fulfilled and requires a skilled tester.
1. The document discusses key concepts in software design including transforming customer requirements into an implementable form, designing modules, control relationships, interfaces, data structures, and algorithms.
2. It also covers preliminary and detailed design phases, where preliminary design identifies modules and relationships, and detailed design specifies data structures and algorithms.
3. Design principles like abstraction, refinement, modularity, architecture, control hierarchy, and information hiding are explained as important concepts for creating a complete design model.
This document discusses requirement analysis in software engineering. It defines requirements as descriptions of a system's services and constraints. Requirement engineering is the process of finding, analyzing, documenting, and checking requirements. User requirements describe desired system functions and constraints in natural language for non-technical users. System requirements provide more technical details of how the system will implement the user requirements and are used by software engineers. Requirements can be functional, specifying system services, or non-functional, specifying constraints like performance or reliability.
The document provides an overview of software engineering concepts including:
1) It defines software and discusses its evolutionary role as both a product and vehicle.
2) It describes different categories of software applications such as system software, real-time software, business software, and more.
3) It discusses software engineering goals, related disciplines, and key terms such as project size factors, quality and productivity factors, and managerial issues.
This document contains a 50 question quiz on data structures. The questions cover topics like linked lists, stacks, queues, trees, sorting algorithms, hashing and more. For each question there are 4 multiple choice answers and the correct answer is indicated. The quiz is assessing understanding of fundamental data structure concepts and their applications.
The document provides information about a presentation on Fourier series given by the Mathematics Department. It introduces Fourier and his work developing Fourier series. Fourier series can be used to represent any periodic function as an infinite sum of sines and cosines. The document discusses key aspects of Fourier series including periodic functions, the Euler formula, even and odd functions, and half-range series. It provides examples of calculating Fourier coefficients and representing even and odd functions with cosine and sine waves respectively. In summary, the document outlines the basics of Fourier series, their applications, and methods for analyzing periodic functions with them.
This document provides an overview of e-commerce and discusses various topics related to e-commerce including:
- The history and generations of computers.
- Electronic commerce frameworks and applications such as supply chain management, e-markets, electronic data interchange, and internet commerce.
- Infrastructure components that support e-commerce such as multimedia content, storage servers, client-server architecture, and information delivery.
- E-commerce applications in different industries such as retail, manufacturing, and how it is changing business environments and processes.
The document discusses various input devices used in computer systems including keyboards, mice, joysticks, touch screens, scanners, microphones, and digital cameras. It provides details on the components and functioning of keyboards and mice. Keyboards have alphanumeric keys, function keys, and cursor keys. Mice can be mechanical or optical and are used to control cursor movement and selection on a screen. Other pointing devices mentioned include trackballs, touchpads, and styluses.
The document provides a subject distribution chart for the Computer Science department at Shri Rawatpura Sarkar Institute of Technology-II, New Raipur. It lists 10 faculty members, their assigned subjects for teaching 4th, 6th and 8th semesters, and any labs or subjects taught in other departments. The chart also includes the workload for each faculty ranging from 17 to 24 credits.
The document contains revision reports from the Computer Science department of Shri Rawatpura Sarkar Institute of Technology-II, New Raipur. It lists the faculty members who conducted revisions for subjects in the 3rd and 5th semester, along with the number of students, date, and a remark that they discussed doubts and important questions from question papers. The note at the end states that student feedback on the revisions was positive and syllabus summaries were also distributed.
This document outlines the lecture plan for the subject "MIS" over 5 units and 46 lectures. The topics to be covered include management and organizational support systems for digital firms, information systems and business strategy, information systems in the enterprise, information technology for competitive advantage, and e-commerce and international information systems. Some specific topics are definition of MIS, report writing software, strategic information systems, executive information systems, firm environment, benefits of information resources, e-commerce strategy, and global information systems architecture. The plan is designed by Vivek Kumar Sinha, Assistant Professor of CSE, for the 6th semester students of CSE at Shri Rawatpura Sarkar Institute of Technology in New Raipur.
This document outlines a lecture plan for a subject on Data Warehousing and Mining (DMW). The plan covers 5 units over 46 lectures and 12 tutorials. Unit I introduces concepts of data warehousing and covers topics like requirements gathering, architecture, and infrastructure. Unit II focuses on data design, modeling, extraction, transformation, and loading of data. Unit III discusses information access, delivery, OLAP, and deployment. Unit IV introduces data mining algorithms, techniques, and applications. The final unit covers advanced topics in web mining, visualization, statistical analysis, and trends in data mining.
The document contains 3 sections detailing department planning milestones at Shri Rawatpura Sarkar Institue of Technology-II in New Raipur, India. Each section lists the faculty teaching various computer science subjects, and their grading on timely delivery and effective delivery of power point presentations for different phases and units. Faculty are assigned to teach subjects like MIS, OOPS, DS, CG, OS, ERP, SEPM, and more. Their performance is reviewed on a scale of 1-8 for timely and effective delivery of presentations on scheduled dates.
The document summarizes a presentation given by Mr. Vivek Sinha and Ms. Shraddha Yadaw to the Department of Computer Science and Engineering at SHRI RAWATPURA SARKAR INSTITUTE OF TECHNOLOGY-II, NEW RAIPUR on 10/23/17. The presentation covered basics of networks, types of networks including LAN, MAN, WAN, PAN and CAN, network topologies, communication tasks, client/server models, benefits of computer networks, and applications of networks such as email, e-commerce, video conferencing and more.
This course will cover the practical aspects of network programming, with emphasis on the Internet. The goal of this course is to introduce the students to the basics of networks programming. We will introduce the students to the TCP/IP protocol stack and some of its important protocols. Students will also be introduced to multi-tier application development and RPC technologies including: RMI, CORBA, EJB, and Web Services.
The document outlines a presentation on the Internet of Things (IoT). It defines IoT as connecting physical objects to the internet, allowing them to interact. The presentation covers the conceptual framework of IoT, how it works by combining physical objects, controllers, sensors and actuators. It also discusses challenges around enabling unauthorized access, security risks, and ensuring privacy as IoT is implemented.
The document describes Shri Rawatpura Sarkar Group of Institutions, a group of engineering colleges in central India founded by Anant Shri Vibhushit Shri Ravi Shankar Ji Maharaj. The mission is to pursue excellence in education, learning, and research. It provides glimpses of departments including applied sciences, civil engineering, mechanical engineering, computer science, electrical engineering, and electronics. It also describes campus facilities like the library, WiFi, buses, cultural events, yoga classes, and clubs to develop students' skills.
The Brayton cycle describes the workings of a constant-pressure heat engine and models modern gas turbine engines. It involves isentropic compression of air in a compressor, isobaric heat addition in a combustor, isentropic expansion in a turbine, and isobaric heat rejection. Materials used include superalloys for the compressor and turbine due to high temperatures and stresses, and refractory metals and ceramics for the combustor. The ideal Brayton cycle is analyzed using pressure-volume and temperature-entropy diagrams. Applications include jet engines and gas turbine power generation due to advantages like high power-to-weight ratio.
buy a fake University of London diploma supplementGlethDanold
Website: https://www.fakediplomamaker.shop/
Email: diplomaorder2003@gmail.com
Telegram: @fakeidiploma
skype: diplomaorder2003@gmail.com
wechat: jasonwilliam2003
buy bachelor degree from https://www.fakediplomamaker.shop/ to be competitive. Even if you are not already working and you havve just started to explore employment opportunities buy UK degree, buy masters degree from USA, buy bachelor degree from Australia, fake Canadian diploma where to buy diploma in Canada, It's still a great idea to purchase your degree and get a head start in your career. While many of the people your age will enlist in traditional programs and spend years learning you could accumulate valuable working experience. By the time they graduate you will have already solidified a respectable resume boasting both qualification and experience.
Manufacturing is the process of converting raw materials into finished goods through various production methods. Historically, manufacturing occurred on a small scale through apprenticeships or putting-out systems, but the Industrial Revolution led to large-scale manufacturing using machines powered by steam engines
Numerical comaprison of various order explicit runge kutta methods with matla...DrAzizulHasan1
Numerical analysis is the area of mathematics and computer science that creates, analyzes andimplements numerical methods for solving numerically the problems of continuous mathematics. Such problems originates from real-world applications of algebra, geometry and calculus and they involve variables that vary continuously, such problems occur throughout the natural sciences, social science, engineering, medicine.
Reciprocating Air Compressor and its TypesAtif Razi
Air Compressors
Classification of Air Compressors
Reciprocating Air Compressor
Main Parts of Reciprocating Air Compressor
Working of Reciprocating Air Compressor
Types of Reciprocating Air Compressor
Applications of Reciprocating Air Compressor
Advantages & Disadvantages of Reciprocating Air Compressor
Thermodynamics and Heat Transfer - KRCE.pptxkrceseo
Thermodynamics and Heat transfer are fundamental to mechanical engineering. These principles guide the design, analysis, and optimization of various systems.
Good Energy Haus: PHN Presents Building Electrification, A Passive House Symp...TE Studio
Tim Eian's contribution to the Passive House Network's Building Electrification Symposium on July 25, 2024.
Topics covered:
- Our Motivation to Electrify
- The Context of the Project
- The Process of Electrification
- Considerations for Electrification
- Data
- Challenges of Electrification
- Successes
- Opportunities
A Case of Unrecognized Peripartum Cardiomyopathy Which Was Noticed During Eme...CrimsonPublishers-SBB
Peripartum cardiomyopathy (PPCMP) is a kind of dilated cardiomyopathy seen between the last week of gestation and the postpartum 5th
month. PPCMP may be a cause of mortality for the mother and the infant. PPCMP is associated with black race, multi parity, maternal age above 30
years, multiple pregnancy, preeclampsia, eclampsia, family history, obesity, smoking, diabetes mellitus, and hypertension, but the underlying cause is
not clear [1]. In this case report, we present the diagnosis of peripartum cardiomyopathy, anesthetic management, and postoperative intensive care
period in a patient who developed pulmonary edema during emergency cesarean operation. We aimed to underline that per partum cardiomyopathy
should be remembered among the presumed diagnoses in case of acute pulmonary edema.
Computer Vision and GenAI for Geoscientists.pptxYohanes Nuwara
Presentation in a webinar hosted by Petroleum Engineers Association (PEA) in 28 July 2023. The topic of the webinar is computer vision for petroleum geoscience.
1. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
EXPERIMENT NO. 01
Aim: Networking Security Programming with TCP/IP for Application layer, Transport
layer, Network layer, Datalink layer protocols.
Program:-
import java.io.*;
public class
{
public static void main(String args[])
{
int sd[MAX_SOCKS];
/* one per TCP/IPv6, UDP/IPv6, TCP/IP, UDP/IP */
char *port, *addr = NULL;
struct addrinfo *res, hints;
port = argv[1];
/* port number as a string – must not be NULL */
if(argc == 3) addr = argv[2];
/* hostname – NULL implies ANY address */
memset(&hints, '0', sizeof(hints));
hints.ai_flags = AI_PASSIVE;
/* if usrreq.addr NULL, sets sockaddr to ANY */
err = getaddrinfo(usrreq.addr, usrreq.port, &hints, &res);
if(err) { if(err == EAI_SYSTEM) perror("getaddrinfo");
else printf("getaddrinfo error %d - %s", err, gai_strerror(err)); return 1;
}
i = 0;
for(aip = res; aip; aip = aip->ai_next)
{
if(aip->ai_family != AF_INET && aip->ai_family != AF_INET6) continue;
/* create a socket for this protocol */
sd[i] = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if(sd[i] < 0) {perror("socket");
return sd[i];
}
err = socket_options(sd[i], aip); /* set SO_REUSEADDR, SO_REUSPORT
etc. */
if(err == -1) {perror("socket_options");
return 1;
}
err = bind(sd[i], res->ai_addr, res->ai_addrlen);
if(err == -1) {perror("bind"); return 1;
} /** perform other per-socket work here – e.g. maybe create threads etc **/
if(i == NUM_ELT(sd)) {printf("Insufficient socket elementsn");
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
2. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
break;
}
i++;
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
3. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
EXPERIMENT NO. 02
Aim: Socket Security Programming for address structures, byte manipulation &
address conversion functions, elementary socket system calls.
Program:-
import java.net.*;
public class host
{
socket address structure:
sockaddr_instruct in_addr
{
in_addr_t s_addr; /* 32-bit IPv4 address */ /* network byte ordered */
};
struct sockaddr_in { uint8_t sin_len; /* length of structure (16) */
sa_family_t sin_family; /* AF_INET */
in_port_t sin_port; /* 16-bit TCP or UDP port number */ /* network byte ordered */
struct in_addr sin_addr; /* 32-bit IPv4 address */ /* network byte ordered */ char
sin_zero[8]; /* unused */
};
int main(int argc, char *argv[])
{
int sockfd, numbytes;
char buf[MAXDATASIZE];
struct addrinfo hints, *servinfo, *p;
int rv;
char s[INET6_ADDRSTRLEN];
if (argc != 2) {
fprintf(stderr,"usage: client hostnamen");
exit(1);
}
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
4. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
hints.ai_socktype = SOCK_STREAM;
if ((rv = getaddrinfo(argv[1], PORT, &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %sn", gai_strerror(rv));
return 1;
}
// loop through all the results and connect to the first we can
for(p = servinfo; p != NULL; p = p->ai_next) {
if ((sockfd = socket(p->ai_family, p->ai_socktype,
p->ai_protocol)) == -1) {
perror("client: socket");
continue;
}
if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
close(sockfd);
perror("client: connect");
continue;
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
5. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
EXPERIMENT NO. 03
Aim: APIs security Programming for windows socket API, window socket & blocking
I/O model, blocking sockets, blocking functions, timeouts for blocking I/O.
Program:-
import java.net.*;
public class test
{
public static void main(String args[])
{
// Create a non-blocking socket and check for connections
try {
// Create a non-blocking socket channel on port 8080
SocketChannel sChannel = createSocketChannel("www.xxx", 8080);
// Before the socket is usable, the connection must be completed
// by calling finishConnect(), which is non-blocking
while (!sChannel.finishConnect()) {
// Do something else
System.out.println("wonderful");
}
// Socket channel is now ready to use
}
catch (IOException e) {
}
}
// Creates a non-blocking socket channel for the specified host name and port.
// connect() is called on the new channel before it is returned.
public static SocketChannel createSocketChannel(String hostName, int port) throws
IOException
{
// Create a non-blocking socket channel
SocketChannel sChannel = SocketChannel.open();
sChannel.configureBlocking(false);
// Send a connection request to the server; this method is non-blocking
sChannel.connect(new InetSocketAddress(hostName, port));
return sChannel;
}
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
6. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
7. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
EXPERIMENT NO. 04
Aim: Web Security Programming for firewall and others.
Program:-
import java.net.*;
import java.io.*;
public class
{
public static void main(String args[])
{
try
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
ServerSocket ss=new ServerSocket(2345);
Socket skt=ss.accept( );
BufferedReader skt_in=new BufferedReader(new
InputStreamReader(skt.getInputStream( )));
PrintStream skt_out=new PrintStream(skt.getOutputStream( ));
while(true)
{
System.out.println(skt_in.readLine( ));
skt_out.println(“What is your name”);
yourname=skt_in.readLine( );
System.out.println(yourname);
String s=skt_in.readLine( );
System.out.println(s);
String myname=br.readLine( );
skt_out.println(myname);
break;
}
while(true)
{
String recv=skt_in.readLine( );
System.out.println(yourname+”:”+recv);
String send=br.readLine( );
skt_out.println(send);
}
}
catch(Exception e)
{
System.out.println(“Exception :”+e);
} }
import java.net.*;
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
8. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
import java.io.*;
public class ChatClient
{
public static void main(String args[])
{
try
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
Socket skt=new Socket(“rungtaibm”,2345);
BufferedReader skt_in=new BufferedReader(new
InputStreamReader(skt.getInputStream( )));
PrintStream skt_out=new PrintStream(skt.getOutputStream( ));
while(true)
{
skt_out.println(“hello can I connect”);
skt_out.println(skt_in.readLine( ));
String myname=br.readLine( );
skt_out.println(myname);
skt_out.println(“What is yours”);
String yourname=skt_in.readLine( );
System.out.println(yourname);
break;
}
while(true)
{
String send=br.readLine( );
skt_out.println(send);
String recv=skt_in.readLine( );
System.out.println(yourname +”:”+recv);
}
}
catch(Exception e)
{
System.out.println(“Exception :”+e);
}
}
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
9. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
EXPERIMENT NO. 05
Aim: Component Security Programming for CORBA.
Program:-
package cs652.corba.server;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
public class HelloWorldServer {
public static void main(String[] args) {
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get reference to rootpoa & activate the POAManager
POA rootpoa =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
// create servant and get the CORBA reference of it
HelloWorldServiceImpl helloWorldImpl = new HelloWorldServiceImpl();
org.omg.CORBA.Object ref =
rootpoa.servant_to_reference(helloWorldImpl);
HelloWorldService helloWorldService =
HelloWorldServiceHelper.narrow(ref);
// get the root naming context and narrow it to the NamingContextExt object
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// bind the Object Reference in Naming
NameComponent path[] = ncRef.to_name("HelloWorldService");
ncRef.rebind(path, helloWorldService);
// wait for invocations from clients
orb.run();
} catch (Exception e) {}
}
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
10. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
EXPERIMENT NO. 06
Aim: Programming for Cryptography and Digital Signature.
Program:-
PublicKeyCryptography
import java.security.*;
import java.security.cert.*;
import javax.crypto.*;
import sun.misc.BASE64Encoder;
import sun.misc.BASE64Decoder;
public class PublicKeyCryptography {
public static void main(String[] args) {
SymmetricEncrypt encryptUtil = new SymmetricEncrypt();
String strDataToEncrypt = "Hello World";
byte[] byteDataToTransmit = strDataToEncrypt.getBytes();
// Generating a SecretKey for Symmetric Encryption
SecretKey senderSecretKey = SymmetricEncrypt.getSecret();
//1. Encrypt the data using a Symmetric Key
byte[] byteCipherText =
encryptUtil.encryptData(byteDataToTransmit,senderSecretKey,"AES");
String strCipherText = new BASE64Encoder().encode(byteCipherText);
//2. Encrypt the Symmetric key using the Receivers public key
try{
// 2.1 Specify the Keystore where the Receivers certificate has been
imported
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
char [] password = "testpwd".toCharArray();
java.io.FileInputStream fis = new
java.io.FileInputStream("/home/Joebi/workspace/OWASP_Crypto/org/owasp/crypto/test
keystore.ks");
ks.load(fis, password);
fis.close();
// 2.2 Creating an X509 Certificate of the Receiver
X509Certificate recvcert ;
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
11. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
MessageDigest md = MessageDigest.getInstance("MD5");
recvcert = (X509Certificate)ks.getCertificate("testrecv");
// 2.3 Getting the Receivers public Key from the Certificate
PublicKey pubKeyReceiver = recvcert.getPublicKey();
// 2.4 Encrypting the SecretKey with the Receivers public Key
byte[] byteEncryptWithPublicKey =
encryptUtil.encryptData(senderSecretKey.getEncoded(),pubKeyReceiver,"RSA/ECB/PK
CS1Padding");
String strSenbyteEncryptWithPublicKey = new
BASE64Encoder().encode(byteEncryptWithPublicKey);
// 3. Create a Message Digest of the Data to be transmitted
md.update(byteDataToTransmit);
byte byteMDofDataToTransmit[] = md.digest();
String strMDofDataToTransmit = new String();
for (int i = 0; i < byteMDofDataToTransmit.length; i++){
strMDofDataToTransmit = strMDofDataToTransmit +
Integer.toHexString((int)byteMDofDataToTransmit[i] & 0xFF) ;
}
// 3.1 Message to be Signed = Encrypted Secret Key + MAC of the data to be
transmitted
String strMsgToSign = strSenbyteEncryptWithPublicKey + "|" +
strMDofDataToTransmit;
// 4. Sign the message
// 4.1 Get the private key of the Sender from the keystore by providing the password
set for the private key while creating the keys using keytool
char[] keypassword = "send123".toCharArray();
Key myKey = ks.getKey("testsender", keypassword);
PrivateKey myPrivateKey = (PrivateKey)myKey;
// 4.2 Sign the message
Signature mySign = Signature.getInstance("MD5withRSA");
mySign.initSign(myPrivateKey);
mySign.update(strMsgToSign.getBytes());
byte[] byteSignedData = mySign.sign();
// 5. The Values byteSignedData (the signature) and strMsgToSign (the data
which was signed) can be sent across to the receiver
// 6.Validate the Signature
// 6.1 Extracting the Senders public Key from his certificate
X509Certificate sendercert ;
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
12. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
sendercert = (X509Certificate)ks.getCertificate("testsender");
PublicKey pubKeySender = sendercert.getPublicKey();
// 6.2 Verifying the Signature
Signature myVerifySign = Signature.getInstance("MD5withRSA");
myVerifySign.initVerify(pubKeySender);
myVerifySign.update(strMsgToSign.getBytes());
boolean verifySign = myVerifySign.verify(byteSignedData);
if (verifySign == false)
{
System.out.println(" Error in validating Signature ");
}
else
System.out.println(" Successfully validated Signature ");
// 7. Decrypt the message using Recv private Key to get the Symmetric Key
char[] recvpassword = "recv123".toCharArray();
Key recvKey = ks.getKey("testrecv", recvpassword);
PrivateKey recvPrivateKey = (PrivateKey)recvKey;
// Parsing the MessageDigest and the encrypted value
String strRecvSignedData = new String (byteSignedData);
String[] strRecvSignedDataArray = new String [10];
strRecvSignedDataArray = strMsgToSign.split("|");
int intindexofsep = strMsgToSign.indexOf("|");
String strEncryptWithPublicKey = strMsgToSign.substring(0,intindexofsep);
String strHashOfData = strMsgToSign.substring(intindexofsep+1);
// Decrypting to get the symmetric key
byte[] bytestrEncryptWithPublicKey = new
BASE64Decoder().decodeBuffer(strEncryptWithPublicKey);
byte[] byteDecryptWithPrivateKey =
encryptUtil.decryptData(byteEncryptWithPublicKey,recvPrivateKey,"RSA/ECB/PKCS1
Padding");
// 8. Decrypt the data using the Symmetric Key
javax.crypto.spec.SecretKeySpec secretKeySpecDecrypted = new
javax.crypto.spec.SecretKeySpec(byteDecryptWithPrivateKey,"AES");
byte[] byteDecryptText =
encryptUtil.decryptData(byteCipherText,secretKeySpecDecrypted,"AES");
String strDecryptedText = new String(byteDecryptText);
System.out.println(" Decrypted data is " +strDecryptedText);
// 9. Compute MessageDigest of data + Signed message
MessageDigest recvmd = MessageDigest.getInstance("MD5");
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
13. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
recvmd.update(byteDecryptText);
byte byteHashOfRecvSignedData[] = recvmd.digest();
String strHashOfRecvSignedData = new String();
for (int i = 0; i < byteHashOfRecvSignedData.length; i++){
strHashOfRecvSignedData = strHashOfRecvSignedData +
Integer.toHexString((int)byteHashOfRecvSignedData[i] & 0xFF) ;
}
// 10. Validate if the Message Digest of the Decrypted Text matches the
Message Digest of the Original Message
if (!strHashOfRecvSignedData.equals(strHashOfData))
{
System.out.println(" Message has been tampered ");
}
}
catch(Exception exp)
{
System.out.println(" Exception caught " + exp);
exp.printStackTrace()
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
14. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
EXPERIMENT NO. 07
Aim : Java network Security programming.
Program:-
SymmetricEncrypt
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.Cipher;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
import java.security.InvalidAlgorithmParameterException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import sun.misc.BASE64Encoder;
public class SymmetricEncrypt {
String strDataToEncrypt = new String();
String strCipherText = new String();
String strDecryptedText = new String();
static KeyGenerator keyGen;
private static String strHexVal = "0123456789abcdef";
public static SecretKey getSecret(){
try{
keyGen = KeyGenerator.getInstance("AES");
keyGen.init(128);
}
catch(Exception exp)
{
System.out.println(" Exception inside constructor "
+exp);
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
15. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
SecretKey secretKey = keyGen.generateKey();
return secretKey;
}
/**
* Step2. Create a Cipher by specifying the following parameters
* a. Algorithm name - here it is AES
*/
public byte[] encryptData(byte[] byteDataToEncrypt, Key secretKey,
String Algorithm) {
byte[] byteCipherText = new byte[200];
try {
Cipher aesCipher = Cipher.getInstance(Algorithm);
/**
* Step 3. Initialize the Cipher for Encryption
*/
if(Algorithm.equals("AES")){
aesCipher.init(Cipher.ENCRYPT_MODE,secretKey,aesCipher.getParameters());
}
else
if(Algorithm.equals("RSA/ECB/PKCS1Padding")){
aesCipher.init(Cipher.ENCRYPT_MODE,secretKey);
}
byteCipherText = aesCipher.doFinal(byteDataToEncrypt);
strCipherText = new BASE64Encoder().encode(byteCipherText);
}
catch (NoSuchAlgorithmException noSuchAlgo)
{
System.out.println(" No Such Algorithm exists " +
noSuchAlgo);
}
catch (NoSuchPaddingException noSuchPad)
{
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
17. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
aesCipher.init(Cipher.DECRYPT_MODE,secretKey);
}
byteDecryptedText = aesCipher.doFinal(byteCipherText);
strDecryptedText = new String(byteDecryptedText);
}
catch (NoSuchAlgorithmException noSuchAlgo)
{
System.out.println(" No Such Algorithm exists " +
noSuchAlgo);
}
catch (NoSuchPaddingException noSuchPad)
{
System.out.println(" No Such Padding exists " +
noSuchPad);
}
catch (InvalidKeyException invalidKey)
{
System.out.println(" Invalid Key " +
invalidKey);
invalidKey.printStackTrace();
}
catch (BadPaddingException badPadding)
{
System.out.println(" Bad Padding " +
badPadding);
badPadding.printStackTrace();
}
catch (IllegalBlockSizeException illegalBlockSize)
{
System.out.println(" Illegal Block Size "
+ illegalBlockSize);
illegalBlockSize.printStackTrace();
}
catch (InvalidAlgorithmParameterException
invalidParam)
{
System.out.println(" Invalid Parameter "
+ invalidParam);
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
18. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
return byteDecryptedText;
}
public static byte[] convertStringToByteArray(String strInput) {
strInput = strInput.toLowerCase();
byte[] byteConverted = new byte[(strInput.length() + 1) / 2];
int j = 0;
int interimVal;
int nibble = -1;
for (int i = 0; i < strInput.length(); ++i) {
interimVal =
strHexVal.indexOf(strInput.charAt(i));
if (interimVal >= 0) {
if (nibble < 0) {
nibble = interimVal;
} else {
byteConverted[j++] = (byte)
((nibble << 4) + interimVal);
nibble = -1;
}
}
}
if (nibble >= 0) {
byteConverted[j++] = (byte) (nibble << 4);
}
if (j < byteConverted.length) {
byte[] byteTemp = new byte[j];
System.arraycopy(byteConverted, 0, byteTemp, 0,
j);
byteConverted = byteTemp;
}
return byteConverted;
}
public static String convertByteArrayToString(byte[] block) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < block.length; ++i) {
buf.append(strHexVal.charAt((block[i] >>> 4) &
0xf));
buf.append(strHexVal.charAt(block[i] & 0xf));
}
return buf.toString();
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
19. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
EXPERIMENT NO. 08
Aim: Client Server Security Connection programming.
Program:-
class Main
{
public static void main(String[] args) {
new TCPServer().start();
new TCPClient().start();
}
}
class TCPClient extends Thread {
// Connection properties
private static final String HOST = "127.0.0.1";
private static final int PORT = 56565;
public void run() {
// Socket class used for TCP connections
Socket sock = null;
// I/O components
BufferedReader input = null;
BufferedWriter output = null;
try {
// Connect our socket to the server.
sock = new Socket(HOST, PORT);
// Use a BufferedReader to read data from the server.
input = new BufferedReader(new InputStreamReader(sock.getInputStream()));
// Use a BufferedWriter to send data to the server.
output = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
// Send some data to the server.
String toServer = "Are you there, Server?";
System.out.println("ToServer: " + toServer);
output.write(toServer);
output.newLine();
output.flush();
// Wait for a response from the server and display it.
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
20. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
String fromServer = input.readLine();
System.out.println("FromServer: " + fromServer);
} catch (final IOException ex) {
} finally {
// Do our best to ensure a clean close procedure.
// Closing the socket will also close input and output.
try {
if (sock != null) {
sock.close();
}
} catch (final IOException ex) {
}
}
}
}
class TCPServer extends Thread {
// Connection properties
private static final int PORT = 56565;
public void run() {
// ServerSocket class used to accept TCP connections
ServerSocket server = null;
Socket sock = null;
// I/O components
BufferedReader input = null;
BufferedWriter output = null;
try {
// Create our server on the given port.
server = new ServerSocket(PORT);
// Wait for a client to connect to us.
sock = server.accept();
// Use a BufferedReader to read data from the client.
input = new BufferedReader(new InputStreamReader(sock.getInputStream()));
// Use a BufferedWriter to send data to the client.
output = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
// Wait for the client to talk to us.
String fromClient = input.readLine();
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha
21. Shri Rawatpura Sarkar Institute Of Technology-II, New Raipur
System.out.println("FromClient: " + fromClient);
// Send them a response.
String toClient = "Yes, I'm here, Client.";
System.out.println("ToClient: " + toClient);
output.write(toClient);
output.newLine();
output.flush();
} catch (final IOException ex) {
} finally {
// Do our best to ensure a clean close procedure.
// Closing the socket will also close input and output.
try {
if (sock != null) {
sock.close();
}
} catch (final IOException ex) {
}
// Close the server socket, as well.
try {
if (server != null) {
server.close();
}
} catch (final IOException ex) {
}
}
}
}
CSE/SRIT/8th
/NS Lab/Prepared by Vivek Kumar Sinha