30 December 2011

CUDA at last

CUDA installed, on a recent attempt

- it does work, there's a nice Mandelbrot demo...
I'm interested in Big Integers. Its not clear how much CUDA speeds these up
NVIDIA GPUs have a bunch of floating point multipliers, not a natural fit for integer MUL with carry

Reports vary from "2X" to "order of magnitude" faster on factoring big integers
nvidia
NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\bin\win64\Release\bandwidthTest.exe Starting...
Running on...
Device 0: GeForce GT 525M
Quick Mode
Host to Device Bandwidth, 1 Device(s), Paged memory
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 2330.7
,,,
NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\bin\win64\Release\deviceQuery.exe Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Found 1 CUDA Capable device(s)
Device 0: "GeForce GT 525M"
CUDA Driver Version / Runtime Version 4.0 / 4.0
CUDA Capability Major/Minor version number: 2.1
Total amount of global memory: 962 MBytes (1008402432 bytes)
( 2) Multiprocessors x (48) CUDA Cores/MP: 96 CUDA Cores
GPU Clock Speed: 1.20 GHz
...
Obviously with just a laptop and a GT525M, I cant be serious about doing big Integer stuff at a competitive level
- but I'm just curious...

Way back, I wrote 386 Assembler code Miller-Rabin Prime tests and a bunch of functions
(Kuttaka.exe, it must be out there )

Occasionally I get a hankering to do big Integers once more

Computers are a million times faster now, they say

GMP is the famous bigInteger library now, buts uses gcc, anti-windows,
a bitch, Even if you go Linux dual boot, you just know that gcc is gonna throw some bunch of errors


a factoring program   YAFU    bbuhrow
- This apparently uses GMP but the exe runs ootb on Windows.
 nice functions like "nextprime"
factored an 80 digit decimal in 4 minutes (Quadratic sieve?)

I want to use my GPU, so I downloaded
msieve    from     gilchrist       this is "Jeff" who people on http://www.mersenneforum.org/ are often thanking

the cuda version
the win32 version worked (factored the 80 digit in 4 minutes)

18/06/2011 02:07 p.m. 870,912 msieve.exe

but the NVIDIA utility reported GPU activity 'none'

tried the big win64 version but got
"vcomp100.dll is missing" - some cuda 64/32 bit mismatch
- not fixed by reloading directX, nor by scattering vcomp100.dll or cudart.dll about

17/06/2011  09:23 p.m.         1,171,968 msieve.exe   CUDA confusion?

I may post a complaint on
mersenneforum
but as of now I dont have any idea if my GPU is active or effective

there is a Number-Field-Sieve implementation CGNFS (from Jeff)
- requires Python 2.6 which is worth having anyway.
I overwrote with the win32 version of msieve and tried the 80 digit using factMsieve.py
- it chugged away for half an hour? then crashed

At the moment I am trying CGNFS on their 100 digit example - hasnt crashed, is onto the sieve
- from the forum it seems its all about tweaking parameters

mpir
MPIR is a fork from GMP
MPIR may be Non-anti-windows and may even be faster
I havnt looked to see if has  a library for VC++

do I still have the level of obsession required ?...

It was oddly nostalgic to look up an article and realise I had tinkered with its algorithms
back in the 90s

MATHEMATICS OF COMPUTATION
VOLUME 53, NUMBER 187
JULY 1989, PAGES 411-414
A New Method for Producing Large Carmichael Numbers
By H. Dubner

08 December 2011

CUDA,OpenCL, NFC

CUDA

Spent Sunday attempting to get CUDA - somehow didnt install
- one page reckoned that CUDA gave only a 2x speedup below 4kbits
Then I tried to get GMP, despite it having no claim to use CUDA
- got tangled in the usual Linux gcc Crapola ... Linux prissy purists insist on handing you the "source" which you have to compile with gcc
but windows gcc is itself fraught with crapola and pils of anxious (outdated?) complaints about it all
..


