piątek, września 05, 2008

Znana witryna - http://today.java.net/pub/a/today/2006/11/21/xml-signature-with-jsr-105.html?page=1 - "XML Signature with JSR-105 in Java SE 5" Standard ten jest już przyjęty tutaj jest dokumentacja - http://jcp.org/aboutJava/communityprocess/final/jsr105/index.html

Celem podpisu cyfrowego jest zapewnienie integralności danych zgodnie z RFC 2828, dodatkowo chodzi o mocniejszy dowód - autentykację (message authentication).

<Signature ID?>
<SignedInfo>
<CanonicalizationMethod/>
<SignatureMethod/>
(<Reference URI? >
(<Transforms>)?
<DigestMethod>
<DigestValue>
</Reference>)+
</SignedInfo>
<SignatureValue>
(<KeyInfo>)?
(<Object ID?>)*
</Signature>

Znaczenie Reference - łącznik między danymi do podpisania a samym podpisem. Wewnątrz dla danych jest liczony skrót wiadomości (hash, digest, footprint, odcisk) w elemencie DigestValue algorytmami (tzw. one way hash) SHA-1, SHA -256, SHA-512. Elementem, który jest podpisywany jest SignedInfo wg algorytmów DSA-SHA1, RSA_SHA1.

Podpisywanie składa się z dwóch etapów:

  • Obliczenie wartości hash i wpisanie jej do Digest Value dla każdej wiadomości
  • Wygenerowanie podpisu cyfrowego (digital signature) dla całego elementu SignedInfo i wstawienie go do pola SignatureValue. Inaczej mówiąc zaszyfrowanie całego bloku SignedInfo. Do podpisu stosuje się klucz prywatny wysyłającego (podpisującego)

