java md ds

24
csci5233 Computer Securit y 1 GS: Chapter 6 Using Java Cryptography for Authentication

Upload: phanleson

Post on 07-Nov-2014

1.420 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Java Md Ds

csci5233 Computer Security 1

GS Chapter 6

Using Java Cryptography for Authentication

csci5233 Computer Security 2

Topics

Message digest (MD) Password authentication for MD Message Authentication Code (MAC) Digital signatures amp Identity authentication Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

csci5233 Computer Security 3

Dependencies

bull Review example programs and discussions in Chapter 3

csci5233 Computer Security 4

Message Digests

message digest a fingerprint of a piece of data

goal data integrity (stored data transmitted data file

copying hellip)

message hashing algorithm digest

Java class MessageDigest

Methods getInstance ( ) update ( ) digest ( )

Algorithms MD5 SHA SHA-1

csci5233 Computer Security 5

Message Digests in Java javasecurity

Class MessageDigest

Message digests are secure one-way hash functions that take arbitrary-

sized data and output a fixed-length hash value

A MessageDigest object starts out initialized The data is processed

through it using the update methods

At any point reset can be called to reset the digest

Once all the data to be updated has been updated one of the digest

methods should be called to complete the hash computation

After digest has been called the MessageDigest object is reset to its

initialized state

csci5233 Computer Security 6

Message Digests in Java

byte[] digest ()

Completes the hash computation by performing final

operations such as padding

byte[] digest (byte[] input)

Performs a final update on the digest using the specified

array of bytes then completes the digest computation

int digest (byte[] buf int offset int len)

Completes the hash computation by performing final

operations such as padding

csci5233 Computer Security 7

Message Digests in Java Computing a message digest on a file DigestFilejava

Size of the output digest

SHA-1 20 bytes

MD5 16 bytes

Exercise Change the content of the input data file and

compare the output digests

Project Write a program that gets a file the MD algorithm

and the generated digest as the input and then determine if

the file has been corrupted

csci5233 Computer Security 8

Message Digests in Java

Alternative classes for computing a message digest on a

file DigestInputStream and DigestOutputStream

DigestInputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest input streams read methods

Sample program DigestStreamExamplejava

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 2: Java Md Ds

csci5233 Computer Security 2

Topics

Message digest (MD) Password authentication for MD Message Authentication Code (MAC) Digital signatures amp Identity authentication Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

csci5233 Computer Security 3

Dependencies

bull Review example programs and discussions in Chapter 3

csci5233 Computer Security 4

Message Digests

message digest a fingerprint of a piece of data

goal data integrity (stored data transmitted data file

copying hellip)

message hashing algorithm digest

Java class MessageDigest

Methods getInstance ( ) update ( ) digest ( )

Algorithms MD5 SHA SHA-1

csci5233 Computer Security 5

Message Digests in Java javasecurity

Class MessageDigest

Message digests are secure one-way hash functions that take arbitrary-

sized data and output a fixed-length hash value

A MessageDigest object starts out initialized The data is processed

through it using the update methods

At any point reset can be called to reset the digest

Once all the data to be updated has been updated one of the digest

methods should be called to complete the hash computation

After digest has been called the MessageDigest object is reset to its

initialized state

csci5233 Computer Security 6

Message Digests in Java

byte[] digest ()

Completes the hash computation by performing final

operations such as padding

byte[] digest (byte[] input)

Performs a final update on the digest using the specified

array of bytes then completes the digest computation

int digest (byte[] buf int offset int len)

Completes the hash computation by performing final

operations such as padding

csci5233 Computer Security 7

Message Digests in Java Computing a message digest on a file DigestFilejava

Size of the output digest

SHA-1 20 bytes

MD5 16 bytes

Exercise Change the content of the input data file and

compare the output digests

Project Write a program that gets a file the MD algorithm

and the generated digest as the input and then determine if

the file has been corrupted

csci5233 Computer Security 8

Message Digests in Java

Alternative classes for computing a message digest on a