So the free arena is Crapola, I need to buy mathematica? ...MatLab has nifty pages on CUDA .. but you have to register to see the price !? (Thousands"??

a Quote:
. I do not think SciLab and Octave are viable alternatives to MATLAB for me. I think Python is a viable alternative for me. There is not much that I can do in MATLAB that I cannot do in Python. There is no question that if I was just starting out I would use Python instead of MATLAB. MATLAB, however, is cheap for me compared to the cost of porting my existing code to Python.
http://www.scientific-computing.com/review1.html

Maybe the best way to get bigint/cuda might be to sign up with one of the global shared computation efforts, one assumes that they will download simply...



Meanwhile: notes on OpenCL (I cant determine if OponCL is a rival of CUDA, or an older obselescant device)

It just so happens that Radeon cards are quick with integer calculations so they were the perfect tool for the job increasing the hash rate by magnitudes of 100+. M
Radeon 5770 is not the fastest card around but packs way more punch than a traditional CPU. It also looks like Radeon cards are faster than their Nvidia counterparts especially when it comes to password brute forcing and the latest Radeon 6990 graphic card should be several times faster than my Radeon 5770 and should make ANY 8 character password obsolete.

he University of Georgia was experimenting with this last year.
gtri
They were able to gang GPU’s to achieve staggering results, even 12 character passwords are crackable in a sort amount of time.


Radeon HD 5970 can execute 3200 32-bit instructions per clock (using its 3200 ALUs or shaders


$350 for the HD5970
AMD Radeon HD 6990: 3072 ALUs x 830 MHz = 2550 billion 32-bit instruction per second


________________________________________________________________________________
OpenCL
compute4cash is using an open-source miner called Poclbm (
bitcoin

August 8, 2011, AMD released the OpenCL-driven AMD Accelerated Parallel Processing (APP) Software Development Kit (SDK) v2.5,


wikipedia


Dell Inspiron i% gas ATI Mobility Radeon HD 5470, Sadly I dont have this???
Mine has NVIDIA GeForce GT 525M - 1GB ???




intel opencl

intel



_______________________
NFC
...if you’re the pioneering (sic) type who likes to swap smartphone batteries in the field: The battery that comes with the stock Galaxy Nexus includes an NFC antenna inside of it (..like Android Beam, for instance). ..So unless you’re swapping that battery cell out for similar one, don’t expect to be waving your Google Wallet around anytime soon.
Wired
_____________________________________________
Google ... integrate Google Wallet into mobile web payments.
.....probably would not make sense yet..... with Fandango.com and MovieTickets.com to offer Google Wallet as a payment option for their mobile web checkout.
...users won't have to try to type their 16-digit credit card number plus the expiration date and security code on their phone.. Typing on mobile phones is a notorious hassle, and mobile Web users often abandon their online shopping carts when they reach the point of entering payment information.
[OK EMV NFC, we have the technology... we can read the CCNumber,ExpDate (but not the 3digit
...Card Security Code (CSC) ... Card Verification Value (CVV) or Card Verfication Code (CVC)]

.. also offer their own apps for iPhone, Android, ...
It's unclear whether Google Wallet will be offered as a payment option for in-app purchases -- but ..."if Google decided to offer this ability, it might "pull the rug out from underneath Apple's 30% tax on in-app purchases."
cnn





______________________________________________________
Auckland Transport's announcement calls the new card an "integrated smartcard," which is, as I've observed before, rather gilding the lily. The service is hardly all that smart, nor very integrated. It's just an electronic cash substitute that can deduct a fare from your card.
...A fully integrated system would include a zonal charging system where passengers were levied for the distance travelled regardless of changes of transport mode on the way.
Even when the new "integrated card" comes in, swapping from bus to train, for example, will incur a new fare.
In a letter to transport committee chairman Mike Lee in August, Mark Lambert, Auckland Transport's manager, public transport operations, outlined how the organisation planned to implement the "integrated public transport network" model over the next three or four years. He painted a four-tiered network of routes, the backbone being a rapid transit network of electrified rail and dedicated busways, interlinked with a secondary grid of bus services.
But absent in this three to four-year plan is any mention of a simplified fare system. One that doesn't punish the commuter for changing modes mid-journey. The new $87 million "integrated ticketing system" is capable [sic] of doing these calculations. When will it be asked to is the question.


nzherald
Auckland's much-hyped smartcard system hardly worthy of the name By Brian Rudman 5:30 AM Friday Nov 11, 2011

03 November 2011

ACR122U as Card Emulator

Emulator

Card Emulator project using ACR122 reader
documents used so far:
..................................................
Paper:
ISO/IEC fcd 14443-3 ISO/IEC JTC1/sc17 N 1531
ISO/IEC JTC 17N 1689 part 4 [1998-01-12] 2000-03-10
ID cicc Proximity Cards

Part 3 Initialization and Anti Collision
Part 4 Transmission protocol

and Inet:
waazaa
ISO/IEC JTC1/SC17 N 1531
waazaa ISO/IEC JTC 1/SC 17 N 1689Date: 2000-03-10Draft ISO/IEC FCD 14443-4 ISO/IEC JTC 1/SC 17/WG 8

..................................................
Inet:
nxp
UM0701-2 pn532 User Manual rev 02
And Paper from NXP
..................................................
Paper:
AN<10449_1> PN532 application note Rev <01.00) 07Dec 2006
 Not available on Inet? Password required Confidetnial Document: nxp
..................................................
Paper:
ACS Advanced CArd Systems Ltd
ACR122 NFC Contactless Smart Card Reader
and Inet:
ACR122


________________________________________________________________________
__________________________________________________________________________



aaa
________________________________________________________________________
__________________________________________________________________________

NAD Present
The apdu got by the emulator must have some bytes stripped off the front
In Python this looks like:

errorcode= int(emulator.data[4:6],16)
# "Error" 0x80 high bit means NAD present ie not an error see page 67
NADpresent = (errorcode & 0x80) != 0
errorcode = errorcode & 0x7F;
if NADpresent:
    apdu_in = emulator.data[8:]
else:
    apdu_in = emulator.data[6:]

20 October 2011

Pi

Pi
Seems that By Alexander J. Yee numberworld isnt using any NVIDIA processors, just Intel CPUs to calculate 10Trillion digits of Pi.

Hes using Intel 'Xeon 5680' which is a 6 core superior to the i7 (at $1600 it oughta be)
He says he hasnt done any work on CUDA
but "v0.5.5 is faster on processors with AVX instructions."

aaa


tomshardware

for some sexy motherboard pics:
pcguide


Meanwhile, If you merely want to run other-region DVDs, get VideoLAN software
Its grand that LapTops have HDMI sockets.
Who needs a TV set?     (except: "that 70's show" isnt on Demand...)
Not So grand that I dont have a "Home Theatre"

Of Course if you live in Sydney you can get "multi-region' DVD players... they arent allowed to advertise as such, but downtown Sydney had charming "Barkers" outside stores shouting "get your unlocked DVD playes here" (is this still true?)
great for those 20-title DVDs you picked up in PatPong

Intel i5 chip seems adequate, get an i7 if you like.

If you want heavy games, better get a tower with slots for NVIDIA cards.
Never been into games much, myself, same as Steve Jobs.



More Motherboard Porn:
theinquirer
"you may indeed have assembled the fastest/most powerful single-motherboard computer in history."
Note the liquid Nitrogen cooling. Youd want to be careful, ... N2 is a well known murder weapon - if the gas displaces the oxygen you may never wake up.
aaa


_____________________________________________________________________________
nb I have altered the translation of Leopold Kronecker's remark...
note that Integers are Positive Natural numbers, so it appears that God created negative numbers...

12 October 2011

CUDA, Supercomputing for the Masses:

CUDA, Supercomputing for the Masses:
Part 1 .... Part 21
(Dr Dobbs series... DDJ is one site thats worth registering .. they dont block safetymail.info...)
DDJ



NVidia Graphics cards , massively parallel, speed up calculations 10x-100x
Since 2007 NVIDIAs CUDA has brought super-computing to anyone with a game card...

"GeForce GT 220 packs 48 processing cores into a compact power efficient.."(< $80)   2009

 this year: NVIDIA® GeForce® GTX 550 Ti graphics processing unit (GPU) $150 "GPU called GF116,"
... Ti is a Fermi?? newegg

:The refreshed Fermi chip is large: it includes 512 stream processors, grouped in 16 stream multiprocessors clusters (each with 32 CUDA cores)," ??

The GF116 has a single Graphics Processing Cluster (GPC), with four Streaming Multiprocessors (SMs). Each SM contains 48 shader cores, four dispatch units, and eight texture units. All told, GF116 employs 192 shader cores, four Polymorph engines (one per SM), and 32 texture units.??

... and all three ROP partitions are fully functional.. similar to the uncut GF106 GPU in Nvidia's GeForce GTX 460M mobile graphics module. With each of the three ROP partitions capable of eight 32-bit integer pixels per clock, we have 24 ROPs and a cumulative 192-bit memory interface..
(24 * 32bits per clock doesnt sound all that grand .. maybe a "shader unit" can do a multiply?)


..............................................
ATI (AMD) Radeon HD 5770 features the exact core configuration of the Radeon HD 4870 and 4890: 800 SPUs, 40 TAUs (Texture Address Units) and 16 ROPs (Rasterization Operator Units).
might be better than NVIDIA, but as NVIDIA write CUDA , they might be more copasetic
"The Radeon HD 5770 features a remarkably low 18 watt idle consumption level, making it one of the most efficient graphics cards available today. When pushing the card to the extreme it will still suck up to 108 watts, but even with the increased thermal stress, noise levels were comparable to those of the Radeon HD 4770 or GeForce GTS 250 graphics cards."
...........................................
Jargon ROP Raster Operations Partition? ROP partition = ROPs + memory controllers + L2 cache .
...........................................
GeForce GTX 295 Each GPU features the full array of 240 processing cores and 80 texture filtering units. The processor cores and filtering units operate at 1242 MHz and 576 MHz respectively ($500? fits in one slot?)
There are GPU cards up to $700.




Either pay $$ for Mathematica 8 ..'Native support for Compute Unified Device Architecture (CUDA) and OpenCL GPU'
or write yr own.

Me, I'd like to set a couple of cards making Carmicheal numbers and seeing how many Miller-Rabin bases I can fox.
At 2048 bits, any more than 2 bases would be fun!



I'm assuming that GeForce work well on Integers. Surely better than AMD 8-core Bulldozers ($205-4245)
cnet


Since I dont do games, or huge monitors, most of the fun would be lost if I bought a DEsktop and a couple of GPU cards
...........................................................................................
Java
jcuda
JCublas is a library that makes it it possible to use CUBLAS, the NVIDIA CUDA implementation of the Basic Linear Algebra Subprograms, in Java applications.

JCublas provides methods for
Vector operations (Level 1 BLAS)
Matrix-Vector operations (Level 2 BLAS)
Matrix-Matrix operations (Level 3 BLAS)

- so no Integers??
I suppose that means dusting off JNI
nvidia

................................
Some Integer work in C: Jeet Chauhan Summer 2010 - a quick eyeball seems to show that Chauhan is NOT using BigInt, ie integers < 2^32 - no fun!!! calstate

__________________________________________________________________
Jolt
More DDJ stuff...
winners of the 2011 Jolt Awards for books, the winner of the top prize,
 Continuous Delivery by Jez Humble and David Farley, was a run-away #1 choice
Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation (Addison-Wesley Signature Series (Fowler)) [Hardcover]Jez Humble (Author), David Farley (Author)

DDJ

Reliable Releases - this seems to be a lasting fashion, cant be bad..
(Jolt was (is?) a cola with "all of the sugar and twice the caffeine?)

10 October 2011

News

Bogota's brilliant Bus system .. seems to be using NFC ("HID")
1.7 million trips/day
treehugger
______________________________________________________
__________________________________________________
FIPS 201 ended up being operating system agnostic, though implementations have all been based on the Java Card OS. There were MULTOS-approved systems when FIPS 201 first came out but agencies have exclusively deployed Java Card, says Neville Pattinson, vice president of government affairs at Gemalto.
CAC/PIV
To date U.S. government agencies have issued more than 4.8 million credentials running the Java Card OS.
fips201

Army Knowledge Online AKO..Internet Explorer 6 ..Tools > Internet Options> Advanced Tab, scroll down to the Security section. check "Use TLS 1.0" ..
.. Mozilla Firefox, go to: Tools > Options > Advanced > Encryption..
Chrome TLS1.0 by default wrench, Options, "Under the Hood" Tab, Change proxy settings,
.."Advanced" Tab, Scoll down and check TLS 1.0
__________________________________
"What AKO tries to do is provide a layer of protection, so in addition to just using a password, you can supply answers to questions about yourself," he said. "Who was your first teacher, the first person you kissed' It'll be answers known only by you. ..
..one more layer of security that defeat keystroke loggers," ...

army
__________________________________________


Thales never sleeps

16 August 2011 Thales, ... announces the world’s first software for Hardware Security Modules (HSMs) that enables mobile payment issuers to deliver their mobile payment applications to mobile handsets Over-The-Air (OTA) in a simple, efficient and secure manner.
..
Today’s mobile payments issuers have to use multiple core cryptographic function calls to build the data needed to issue a payment application and to create the secure messages required to personalize the mobile phone with the application Over-The-Air (OTA)..
Thales HSMs now provide for the first time the ability to create a secure message to personalize a payment application hosted in a GlobalPlatform Secure Element, resident in a mobile phone using a single dedicated cryptographic HSM call...
thalesgroup
paymentssecurity
___________________________
Sydney U researches smart transport:
? Does Sydney have a BusCArd Yet? Is this report worth $25?
edu
_________________________________________________

Sydney Oyster/Opal 2014 $1B
Sydney's version of a universal public transport card .. will be called Opal...
The card will first be introduced on Sydney Ferries by December next year, she said.
.. following year it will be trains, the following year after that it will be buses  " ..
She said the system had been bought from and would be operated by the people behind London's Oyster card, and would cost just over $1E9. NSW Transport Minister Gladys Berejiklian says.
September 13, 2011 AP
smh
_________________________________________________
Vodafone Italia and CartaSi .. launch of the Vodafone Smart Pass, a pre-paid ... NFC... .. associated to mobile phone number .. CartaSi channels... and MasterCard.
_________________________________________________


Aug 16 2011
Motorola Gives Google Chance to Control More Secure Elements
Lower NFC Phone Shipments....
..offers Google a way to control the secure chips in more NFC phones.
Google needs ...control of the ..secure elements for its Google Wallet...trademarked .."SingleTap"
..no problem .. with the Nexus S 4G, ..so far the only phone model onboard for the wallet launch, expected next month in the US..
..ordered it with an embedded secure element from..NXP..
But for other Android phones, Google would have to make deals with handset makers or mobile operators to allow it to manage the wallet applications, ..
...willing to work with mobile operators to put the Google Wallet applications onto these SIMs, perhaps renting space on the cards from the telcos. But the Google Wallet would compete with the operators’ own wallets,..
.. Motorola, .. 11% of the U.S. smartphone market with its Android handsets and about 2% of the global phone market,.. Verizon..part of the Isis joint venture and wants to control all secure elements in the NFC phones it sells.
..Sprint, which is not part of Isis ..
nfctimes
____________________________
The Mobile Wallet Wars
mercatoradvisorygroup
____________________________
intel
.. Intel Advanced Vector Extensions Programming Reference (June 2011)... AVX2 (256-bit integer AVX instructions) and some VEX-encoded general-purpose instruction for bit manipulation et al.

'm assuming by an 8 core Bulldozer, they are actually really referring to a physical 4 core CPU that has 8 integer cores and 4 FPU cores. I think this terminology will trick a lot of people, because in reality, it is really only a quad processor that happens to have 2 integer units per core :). The extra cost of the extra integer unit per core was apparently very minimal, so cost wise the Bulldozer should be comparable to the Sandy-Bridge, just (supposedly) a lot faster! In addition to both having AVX instructions, the Bulldozer has the additional benefit of having what was once known as SSE5, but is now FMA4, CVT16 etc, although I'm not sure whether they will be beneficial for encoding.
popper

____________________________________

Some Skype distributions, like those available in China, have built-in back doors that make it possible for local officials to monitor communications.
____________________________________


nearfield
nearfield
viddler

nearfieldcommunicationsworld

MeeGo, the Linux-based open source operating system born from the February 2010 shotgun marriage of Nokia's Maemo and Intel's Moblin and left at the altar when Nokia hooked up with Windows Phone 7, is an "unstoppable force" that speeds device-developers' time-to-market, and it stands for "love, courage, and change."

That was the message delivered at the MeeGo Conference in San Francisco on Monday by the executive director of The Linux Foundation Jim Zemlin
_____________________________________________________________

conceivablytech

Japan’s Riken Advanced Institute.. ..fastest supercomputers.
The K Computer ....
..a peak 8.77 PFlop/s..sustained 8.2 PFlop/s
Peta = E15

..Tianhe-1.. November.. 4.7 PFlop/s, K does not use GPUs..It’s extremely difficult to exploit ..a GPU supercomputer.

K ... 68,544 2.0 GHz Fujitsu Sparc VIIIfx CPUs with 8 cores each, ..(548,352). Each core .. 16 (double-precision, DP) GFlop/s,.. slightly more than Intel.. Sandy Bridge..
45 nm chip .. 8 flop/clock/core.

8-core processor ...58 Watts.
currently 9.9 MWatts ..When finalized,... 10 PFlop/s ... 11 MWatts.
..human Brain .. 10 - 38 PFlop/s ... memory 3584 TB
we may be able to simulate a human brain next year or within 3 years. {i dont believe in this simulate a human at all}

03 October 2011

GlobalPlatform Card Key Id & Versions

GlobalPlatform Card  Key Id & Versions

1) select Card Manager     byte[] selectAPDU = Uti.asHex("00A4 0400 08 A000000003000000 ");
2) get data p2 = E0     APDU  "80 CA 00 E0 00"
this returns  E024C00401018010C00402018010C00403018010C00401038010C00402038010C00403038010
which we can unpack knowing tags E0 and C0 as
E024
  C004 01018010   id = 01 vers = 01 type = 80 (DES)  length = 10 (16 decimal)
  C004 02018010
  C004 03018010
  C004 01038010   version 03  I believe this is after me adding version 3 keys...
  C004 02038010
  C004 03038010

with tag C1 and CLA 00  get get data C1 <<<00BD>>>Sequence Counter of the default Key Version Number   ???
with tag C1 and CLA 80  C10200C5  which looks better    sequence counter (?) is C5 ???
This is said to be used to derive session keys??
In practice we use the 108100..00 derivation data, so when is this sequence counter used??
It is said that only SCP02 responds to C1,so there's a test for you...

Note the GetData CLA can be 00 or 80   80 is better.....
there is an undocumented CLA of FF which returns 2DB3BB28 irrespective of p2 .....
  seems to be uid String getUID = "FF CA 00 00 00";
------------------------------------
get data tag 66
664C
  734A
    0607 2A864886FC6B01
     600C 060A 2A864886FC6B 02     020101  211  ie GPCard Spec 2.1.1
     6309 0607 2A864886FC6B 03     IIN and CIN not seen here...
     640B 0609 2A864886FC6B 04 0215     scp 02  i 15 'implementation option'
     650B 0609 2B8510864864020103   GP does not say
     660C 060A 2B060104012A026E0102 GP does not say
   
     IIN tag 42 not seen here
     CIN tag 45 not seen here
     2A864886FC6B seems to be  {globalPlatform}
    12840114283 dec -> 2FD54986B Hex 
    {iso(1) member-body(2) country-USA(840) Global-Platform(114283)} 


    so do I decode these few items the 'hard' way 
    or do I find a library for ISO/IEC 7816-4 structure.
   (the 'difficult' way)
---------------------------------------------------------    



02 October 2011

CMAC for JCOP

CMAC
New version since Aug 2010 - everything works! thanks jcManager & braicu




        public static byte[] generateMAC_SCP02(byte[] iv, byte[] data) throws Exception {
                byte cMac[] = null;
if (data.length < 5)
                {
                    print("\n MAC data.length  < 5 \n");
                    return cMac;
                }
                int z = data[4] & 0xFF;
z = z + 8;
//padding
int dz = data.length+1;
while ((dz & 7)!=0) {
dz++;
}


byte[] dataWithPAD = new byte[dz];
int dsub = dz - 8;


System.arraycopy(data,     0, dataWithPAD,           0, data.length);
                dataWithPAD[data.length] = (byte)0x80;
dataWithPAD[4] = (byte)z;   //modify Lc with C-MAC length


SecretKeySpec desSingleKey = new SecretKeySpec(S_MAC_24,0, 8,"DES");
Cipher singleDesCipher = Cipher.getInstance("DES/CBC/NoPadding");
byte ivc[] = null;
IvParameterSpec ivSpec = new IvParameterSpec(iv);
                if (dsub > 0)                   // try as 1 op
                {
                    byte[] head = new byte [dsub];  // care dsub may = 0
                    System.arraycopy(dataWithPAD,0,head,0,dsub);
             singleDesCipher.init(Cipher.ENCRYPT_MODE, desSingleKey, ivSpec);
   ivc = singleDesCipher.doFinal(head); //Final<<<<<<<<<<<<
   ivSpec = new IvParameterSpec(ivc);
                }




SecretKeySpec desKey = new SecretKeySpec(S_MAC_24, "DESede");
Cipher cipher = Cipher.getInstance("DESede/CBC/NoPadding", "SunJCE");
cipher.init(Cipher.ENCRYPT_MODE, desKey, ivSpec);
cMac = cipher.doFinal(dataWithPAD, dsub, 8); //Final<<<<<<<<<<<<
return cMac;
}




I can even change keys (sometimes, on some cards! - there may be something about new and old key version that needs to be done right.. braicu just assumes old version = 1)

21 September 2011

JCOP Change Keys

JCOP Key Version & Key Change
GPSpec 2.2


Key Change Sometimes  (Occasionally) works  
[ Security Domain Secure Channel Keys  S-ENC S-MAC  DEK]

- I did a keyChange with oldVersion 1 newVersion2,
   then a keyChange with oldVersion2 new Version 3
( it is not stated that versions must be consecutive)
Now I cant change any more ...

Notes:
Initiallize Update   (initialize a Secure Channel Session) is currently done with hardcoded
p1  = 0   .... “ Key Version within the Security Domain to be used to initiate the Secure Channel Session. If this value is zero, the first available key chosen by the Security Domain will be used. “
p2 = 0 ....Key Identifier ..with the Key Version..”unique reference to the set of keys to be used to initiate the Secure Channel Session.”

So a regularisation of usage here seems required.
............................................
ChangeKey [PUT KEY]
has p1 = current key Set      = version  “ identifies keys already on card”
and Data[0] = new KeySet
........................................

Getting the  KeySet version:
the response to  Initialize Update has Key Version Number as byte [11]
 I understand the relation between initialize Update p1 and response ??

........................................

Get Data
There is a variant of getData  (note E0 tagindicating Key data
APDU = FF CA 00 E0 00     but note CLA FF is NOT defined
 - I forget where I learned to use FF as CLA byte....


this Class also used in:
final String sread_uid =    "FFCA 00-00 00";
I forget where I got these FF??


example
Select App 01090000010303000401 selected     keyData 2DB3BB28
   - what means Version B3 ???

try select Card Manager:

after select CardManager: CM selected        keyData 2D B3 BB 28

So I try changeKey oldVersion B3  new Version B4   WORKED!!
then b4 -> B5 it did not work !!  0x6A80       SW_WRONG_DATA

So Occasionally PUT KEY works ... I wish I knew the rules.





20 September 2011

JCOP Card Init Update, Opal

JCOP card example
Init Update is used in authenticate and deriveKeys,

deriveKeys is slightly secret  - the jcManager code. on which this is based,  omits the derive routine.
So its nowhere on the internets.

The Derivation routine was passed to us in a silly kind of hush-hush way - we got sent a jpg of a torn page of the specs ...
(derived means that each card modifies the master keys using some unique cardID.

Its not actually secret, nor  covered by NDA, so offer me a job and I'll bring it.



    static String CMAID = "A000000003000000";  //  Card Manager




    public static byte[] initUpdate()  //  uses globals CMAID, Cardch
    {
//                print("\n Select Card Manager " + CMAID) ;
byte[] selectAPDU = Uti.asHex("00 A4 04 00 08 A0 00 00 00 03 00 00 00 ");  //  Le 00 not present
                // put CMAID into Select:   if CMAID never changes these2 lines redundant:
byte[] issuerDomain = Uti.asHex(CMAID);
                System.arraycopy(issuerDomain,0,selectAPDU,5,8);
                ResponseAPDU  respa = Terminal.sendAPDU(selectAPDU, Cardch);  // CardChannel
                if (respa.getSW() != 0x9000)
                {
                    print("     SW " + Uti.serrcode(respa.getSW()) );  // translate error code
                    return null;
                }
                /**
              // print("\n Select Card Manager APDU response (Horrid ASN.1) " + Uti.asString(respa.getData()));
                '6F' File Control Information (FCI template) Mandatory
                '84' Application / file AID Mandatory
                'A5' Proprietary data Mandatory
                '73' Security Domain Management Data (see Appendix F for detailed coding)              Optional
                '9F6E' Application production life cycle data Optional
                '9F65' Maximum length of data field in command message Mandatory
                **/
hostChallenge = new byte[8];
Random rnd = new Random();
rnd.nextBytes(hostChallenge);


                
byte[] initUpdateAPDU = Uti.asHex("8050 0000 08 00000000  00000000 ");
System.arraycopy(hostChallenge, 0, initUpdateAPDU, 5, 8);
respa = Terminal.sendAPDU(initUpdateAPDU, Cardch);
                if (respa.getSW() == 0x6982)  //  SW_SECURITY_STATUS_NOT_SATISFIED
                {
                    print("  SW_SECURITY_STATUS_NOT_SATISFIED ");
                    print("  Keys incorrect?, not derived? Derived when they oughtnt be?");
                    return null;
                }
                else if(respa.getSW() != 0x9000)
                {
                    print("     SW " + Uti.serrcode(respa.getSW()));
                    return null;
                }
                return respa.getData(); // 28 bytes


    }


______________________________
Sydney Oyster/Opal 2014 $1B
Sydney's version of a universal public transport card .. will be called Opal...
The card will first be introduced on Sydney Ferries by December next year, she said.
.. following year it will be trains, the following year after that it will be buses " ..
She said the system had been bought from and would be operated by the people behind London's Oyster card, and would cost just over $1 billion. NSW Transport Minister Gladys Berejiklian says.
September 13, 2011 AP
smh
________________________________________________________

11 September 2011

Smart Card "No Driver Found" - continued

OK I did the MSoft RegEdit thing:

To stop dumb-arse "no Driver.." message

For x64-bit systems, identical changes must be made under the following subkey:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Cryptography\Calais\SmartCards
    ATR=Hexadecimal      DWORD: 3B,8A,80,01,4A,43,4F,50,34,31,56,32,33,32,7D     (actually a REG_EXPAND_SZ)
    ATRMask= Hexadecimal DWORD: ff,ff,ff,ff,ff,ff,ff,ff,00,00,00,00,00,00,00 (actually a REG_EXPAND_SZ)
    Crypto Provider=String value: "FRED Dummy Provider"                        (actualy REG_SZ)


This mask supposedely will recognise JCOP41 and JCOP31
The message seems to have stopped, but you never know
Now I get a NFC read with OMNIKEY 5321 v2  using "HID" - Omnikey Disgnostic tool 2.4.0.5

I had another Omnikey at home and couldnt get it to work (NFC only) so I dont know if all the drivers I downloaded will work with it of not

I recommend sticking with the dual (Contact/NFC)  5321

I also recommend not settling for Windows "Home"

Smart Card "No Driver Found", QR fun

 Smart Card "No Driver Found" - revisited - You can just ignore this message every time you read a card
OR the fix is: run
gpedit.msc
 1. Click Start, type gpedit.msc in the Search programs and files box, and then press ENTER.
2. In the console tree under Computer Configuration, click Administrative Templates.
3. In the details pane, double-click Windows Components, and then double-click Smart Card.
4. Right-click Turn on Smart Card Plug and Play service, and then click Edit.
5. Click Disabled, and then click OK.

 BUT Windows 7 Home Premium does NOT have gpedit (my New Laptop is W7HP)
 I looked for an install, but got a couple of dodgy looking sites that did NOT install gpedit.msc
I guess for now I'll just have to live with the annoying message

 These sites did NOT work: (remove the zzz if you really like dodgy web sites) icpezzzp thecustomizewzzzindows




This also does NOT work in Wind7HomePrem
 1. Run MMC.exe
 2. Add Group Policy snap-in
3. Open Local Computer Policy\Computer Configuration\Windows Settings\Administrative Templates\Windows Components\Smart Card
 4. Disable Turn On Smart Card Plug And Play Services. Smart Card "No Driver Found"


[im gonna hafta revert to old blog format... the new editor doesnt recognise linebreaks .. how braindead!]

_______________________________________________________________
Quickmark QR fun
 phone ctskinner phone
____________________________________________________________________
 Kronecker Blog Kronecker Blog _______________________________________________________________
 email ctskinner email _______________________________________________________________

Cheap NFC on the way nfctimes

06 September 2011

Java to CAP to Card

JCOP 


 Java to CAP
 Compiling the java:
 We use JCOP41 cards so: We need JavaCard old-style ie 2.2.1 and javaCompiler1.3

Eclipse uses 2.2.2+ so cant be used for the final compile.
 I suspect Netbeans might be persuaded to do the decent thing.

 You dont have to dig up java 1.3,       use java 1.6 with -target 1.1 -source 1.3

 here is the compile batch file
 ...........................................................

 copy "C:\Users\Chris Skinner\Documents\NetBeansProjects\Shamu\src\sham\Shamu.java" \card\src\sham


 set JC_HOME=C:\card\java_card_kit-2_2_1


 :: CARE set JAVA_HOME does NOT change javac version 


 set JAVA_HOME="C:\Program Files\Java\jre1.5.0_05"
:: the above line is pointless?? or does it give us api.jar??


 set PATH=.;%JC_HOME%\bin;%JAVA_HOME%\bin;%PATH%


 cd \card\src\sham
 del *.class


 ::C:\card\jsdk13\bin\javac -g -classpath ".;%JC_HOME%\lib\api.jar" Shamu.java  NOT NOW NEEDED


 javac -target 1.1 -source 1.3 -g -classpath ".;%JC_HOME%\lib\api.jar" Shamu.java 


 pause 


set _CLASSES=C:\card\java_card_kit-2_2_1\lib\apduio.jar;C:\card\java_card_kit-2_2_1\lib\api.jar;C:\card\java_card_kit-2_2_1\lib\capdump.jar;C:\card\java_card_kit- 2_2_1\lib\converter.jar;C:\card\java_card_kit-2_2_1\lib\offcardverifier.jar;




 cd \card\src\ 


 java -classpath "%_CLASSES%"      com.sun.javacard.converter.Converter -config Shamu.opt


 ...........................................................

 You cant just say "converter",
 I jumped through all the classpath hoops as above

 shamu.opt is a configuration file viz:
 ......................................................
 -out EXP JCA CAP
 -exportpath sham\exp 
 -applet 0x1:0x9:0x0:0x0:0x1:0x3:0x1:0x0:0x4:0x1 sham.Shamu sham 0x1:0x9:0x0:0x0:0x1:0x3:0x1:0x0:0x4 1.0

 ......................................................

 It is suggester that the package name should have at least 2 layers... ie I could use a few more...

 We dont ever use the EXP and JCA output?

__________________________________________________________________

CAP to Card

I have used jcManager source to write a CAPLoader

CAPLoader loads CAP produced by this method. (onto JCOP41 cars)

 It Doesnt load many sample CAPs that float down through the Internet.
I guess theyre mostly 2.2.2+

CAPLoader does use SCP02 (Secure Channel Protocol 02) so we are not entirely back in the dark ages. 

Oddly, It authenticates to old JCOP31 cards, so they can evidently use SCP02

28 August 2011

JCOP back again

JCOP
momentarily done with DEFire.  Glad to be back with a JCOP task.
Load a CAP.
Amazingly there seems to be only 1 Java level solution:

jcManager by  Stefan Braicu, source code available.

The Java Card  2.1.1 Virtual  Machine Specification does NOT provide a clear description of how to load a CAP.  The thousands of phone CAPs must all be loaded by 'utilities'. ie not by Java code.


01 August 2011

DESFire Transport Application, DESFire SAM RSA

We have reset a DESFire  Card and re-written the Transport Apps & files.
We know where the money is (in a "functional" file beneath a "logical file" in a physical file)
Wish I could say more but the card and the apps are under Non-Disclosures
Cant even get the docs in searchable form.

That aint no way to run a railroad, but it gives me a skillset I guess
______________________________________________________________________

DESFire SAM  AV2 does 2048 bit RSA


 Times to generate RSA keys (seconds) 10 runs:
 12.66   15.44   32.12   9.98    21.18   17.81   12.06   15.71   36.58   33.45
 roughly equivalent to an old 80386?

10 July 2011

Computers in NZ cont..

BioMatters is a world leader in DNA sequencing, gene assembling and tree forming.
Exporting to 29 Universities world-wide.
geneious



My list of interesting things to do with computers:

1) Search and Match DNA sequences: Craig Venter has a big DECAlpha farm to do the HGSequence.
- But turns out that I could have stayed in NZ to join a world class DNA outfit

2) Simulate explosions for the military
3) Simulate explosions for CGI movies, with Orcs running about.

2) apparently is fairly similar to 3) which had the USA DOD concerned when Peter Jackson assembled the biggest Intel Farm in Wellington for LOTR)
I left Wellington to travel the world, with CGI in mind. Who knew Wgtn would be the place?

