Top Banner
Mike Taylor Uniface Solution Specialist Atlanta - June 8 th , 2010 Encryption and Security
22

02-Security & Encryption-CPWR 2

Dec 31, 2015

Download

Documents

02-Security & Encryption-CPWR 2
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 02-Security & Encryption-CPWR 2

Mike TaylorUniface Solution SpecialistAtlanta - June 8th, 2010

Encryption and Security

Page 2: 02-Security & Encryption-CPWR 2

Agenda

Encode/encrypt – Decode/DecryptHash functions

Block ciphers

Calling webservices with a certificate

Page 3: 02-Security & Encryption-CPWR 2

3

Project Goal Provide the ability to encode/encrypt and

decode/decrypt data by Uniface 4GL proc functions. Hash functions

MD4, MD5, SHA-1, SHA-2, HMAC

Block ciphers AES, DES, Triple DES, Blowfish, Twofish

Miscellaneous Base64, HEX, URL encoding

Page 4: 02-Security & Encryption-CPWR 2

4

Hash functionsReturn fixed length data which is;

infeasible to find the source from a hash.

infeasible to find two different sources with the same hash.

INPUT HASH

B062B1413B28E83DCBF4E9DB2C51D63EUniface

Page 5: 02-Security & Encryption-CPWR 2

5

Block ciphers (1)

Use a symmetric key to encrypt and decrypt the data.

Operate on fixed-length data called block.

INPUT CIPHER

KEY

8A0D1BBFA0C34DUniface

password

Page 6: 02-Security & Encryption-CPWR 2

6

Block ciphers (2)

REF: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation

Data is divided into blocks (fixed length data) and each block is encrypted separately.

Identical plaintext blocks are encrypted into identical cipher text blocks.

Page 7: 02-Security & Encryption-CPWR 2

7

Modes of operation

Original ECB mode other modes

REF: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation

Several modes of operation have been invented which allow block ciphers to provide confidentiality.

Mode: ECB, CBC, CFB, OFB etc.

Page 8: 02-Security & Encryption-CPWR 2

8

Initialization Vector (IV)

REF: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation

All modes except ECB require an initialization vector (IV)

No need to be secret, but it is important that never reused with the same key

Page 9: 02-Security & Encryption-CPWR 2

9

New proc functions$encode and $decode

Syntax:

$encode/$decode(Algorithm, Source{, Key{, Mode, IV}}) Algorithm: Encode/encryption algorithm Source: Source data Key: Secret key for a block cipher Mode: Modes of operation IV: Initialization Vector

Page 10: 02-Security & Encryption-CPWR 2

10

$encode / $decode (1)

$encode/$decode(Algorithm, Source{, Key{, Mode, IV}})Algorithm:Hash functions (only available for $encode)

MD4, MD5, SHA1, SHA224, SHA256, SHA384, SHA512, HMAC_MD5, HMAC_SHA1

Block ciphers AES (RIJNDAEL), DES, TDES (DES_EDE3), DES_EDE2, DESX (DES_XEX3), BLOWFISH, TWOFISH

Misc. BASE64, HEX, URL URAW, USTRING (only available for $encode)

Page 11: 02-Security & Encryption-CPWR 2

11

$encode / $decode (2)$encode/$decode(Algorithm, Source{, Key{, Mode, IV}})Source:

Any text or raw data.

Key: Required for block ciphers and HMAC.

Should be a specific length.

AES (16/24/32), DES (8), TDES (24), DESX (24)

BLOWFISH (4 – 56), TWOFISH (16/24/32)

Page 12: 02-Security & Encryption-CPWR 2

12

$encode / $decode (3)$encode/$decode(Algorithm, Source{, Key{, Mode, IV}})Mode: Modes of operation

ECB, CBC, CFB, OFB, CTR, CBC_CTS

Default = ECB

IV: Initialization Vector Required for all modes except ECB.

Page 13: 02-Security & Encryption-CPWR 2

13

Notes

Because the return value may contain the null byte (0x00), $encode/$decode returns in the Uniface RAW data type which is binary safe, unless the Algorithm is BASE64, HEX, URL or USTRING, in which case a data is returned as the Uniface String data type (UTF-8).

Algorithm USTRING doesn’t convert the string from a character set to another.

Page 14: 02-Security & Encryption-CPWR 2

14

DEMO

Page 15: 02-Security & Encryption-CPWR 2

Agenda

Encode/encrypt – Decode/Decrypt– Hash functions

– Block ciphers

Calling webservices with a certificate

Page 16: 02-Security & Encryption-CPWR 2

Webservice Security

Server has a certificate – (Supplied by agency or self sign)

The webserver also has a certificate – Signed by the server certificate

Page 17: 02-Security & Encryption-CPWR 2

Webservice Security1. Client makes request to a secure webserver

2. Webserver accepts the connections and returns it’s certificate

3. Client verifies certificate is valid and trusted– Disabled checking with usys$sop_params ign=p

– Trusted certificates held in usys:ca-bunble.crt

– Certificate obtained from the website

Page 18: 02-Security & Encryption-CPWR 2

usys:ca-bundle.crtFormat for ca-bundle.crt

-----BEGIN CERTIFICATE-----

Certificate Data

-----END CERTIFICATE----- -----BEGIN CERTIFICATE-----

Certificate Data

-----END CERTIFICATE-----

Certificate Data is encoded Base-64 Encoded X.509 (PEM)

Page 19: 02-Security & Encryption-CPWR 2

ca-bundle.crt Trusted root certificates can be obtained from curl

– http://curl.haxx.se/ca/cacert.pem

Owner sends you their certificate Servers certificate can be obtained in IE by

– Request the URL– Click on the padlock icon– View the certificate– Click on the “Certification Path” tab and select the server certificate.– Click “View Certificate”– Click on the “Details” tab– Click on the “Copy to file…” button and click Next >– Select Base-64 Encoded X.509 (.CER) and click Next >– Enter a filename e.g. server.cer– If you have a ca-bundle.crt file in your usys folder, append the contents of server.cer to it in a text editor, otherwise copy to ca-bundle.crt.

– Click Finish

Page 20: 02-Security & Encryption-CPWR 2

20

DEMO

Page 21: 02-Security & Encryption-CPWR 2

Restrictions

Client certificates are due soon WS-security not currently supported

– Soap headers available from 3gl interface.

• soap_pre_request • soap_post_request

Page 22: 02-Security & Encryption-CPWR 2

Thank You& Questions