file DigestInputStream and DigestOutputStream

DigestInputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest input streams read methods

Sample program DigestStreamExamplejava

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 3: Java Md Ds

csci5233 Computer Security 3

Dependencies

bull Review example programs and discussions in Chapter 3

csci5233 Computer Security 4

Message Digests

message digest a fingerprint of a piece of data

goal data integrity (stored data transmitted data file

copying hellip)

message hashing algorithm digest

Java class MessageDigest

Methods getInstance ( ) update ( ) digest ( )

Algorithms MD5 SHA SHA-1

csci5233 Computer Security 5

Message Digests in Java javasecurity

Class MessageDigest

Message digests are secure one-way hash functions that take arbitrary-

sized data and output a fixed-length hash value

A MessageDigest object starts out initialized The data is processed

through it using the update methods

At any point reset can be called to reset the digest

Once all the data to be updated has been updated one of the digest

methods should be called to complete the hash computation

After digest has been called the MessageDigest object is reset to its

initialized state

csci5233 Computer Security 6

Message Digests in Java

byte[] digest ()

Completes the hash computation by performing final

operations such as padding

byte[] digest (byte[] input)

Performs a final update on the digest using the specified

array of bytes then completes the digest computation

int digest (byte[] buf int offset int len)

Completes the hash computation by performing final

operations such as padding

csci5233 Computer Security 7

Message Digests in Java Computing a message digest on a file DigestFilejava

Size of the output digest

SHA-1 20 bytes

MD5 16 bytes

Exercise Change the content of the input data file and

compare the output digests

Project Write a program that gets a file the MD algorithm

and the generated digest as the input and then determine if

the file has been corrupted

csci5233 Computer Security 8

Message Digests in Java

Alternative classes for computing a message digest on a

file DigestInputStream and DigestOutputStream

DigestInputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest input streams read methods

Sample program DigestStreamExamplejava

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 4: Java Md Ds

csci5233 Computer Security 4

Message Digests

message digest a fingerprint of a piece of data

goal data integrity (stored data transmitted data file

copying hellip)

message hashing algorithm digest

Java class MessageDigest

Methods getInstance ( ) update ( ) digest ( )

Algorithms MD5 SHA SHA-1

csci5233 Computer Security 5

Message Digests in Java javasecurity

Class MessageDigest

Message digests are secure one-way hash functions that take arbitrary-

sized data and output a fixed-length hash value

A MessageDigest object starts out initialized The data is processed

through it using the update methods

At any point reset can be called to reset the digest

Once all the data to be updated has been updated one of the digest

methods should be called to complete the hash computation

After digest has been called the MessageDigest object is reset to its

initialized state

csci5233 Computer Security 6

Message Digests in Java

byte[] digest ()

Completes the hash computation by performing final

operations such as padding

byte[] digest (byte[] input)

Performs a final update on the digest using the specified

array of bytes then completes the digest computation

int digest (byte[] buf int offset int len)

Completes the hash computation by performing final

operations such as padding

csci5233 Computer Security 7

Message Digests in Java Computing a message digest on a file DigestFilejava

Size of the output digest

SHA-1 20 bytes

MD5 16 bytes

Exercise Change the content of the input data file and

compare the output digests

Project Write a program that gets a file the MD algorithm

and the generated digest as the input and then determine if

the file has been corrupted

csci5233 Computer Security 8

Message Digests in Java

Alternative classes for computing a message digest on a

file DigestInputStream and DigestOutputStream

DigestInputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest input streams read methods

Sample program DigestStreamExamplejava

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 5: Java Md Ds

csci5233 Computer Security 5

Message Digests in Java javasecurity

Class MessageDigest

Message digests are secure one-way hash functions that take arbitrary-

sized data and output a fixed-length hash value

A MessageDigest object starts out initialized The data is processed

through it using the update methods

At any point reset can be called to reset the digest

Once all the data to be updated has been updated one of the digest

methods should be called to complete the hash computation

After digest has been called the MessageDigest object is reset to its