3) handle large integers to enable secure transactions and identification

5) simulate the climate crash

6) manage your Audio and Video info, run the Internet, telescopes, traffic lights etc.

7) run businesses, ie databases

I lost interest in CGI (endless noisy orc/goblin battles) so settled for 3)

1) would have been the most fantastic career choice.


DNA searching is at first glance simple. Do a Boyer-Moore on sequences encoded at 2 bits per Base (there are 4 bases)
- I hear that Boyer-Moore has been improved since I implemented it in 16-bit Intel Assembler in the 90's

DNA has peculiarities: Some Base changes dont change the Amino Acid, so thats another layer of search.
Then theres functional search: Some AminoAcids can be replaced with no change in protein function - eg some may simply be 'hydrophilic' to insert in membrane.
Then there are enzyme 'active site' vs backbones, which may be swapped?

Then there are mutations: a single Base loss means a 'Frame Shift' so that all downstream codons are off.
Combine with translocations and jumping genes, some limited back mutation and metres of ancient ERV remnants and the game gets interesting.

Nature, in the form of the MHC and the immune system, hunts for Aa sequences about 5 Aas long thats 20^5 = 1 in 3 million.
Any less and the VanderW forces wouldnt hold, so that may be as important as the odds of uniqueness.
I dont know how many DNA bases in a typical Repressor/Activator sequence. Obviously activator proteins must act on more than one gene, if a gene is required to produce an activation.
This is where the most worthwhile computer stuff is. Its just so damned hard to do Biochem. Life molecules have a tendency to behave badly in the undergraduate lab.
__________________________________________________________________

