07 October 2012

Single precision floating point variable

Single-precision floating-point format is a computer number format that occupies 4 bytes (32 bits) in computer memory, known as float in C.

IEEE 754 is a technical standard for floating-point computation.


Converting from decimal to single-precision binary:
26.25

.25 x 2 = 0.50 -> 0
.50 x 2 = 1.00 -> 1

26.25 = 1A.25 = 0001 1010 . 01 = 1.101001 x 2^4

0 (127+4) 101001 = 0 (131) 101001
0 10000011 101001 = 0100 0001 1101 0010 = 0x41D20000

Converting from single-precision binary to decimal:
471BCF90 = 0100 0111 0001 1011 1100 1111 1001 0000

0 10001110 00110111100111110010000 = 0 (142-127) XYZ

1 . 00110111100111110010000 x 2^15 = 1001 1011 1100 1111 . 1001

1x2^-1 + 1x2^-4 =  .5 + .0625 = .5625

9BCF . 1001 = 39887 . 5625 = 39887.5625

Reference:
http://en.wikipedia.org/wiki/Single_precision
http://sandbox.mc.edu/~bennet/cs110/flt/dtof.html
http://www.exploringbinary.com/pi-and-e-in-binary/

05 October 2012

A script to check PNR status

# cat << EOF > pnrdata
lccp_pnrno1=MYPNRNO
EOF

# cat pnrdata
lccp_pnrno1=MYPNRNO

# url=http://www.indianrail.gov.in/cgi_bin/inet_pnrstat_cgi.cgi
# lynx -post_data $url < ./pnrdata | 
  grep -A32 PNR | grep "Passenger [0-9]"
   Passenger 1 W/L 114,GNWL W/L 21

wget --user-agent="Myscript 1.0;" \
--header="Content-Type: application/x-www-form-urlencoded" \
--post-data="lccp_pnrno1=MYPNRNO" \
"http://www.indianrail.gov.in/cgi_bin/inet_pnrstat_cgi.cgi" -O- 2>/dev/null \
| grep -A2 "Passenger 1"
<TD class="table_border_both"><B>Passenger 1</B></TD>
<TD class="table_border_both"><B>W/L  114,GNWL  </B></TD>
<TD class="table_border_both"><B>W/L   21</B></TD>


Reference:
http://wiki.linux-delhi.org/cgi-bin/twiki/view/Main/LinuxTricks
http://akhileshss.blogspot.com/2008/09/script-to-periodically-check-pnr-status.html

26 September 2012

wireless security a small peep

802.11i defines set of procedures (RSN) that tells how keys are derived and distributed.
802.11i provides sophisticated authentication using a variety of protocols (PSK, 802.1X) and strong security with the AES-CCMP encryption protocol.
WEP
--> uses RC4 encryption

WPA - draft of 802.11i (Home and small office)
TKIP
-> automatic key management (key mixing)
-> per-frame keying (key mixing)
-> sequence counter / 48bit IV (replay protection)
-> new message integrity check (Michael integrity check)
=> uses RC4 encryption

WPA2 - 802.11i - RSN (Home and small office)
CCMP - AES

RSN
The earlier EAP exchange or WPA2-PSK has provided the shared secret key PMK
PTK = PBKDF2-SHA1(PMK + ANonce + SNonce + AP MAC + STA MAC)


RSN packets
PEAP packets
WEP - Wired Equivalent Privacy
WPA - WiFi Protected Access
TKIP - Temporal Key Integrity Protocol
CCMP - Counter Mode with CBC-MAC Protocol

RSN - Robust Security Network
PMK - Pairwise Master Key
PTK - Pairwise Transient Key

PEAP