initialized state

csci5233 Computer Security 6

Message Digests in Java

byte[] digest ()

Completes the hash computation by performing final

operations such as padding

byte[] digest (byte[] input)

Performs a final update on the digest using the specified

array of bytes then completes the digest computation

int digest (byte[] buf int offset int len)

Completes the hash computation by performing final

operations such as padding

csci5233 Computer Security 7

Message Digests in Java Computing a message digest on a file DigestFilejava

Size of the output digest

SHA-1 20 bytes

MD5 16 bytes

Exercise Change the content of the input data file and

compare the output digests

Project Write a program that gets a file the MD algorithm

and the generated digest as the input and then determine if

the file has been corrupted

csci5233 Computer Security 8

Message Digests in Java

Alternative classes for computing a message digest on a

file DigestInputStream and DigestOutputStream

DigestInputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest input streams read methods

Sample program DigestStreamExamplejava

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 6: Java Md Ds

csci5233 Computer Security 6

Message Digests in Java

byte[] digest ()

Completes the hash computation by performing final

operations such as padding

byte[] digest (byte[] input)

Performs a final update on the digest using the specified

array of bytes then completes the digest computation

int digest (byte[] buf int offset int len)

Completes the hash computation by performing final

operations such as padding

csci5233 Computer Security 7

Message Digests in Java Computing a message digest on a file DigestFilejava

Size of the output digest

SHA-1 20 bytes

MD5 16 bytes

Exercise Change the content of the input data file and

compare the output digests

Project Write a program that gets a file the MD algorithm

and the generated digest as the input and then determine if

the file has been corrupted

csci5233 Computer Security 8

Message Digests in Java

Alternative classes for computing a message digest on a

file DigestInputStream and DigestOutputStream

DigestInputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest input streams read methods

Sample program DigestStreamExamplejava

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 7: Java Md Ds

csci5233 Computer Security 7

Message Digests in Java Computing a message digest on a file DigestFilejava

Size of the output digest

SHA-1 20 bytes

MD5 16 bytes

Exercise Change the content of the input data file and

compare the output digests

Project Write a program that gets a file the MD algorithm

and the generated digest as the input and then determine if

the file has been corrupted

csci5233 Computer Security 8

Message Digests in Java

Alternative classes for computing a message digest on a

file DigestInputStream and DigestOutputStream

DigestInputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest input streams read methods

Sample program DigestStreamExamplejava

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 8: Java Md Ds

csci5233 Computer Security 8

Message Digests in Java

Alternative classes for computing a message digest on a

file DigestInputStream and DigestOutputStream

DigestInputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest input streams read methods

Sample program DigestStreamExamplejava

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 9: Java Md Ds

csci5233 Computer Security 9

Message Digests in Java

DigestOutputStream

A transparent stream that updates the associated message digest using the

bits going through the stream

To complete the message digest computation call one of the digest

methods on the associated message digest after your calls to one of

this digest ouput streams write methods

Any advantages over the MessageDigest class yes

automatic generation of the digest

Exercise Rewrite the DigestStreamExamplejava program by using

DigestOutputStream instead

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 10: Java Md Ds

csci5233 Computer Security 10

Message Digests in Java

Another application of MD Using message digests to

store and authenticate passwords

Sample program PasswordAuthenticatorjava

Usages

-c password Create a password

-a password Authenticate the password

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 11: Java Md Ds

csci5233 Computer Security 11

Message Digests in Javabull Storing the password

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 12: Java Md Ds

csci5233 Computer Security 12

Message Digests in Javabull Authenticate a password using the stored password

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 13: Java Md Ds

csci5233 Computer Security 13

Message Authentication Codes A keyed message digest

Often used for authenticating data sent over an insecure

network or stored in an insecure medium

To prevent man-in-the-middle attack against keyless message digest

message + key MA algorithm MAC

Verification

The same key is used to produce MACrsquo which is compared

to MAC to determine if the message has been

tampered

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 14: Java Md Ds

csci5233 Computer Security 14