NewsFlash: Low-Cost NFC in Turkey:
"another Huawei-made device has been spotted, this time in Turkey. Called Sonic (aka Huawei T20), it's a mid-range device with NFC capability and pre-loaded Gingerbread. Turkish Turkcell is offering it for 150 EUR" (NZD255)
engadget

30 June 2011

DESFire SAM AV2, NFC, N9, K Computer

Just "Activated" a DESFire SAM. ie converted it from AV1 to AV2
I can write keys to SAMs easily enough
but the commands to write keys to Cards are more obstruse
even with NXP's (confidential) Documents - hint... the documents occasionally have a "Standard" and also a "Worked Example"
which may contradict. Try the "Worked Example"

To write to Cards we tried to install the Collis Card Tool, but right now we appear to lack
Collis Conclusion Runtime Environment 2.1.2 -2.9.9
- Now thats why I like CDROM installs. People used to try to get Every Neccessary Thing on a CDROM...
_____________________________________________________________
first international NFC payments service is to go live this summer, Thierry Barba,...at Orange Group... GSMA's Mobile Money Summit in Singapore.

..Quick Tap NFC service, launched in the UK by Orange and Barclaycard last month will be able to use their NFC phones to make payments in Nice, the test site for the French Cityzi NFC project which is also backed by Orange. The French system is set for a nationwide commercial rollout of NFC services from the spring of 2012 and Orange expects to sell 500,000 NFC phones in France this year.