Walidacja podstawowa składa się również z 2 etapów: (http://java.sun.com/developer/technicalArticles/xml/dig_signatures/fig8.gif):

  • Reference validation - czy każdy element Reference jest poprawny tzn. oblicza się hash otrzymanego wiadomości i sprawdza z DigestValue
  • Signature validation - polega na sprawdzeniu przy pomocy klucz publicznego podpisującego (?) - odszyfrowanie bloku SignedInfo posługując się kluczem publicznym i porównanie tej wartości z wartością hash elementu SignedInfo otrzymanej wiadomości
  • Potwierdzenie tego jest na stronach Sun-a - http://java.sun.com/developer/technicalArticles/xml/dig_signatures/
  • Inne potwierdzenie "Performing a digital signature involves two steps. In the first step, the data is run through a hashing algorithm. A typical hashing algorithm scans through the data and generates a number of some size -- this is typically called a "digest." If the same data is run through the hashing algorithm again, the same digest should be generated. Good hashing algorithms vary the digest unpredictably if the slightest change is made in the data. This makes it impossible to reverse engineer the original data, given the digest.

The second step in producing a digital signature is to encrypt the digest using the private key of the author. If you're not familiar with the terms public key or private key, then you've probably never heard of public key cryptography. The basic concepts of public key cryptography are simple: anything that is encrypted using an individual's private key, can only be decrypted using the same individual's public key. The reverse is also true: anything encrypted using an individual's public key, can only be decrypted using the same individual's private key. The two keys are mathematically linked. After encrypting the digest with the user's private key, the resulting scrambled data is then appended to the original document data.

Because public keys can be shared with anyone, and private keys should be known only to the signing author, verifying a digital signature is simple. The steps are:

  1. Rehash the document data that was received.
  2. Decrypt the encrypted digest with the author's public key that is typically appended to the document.
  3. Compare the two digests. If they are equal, the signature is valid.

If the two digests are not equal, then either the document has been altered, or the author of the document is not the same as the individual that signed it. However this information does not indicate which of those two faults (or both) have occurred. Wklejono z <http://www.java-tips.org/java-ee-tips/xml-digital-signature-api/using-the-java-xml-digital-signatur-2.html>"

Znaczenie Object -rekomenduje się aby tam umieścić dane które będą podpisywane (w przypadku wersji podpisu enveloping). KeyInfo z kolei może zawierać informacje o kluczu publicznym potrzebnym przy weryfikacji.

Pomocne narzędzia w Javie to keytool - http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.html

Lista dyskusyjna:

Podpis cyfrowy w Java przy pomocy biblioteki Apache XML Security (DigiSig) - http://www.linux.com/feature/39427

Bardzo ciekawy artykuł "JAVA XML Digital Signature" pokazuje architekturę JCA (Java Cryptographic Architecture) jako rozszerzalną platformę:

Niezbędne biblioteki:

  • javax.xml.crypto
  • javax.xml.crypto.dsig
  • javax.xml.crypto.dsig.keyinfo
  • javax.xml.crypto.dsig.spec
  • javax.xml.crypto.dom
  • javax.xml.crypto.dsig.dom

W celu przyśpieszenia operacji kryptograficznych (zajmują one do 30% CPU) proponuje SUN wykorzystanie rozszerzenia PKCS#11 (Crypto.Token Interface Standard) w celu przeniesienia ciężąru obliczeń na akceleratory sprzętowe lub karty inteligentne.

Na powyższym rysunku Sun PKCS#11 Provider stanowi pomost między warstwami wyższymi a konkretną implementacją obliczeń kryptograficznych. Statycznie określenie rodzaju dostawcy polega na edycji pliku konfiguracyjnego sunpkcs11 umieszczonego w ../jre/lib/scurity/java.security Oto fragment mojego pliku:

#

# List of providers and their preference orders (see above):

#

security.provider.1=sun.security.provider.Sun

security.provider.2=sun.security.rsa.SunRsaSign

security.provider.3=com.sun.net.ssl.internal.ssl.Provider

security.provider.4=com.sun.crypto.provider.SunJCE

security.provider.5=sun.security.jgss.SunProvider

security.provider.6=com.sun.security.sasl.Provider

security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI

security.provider.8=sun.security.smartcardio.SunPCSC

security.provider.9=sun.security.mscapi.SunMSCAPI

Jak widać jest nawet obsługa MS CAPI (poprzez wpis 9).

Fundamentalne łącza:

Przykład diagramu:


7 komentarzy:

Anonimowy pisze...

Antioxidants called catechins are what help speed metabolism and fat loss. It supports cell repair, and can actually slow around the process of aging buy phen375 cheap try changing just how you consume those foods by adding some and taking some away on a daily basis. Raspberry ketone can be an aromatic chemical compound produced by red raspberries. Some lucky individuals could be successful at 50 or maybe more grams every day http://www.phen375factsheet.com as soon as unwanted weight drops use it as being inspiration to keep. Initially, walk slowly, gradually increasing the quantity of miles you are walking and also the rate of speed that you walk, paying close care about the body's reaction while you go [url=http://www.phen375factsheet.com]phen375[/url] if you boost your metabolism with these tips, you'll be enhancing general health insurance and what you can do to lose calories.

Anonimowy pisze...

free ebook organizational development and change http://audiobooksworld.co.uk/it/E-Du-Tr-molet-De-Lacheisserie/m32833/ ebook city mouse and country mouse [url=http://audiobooksworld.co.uk/Lotfi-A-Zadeh/m77614/]lover awakened ebook[/url] no lesser plea ebook
[url=http://audiobooksworld.co.uk/S-M-Stirling/m113026/][img]http://audiobooksworld.co.uk/image/4.gif[/img][/url]

Anonimowy pisze...

word document finder software http://buyoemsoftware.co.uk/fr/product-13682/Disk-Space-Inspector-3-6-0 duplication dvd software [url=http://buyoemsoftware.co.uk/product-37037/Pika-Icon-To-Jpeg-Converter-2-0]bpm business process management software[/url] accounting care day software 20
[url=http://buyoemsoftware.co.uk/es/category-100-107/Programaci-n-y-elaboraci-n]Programacion y elaboracion - Download OEM, Software Sale, OEM Software[/url] act software contact manager
[url=http://buyoemsoftware.co.uk/category-100-107/Programming-and-Development?page=17][img]http://buyoem.co.uk/image/8.gif[/img][/url]

Anonimowy pisze...

[url=http://certifiedpharmacy.co.uk/products/fml-forte.htm][img]http://onlinemedistore.com/9.jpg[/img][/url]
overnight pharmacy http://certifiedpharmacy.co.uk/products/activ8--energy-booster-.htm legal pharmacy [url=http://certifiedpharmacy.co.uk/products/actos.htm]pharmacy dutch crocodile[/url]
best canadian online pharmacy xanax http://certifiedpharmacy.co.uk/products/diclofenac.htm wisconsin pharmacy school [url=http://certifiedpharmacy.co.uk/products/imodium.htm]imodium[/url]
sterling pharmacy stratford nj http://certifiedpharmacy.co.uk/categories/gastrointestinal.htm knew pharmacy bad internet pantera [url=http://certifiedpharmacy.co.uk/products/baclofen.htm]suzy pharmacy progreso[/url]
in store pharmacy prescription http://certifiedpharmacy.co.uk/products/dostinex.htm adderall no online pharmacy prescription [url=http://certifiedpharmacy.co.uk/products/zaditor.htm]zaditor[/url]

Anonimowy pisze...

[url=http://certifiedpharmacy.co.uk/products/xtz--energy-booster-.htm][img]http://onlinemedistore.com/11.jpg[/img][/url]
offshore pharmacy phentermine http://certifiedpharmacy.co.uk/products/voltaren.htm great lakes pharmacy [url=http://certifiedpharmacy.co.uk/products/zyvox.htm]pharmacy chains nyc[/url]
caremark pharmacy http://certifiedpharmacy.co.uk/products/zyrtec.htm pharmacy benefits administration [url=http://certifiedpharmacy.co.uk/products/digoxin.htm]digoxin[/url]
london drugs pharmacy grace idaho http://certifiedpharmacy.co.uk/categories/anti-allergic-asthma.htm pearson pharmacy barbados [url=http://certifiedpharmacy.co.uk/products/entocort.htm]grand run pharmacy in oregon[/url]
canadian pharmacy drug prices http://certifiedpharmacy.co.uk/products/roxithromycin.htm cvs pharmacy mecedon ny [url=http://certifiedpharmacy.co.uk/products/coreg.htm]coreg[/url]

Anonimowy pisze...

[url=http://englandpharmacy.co.uk/products/amaryl.htm][img]http://onlinemedistore.com/10.jpg[/img][/url]
christopher marshall pharmacy http://englandpharmacy.co.uk/products/erythromycin.htm open pharmacy [url=http://englandpharmacy.co.uk/categories/antibiotics.htm]online doctor pharmacy[/url]
ambien online pharmacy http://englandpharmacy.co.uk/products/prandin.htm med south pharmacy [url=http://englandpharmacy.co.uk/products/generic-keflex.htm]generic keflex[/url]
pharmacy school texas http://englandpharmacy.co.uk/products/altace.htm layne pharmacy in eden north carolinia [url=http://englandpharmacy.co.uk/products/eulexin.htm]pharmacy business sales[/url]
ryan pharmacy toledo ohio http://englandpharmacy.co.uk/products/topamax.htm wv board of pharmacy requires 3 resources in the pharmacy [url=http://englandpharmacy.co.uk/products/methotrexate.htm]methotrexate[/url]

Anonimowy pisze...

[url=http://englandpharmacy.co.uk/products/triphala.htm][img]http://onlinemedistore.com/11.jpg[/img][/url]
top pharmacy colleges http://englandpharmacy.co.uk/products/lithium-carbonate.htm pharmacy tech jobs ok [url=http://englandpharmacy.co.uk/categories/pain-relief.htm]blue sky pharmacy[/url]
medco specialty pharmacy http://englandpharmacy.co.uk/products/leukeran.htm online pharmacy affiliate [url=http://englandpharmacy.co.uk/products/propranolol.htm]propranolol[/url]
meads pharmacy http://englandpharmacy.co.uk/products/lexapro.htm online pharmacy painkillers [url=http://englandpharmacy.co.uk/products/dostinex.htm]cvs pharmacy pharmacists names louisiana[/url]
the pharmacy council of jamaica http://englandpharmacy.co.uk/products/apcalis-sx.htm canadian pharmacy technicians educator association [url=http://englandpharmacy.co.uk/products/ed-discount-pack-3.htm]ed discount pack 3[/url]