Using MAC in Java HMAC (Hashed MAC)

HMAC functions supported by JCE

HmacMD5 and HmacSHA1

javaxcrypto

Class Mac

Methods getInstance( ) init( ) update( ) doFinal( )

Sample program MACExamplejava

Drawback of MAC The need to have a shared secret key

Solution Digital signatures

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 15: Java Md Ds

csci5233 Computer Security 15

Digital Signatures

Associates an individual with a particular piece of data

like a signed contract or an e-mail

is essentially a message digest signed by someonersquos

private key achieves both data integrity and source

integrity (ie authentication)

Review diagrams on p48 as well as on pp135-136

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 16: Java Md Ds

csci5233 Computer Security 16

Digital Signature Algorithm (DSA)

works similarly to RSA signing but lack an encryption

capability

cf RSA

DSA is faster at generating signatures RSA is faster at

validating signatures

DSA was supported in older Java (v12) RSA is supported

by JDK v13 and higher

RSA is generally recommended if you have a choice

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 17: Java Md Ds

csci5233 Computer Security 17

DSA and RSA The signature algorithm can be among others DSA and

SHA-1 The DSA algorithm using the SHA-1 message

digest algorithm can be specified as SHA1withDSA

In the case of RSA there are multiple choices for the

message digest algorithm so the signing algorithm could

be specified as for example MD2withRSA

MD5withRSA or SHA1withRSA

The algorithm name must be specified as there is no

default

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 18: Java Md Ds

csci5233 Computer Security 18

Digital Signatures in Java

javasecurity

Class Signature

refers to the object used to create and verify DS but not

the signatures which are manipulated as byte arrays

Methods getInstance( ) initSign( )

initVerify( ) update( ) sign( ) and

verify( )

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 19: Java Md Ds

csci5233 Computer Security 19

Digital Signatures in Java There are three phases to the use of a Signature object

1 Initialization with either

a public key which initializes the signature for verification (see

initVerify( ) ) or

a private key which initializes the signature for signing (see initSign(

PrivateKey) and initSign(PrivateKey SecureRandom))

2 Updating

Depending on the type of initialization this will update the bytes to be

signed or verified See the update( ) methods

3 Signing or Verifying a signature on all updated bytes See the sign( )

methods and the verify( ) method

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 20: Java Md Ds

csci5233 Computer Security 20

Digital Signatures in Java

Sample program SignatureExamplejava

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 21: Java Md Ds

csci5233 Computer Security 21

Authenticating Identity using DS

Authenticating a

userrsquos identity by

using his digital

signature Application

secure

communication

between a server

and a client (eg

online bank

transaction)

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 22: Java Md Ds

csci5233 Computer Security 22

Authenticating Identity using DS Sample programs

SignatureAuthenticationClientjava

SignatureAuthenticationServerjava Advantage of this ldquononcerdquo approach

It allows the server to validate the clientrsquos signature at the

beginning of a communication session

Drawback requires secure communication otherwise may

suffer man-in-the-middle attack

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 23: Java Md Ds

csci5233 Computer Security 23

Authenticating Identity using DS cf Server-initiated authentication

The server encrypts some random data with the clientrsquos

public key and sends the result to the client If the client

can decrypt the ciphertext his identity is authenticated

Trade-offs

cf The ldquofull-blownrdquo DS approach in which the client

sign every message Trade-offs

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next
Page 24: Java Md Ds

csci5233 Computer Security 24

Next

Digital certificates X509 certificate chaining Keystores Public Key Infrastructure (PKI)

  • GS Chapter 6 Using Java Cryptography for Authentication
  • Topics
  • Dependencies
  • Message Digests
  • Message Digests in Java
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Message Authentication Codes
  • Using MAC in Java
  • Digital Signatures
  • Digital Signature Algorithm (DSA)
  • DSA and RSA
  • Digital Signatures in Java
  • Slide 19
  • Slide 20
  • Authenticating Identity using DS
  • Slide 22
  • Slide 23
  • Next