nearfieldcommunicationsworld
___________________________________________________________________
Nokia's N9 does NFC
MeeGo, the Linux-based open source operating system born from the February 2010 shotgun marriage of Nokia's Maemo and Intel's Moblin and left at the altar when Nokia hooked up with Windows Phone 7, is an "unstoppable force" that speeds device-developers' time-to-market..... MeeGo Conference in San Francisco on Monday by the executive director of The Linux Foundation Jim Zemlin

(local Store says they will have  GalaxySII 'soon" at ca $1,100)

nearfield
nearfield
viddler
nearfieldcommunicationsworld
___________________________________________________________________
The K Computer ....

Japan’s Riken Advanced Institute.. ..fastest supercomputers.
... peak 8.77 PFlop/s..sustained 8.2 PFlop/s [Peta = E15]

Previous: ..Tianhe-1.. November.. 4.7 PFlop/s, K does not use GPUs..It’s extremely difficult to exploit ..a GPU supercomputer.

K ... 68,544 2.0 GHz Fujitsu Sparc VIIIfx CPUs with 8 cores each, ..(548,352). Each core .. 16 (double-precision, DP) GFlop/s,.. slightly more than Intel.. Sandy Bridge..
45 nm chip .. 8 flop/clock/core.

8-core processor ...58 Watts.
currently 9.9 MWatts ..When finalized,... 10 PFlop/s ... 11 MWatts.
..human Brain .. 10 - 38 PFlop/s ... memory 3584 TB
we may be able to simulate a human brain next year or within 3 years.

conceivablytech

16 June 2011

Java Distribution, SwingWorker

Java Distribution
OK one more time: Java Distro made easy:

if using Netbeans: (bad GUI IDE...)

Right click on the dist folder, send it to a compressed folder
this will put the lib directory in place with all your extra jars.

do NOT futz with classpath... it wont do any good Java is notorious for not finding jars,
and deceiving about CLASSPATH

put a batch file called fred.bat
java -jar fred.jar
in the dist directory before you zip it.

In my old age I am finally writing static libraries of common functions.
But I am not permitted to do static imports,which nicely hide the class names...
_____________________________________________________
SwingWorker
Java Swing is NOT threadsafe - beware the black screen, which only task manager can kill

You need a silly thing called SwingWorker if your gonna wait for a card etc...


void SAM() //Button action HOT Switching SAMs
{
    UID = "";
    tSAM.setText("Insert SAM ");
    if (cardTerms == null)
    initTerms(); // make a list of all teminals: java does this nicely   

//_________________________________________________________


    SwingWorker waitForSAM = new SwingWorker()
    {
        public String doInBackground()
    {
    do
    {
       
 tryAllTermsCL(true); // <<<< find a SAM on a NonNFC reader
                                              

// do as much SAM/Card dependent stuff as you can, here, inside the SwingWorker..                                                                


        if (this.isCancelled()) // ideally have a Cancel button
             exit return("can"); 
    
     } 
     while ( UID.length() < 2); 

         publish(UID); //publish an update, this will get added to a list and processed in bulk by the process() method at some point 
     try 
     { 
         Thread.sleep(150); // let a cancel in?? 
     }
     catch (InterruptedException e) 
     {    
         System.out.println("Irrrrr"); 
         return("rupt"); 
     } 
     return("blank"); 
     } 
     @Override protected void process(List    chunks) 
     {
         //System.out.println("\n process " + chunks);

     }

        @Override
        protected void done()
        {
            tSAM.setText(UID);
        } // done
    }; //waitForCard definition fin

//_________________________________________________________
    waitForSAM.execute();

// card wait stuff done here may cause black-screen.....

    tArea.setCaretPosition(tArea.getDocument().getLength());


14 June 2011

HSM, NFC, GPU, Kindle Dash

HSM
I made a true triple DES key, loaded it into a HSM (software emulation)
It gave a correct KCV (encryption of 00..00) which had me fooled
But upon extraction (getKey) it gave a different result
Conclusion HSM double DES only!
____________________________________________________


Android 2.3.3 release, Google has added new capabilities for developers, including updates to the API ... that now allow for both reading and writing to standard NFC tags.
Dude..... its about more than tags
- we have a Nexus S in the office, it almost works for our reload app...
hope I can get some time to play with it (NZ1100?)

According to the Android Developers blog, some of the new features include:


A comprehensive NFC reader/writer API that lets apps read and write to almost any standard NFC tag in use today.
Advanced Intent dispatching that gives apps more control over how/when they are launched when an NFC tag comes into range.
Some limited support for peer-to-peer connection with other NFC devices.
For end users of NFC-enabled Android devices, what this means is that applications now have more control about how they are launched when an NFC tag is read. For example, apps could listen for specific tag content or tag technologies, and only launch when a match was made. Plus, applications running in the foreground could stop another app from launching upon the tag reading event, if need be.


The updated platform also provides a limited peer-to-peer communication protocol
http://android-developers.blogspot.com/2011/02/android-233-platform-new-nfc.html
NFC-A (ISO 14443-3A)
• NFC-B (ISO 14443-3B)
• NFC-F (JIS 6319-4)
• NFC-V (ISO 15693)
• ISO-DEP (ISO 14443-4)
• Mifare Classic
• Mifare Ultralight
NFC Forum NDEF tags
androidcommunity

developer.android
____________________________________________________

.Graphics Processing Unit  for cracking passwords..the GPU produces the correct password in a fraction of the time. On a Windows machine he pitted the Cain password recovery tool which uses the CPU for its calculations against ighashgpu which uses ATI or Nvidia graphics cards to do the deed. Hands down ighashgpu is the fastest; with Cain taking about one year to crack an eight character password while ighashgpu can do it in under nineteen hours.

hackaday
.....................................
GPGPU computing ... doing general calculations on graphic cards (GPUs) rather than CPUs. ... GPUs ... rendering frames .... people started realizing that GPUs are far more efficient at handling highly parallel tasks ... GPUs are used to speed up video conversion, video processing, doing scientific calculations, folding and password hash cracking.
ighashgpu.
golubev

how many passwords the GPU has churned out per second. Dude, it’s 3.334 billion passwords.

wordpress
____________________________________________________

Kindle seems nifty. But : dash it!
lunascafe typography-is-about-reading-and-so-are
____________________________________________________