# TCCSecurity.cc

Summary

TCCSecurity.cc |
Functions |
f__calculateDigestResponse | Calculate digest response
f__calculateDigestHA1 | Calculate digest H(A1) hash
f__TCCSecurity__hex2char | Computes the 8 bit ASCII representation of an hexstring
f__calculateMD5 | Compute MD5 hash value
f__IMSAKA__f1 | Computes network authentication code MAC-A from key K, random challenge RAND, sequence number SQN and authentication management field AMF.
f__IMSAKA__f2 | Takes key K and random challenge RAND, and returns response RES.
f__IMSAKA__f3 | Takes key K and random challenge RAND, and returns confidentiality key CK.
f__IMSAKA__f4 | Takes key K and random challenge RAND, and returns integrity key IK.
f__IMSAKA__f2345 | Takes key K and random challenge RAND, and returns AK, CK, RES
f__IMSAKA__f5 | Takes key K and random challenge RAND, and returns anonymity key AK.
f__IMSAKA__f1star | Computes resynch authentication code MAC-S from key K, random challenge RAND, sequence number SQN and authentication management field AMF.
f__IMSAKA__f5star | Takes key K and random challenge RAND, and returns resynch anonymity key AK.
f__EAPSIM__A3A8 | Takes key Ki and random challenge RAND, and returns Kc and SRES keys
f__IMSAKA__calculateAUTN | Computes authentication token AUTN from anonymity key AK, random challenge RAND, sequence number SQN and authentication management field AMF.
f__calculateHMACMD5 | Calculate the HMAC MD5 value of a message with specified 64 bit key.
f__calculate__HMAC__MD5 | Calculate the HMAC MD5 value of a message with specified key.
f__calculate__HMAC__SHA1 | Calculate the HMAC SHA1 value of a message with specified key.
f__calculate128__EEA3 | Purpose: Encrypt TTCN-3 message using the confidentiality algorithm 128-EEA3
f__calculate128__EIA3 | Purpose: Calculate 32 bit message authentication code (MAC) using integrity algorithm 128-EIA3 for TTCN-3 message

### Functions

### f__calculateDigestResponse

#### Purpose

Calculate digest response

#### Parameters

nonce | in charstring - a server-specified data string which may ` be uniquely generated each time a 401 response is made
cnonce | in charstring - client nonce
user | in charstring - user name
realm | in charstring - user realm
passwd | in charstring - user password
alg | in charstring - a string indicating a pair of algorithms used to produce the digest and a checksum
nonceCount | in charstring - nonce count (8 hex digits)
method | in charstring - method (from the request)
qop | in charstring - qop-value: “”, “auth”, “auth-int”
URI | in charstring - digest URI
HEntity | in charstring - H(entity body) if qop=”auth-int”

#### Return Value

charstring | digest response

#### Errors

-

#### Detailed description

Support HTTP authentication (detailed description in RFC 2617) using uses one-way hash (md5) specified in RFC 1321. When a request arrives to server for an access-protected object, it responds an “401 Unauthorized” status code and a WWW-Authenticate header (encapsulate nonce and other necessary parameters). The client is expected to retry the request, passing an Authorization header with response field calculated with f_calculateDigestResponse().

Overview: http://en.wikipedia.org/wiki/Digest_access_authentication

### f__calculateDigestHA1

#### Purpose

Calculate digest H(A1) hash

#### Parameters

nonce | in charstring - a server-specified data string which may ` be uniquely generated each time a 401 response is made
cnonce | in charstring - client nonce
user | in charstring - user name
realm | in charstring - user realm
passwd | in charstring - user password
alg | in charstring - a string indicating a pair of algorithms used to produce the digest and a checksum

#### Return Value

charstring | digest response

#### Errors

-

#### Detailed description

Overview: http://en.wikipedia.org/wiki/Digest_access_authentication

### f__TCCSecurity__hex2char

#### Purpose

Computes the 8 bit ASCII representation of an hexstring

#### Parameters

hex | in <char*> - input value
str | out <char*> - output value

#### Return Value

-

#### Errors

-

#### Detailed description

-

### f__calculateMD5

#### Purpose

Compute MD5 hash value

#### Parameters

pszHashInput | in charstring - input value to compute hash of

#### Return Value

hashValue | out charstring - hexa hash value of input

#### Errors

-

#### Detailed description

-

### f__IMSAKA__f1

#### Purpose

Computes network authentication code MAC-A from key K, random challenge RAND, sequence number SQN and authentication management field AMF.

#### Parameters

pl__OP | in octetstring - the operator variant algorithm configuration field
pl__k | in octetstring - key
pl__rand | in octetstring - random challenge
pl__sqn | in octetstring - sequence number
pl__amf | in octetstring - authentication management field

#### Return Value

octetstring | network authentication code MAC-A

#### Errors

-

#### Detailed description

-

### f__IMSAKA__f2

#### Purpose

Takes key K and random challenge RAND, and returns response RES.

#### Parameters

pl__OP | in octetstring - the operator variant algorithm configuration field
pl__k | in octetstring - key
pl__rand | in octetstring - random challenge

#### Return Value

octetstring | response RES

#### Errors

-

#### Detailed description

-

### f__IMSAKA__f3

#### Purpose

Takes key K and random challenge RAND, and returns confidentiality key CK.

#### Parameters

pl__OP | in octetstring - the operator variant algorithm configuration field
pl__k | in octetstring - key
pl__rand | in octetstring - random challenge

#### Return Value

octetstring | confidentiality key CK

#### Errors

-

#### Detailed description

-

### f__IMSAKA__f4

#### Purpose

Takes key K and random challenge RAND, and returns integrity key IK.

#### Parameters

pl__OP | in octetstring - the operator variant algorithm configuration field
pl__k | in octetstring - key
pl__rand | in octetstring - random challenge

#### Return Value

octetstring | integrity key IK

#### Errors

-

#### Detailed description

-

### f__IMSAKA__f2345

#### Purpose

Takes key K and random challenge RAND, and returns AK, CK, RES

#### Parameters

pl__OP | in octetstring - the operator variant algorithm configuration field
pl__k | in octetstring - key
pl__rand | in octetstring - random challenge

#### Return Value

TCCSecurity_Keys typed value Errors: -

#### Detailed description

-

### f__IMSAKA__f5

#### Purpose

Takes key K and random challenge RAND, and returns anonymity key AK.

#### Parameters

pl__OP | in octetstring - the operator variant algorithm configuration field
pl__k | in octetstring - key
pl__rand | in octetstring - random challenge

#### Return Value

octetstring | anonymity key AK

#### Errors

-

#### Detailed description

-

### f__IMSAKA__f1star

#### Purpose

Computes resynch authentication code MAC-S from key K, random challenge RAND, sequence number SQN and authentication management field AMF.

#### Parameters

pl__OP | in octetstring - the operator variant algorithm configuration field
pl__k | in octetstring - key
pl__rand | in octetstring - random challenge
pl__sqn | in octetstring - sequence number
pl__amf | in octetstring - authentication management field

#### Return Value

octetstring | resynch authentication code MAC-S

#### Errors

-

#### Detailed description

-

### f__IMSAKA__f5star

#### Purpose

Takes key K and random challenge RAND, and returns resynch anonymity key AK.

#### Parameters

pl__OP | in octetstring - the operator variant algorithm configuration field
pl__k | in octetstring - key
pl__rand | in octetstring - random challenge

#### Return Value

octetstring | resynch anonymity key AK

#### Errors

-

#### Detailed description

-

### f__EAPSIM__A3A8

#### Purpose

Takes key Ki and random challenge RAND, and returns Kc and SRES keys

#### Parameters

pl__Ki | in octetstring - the shared key
pl__rand | in octetstring - random challenge
pl__sres | out octetstring - authentication result param
pl__Kc | out octetstring - encryption key

#### Return Value

-

#### Errors

-

#### Detailed description

-

### f__IMSAKA__calculateAUTN

#### Purpose

Computes authentication token AUTN from anonymity key AK, random challenge RAND, sequence number SQN and authentication management field AMF.

#### Parameters

pl__SQN | in octetstring - sequence number
pl__AK | in octetstring - anonymity key
pl__AMF | in octetstring - authentication management field
pl__MAC | in octetstring - encryption key

#### Return Value

octetstring | Authentication token - AUTN

#### Errors

-

#### Detailed description

-

### f__calculateHMACMD5

#### Purpose

Calculate the HMAC MD5 value of a message with specified 64 bit key.

#### Parameters

msg | in octetstring - message to be hashed
key | in OCT_64 - 64 bit key of the hash function

#### Return Value

octetstring | Hash value (16 octet - 128 bit)

#### Errors

-

#### Detailed description

- (should be kept because of backward compatibility reasons)
- HMAC() is an openssl specific function, should be found under openssl/hmac.h
- key can only be 64 bit (any other case please use f_calculate_HMAC_MD5)
- the length of generated hash value can only be 128 bit (any other case please use f_calculate_HMAC_MD5)

### f__calculate__HMAC__MD5

#### Purpose

Calculate the HMAC MD5 value of a message with specified key.

#### Parameters

pl_key | in octetstring - key of the hash function
pl_input | in octetstring - message to be hashed
pl_length | in integer - length of the output hash value (should be 16 in most of the cases)

#### Return Value

octetstring | Hash value

#### Errors

-

#### Detailed description

- HMAC() is an openssl specific function, should be found under openssl/hmac.h

### f__calculate__HMAC__SHA1

#### Purpose

Calculate the HMAC SHA1 value of a message with specified key.

#### Parameters

pl_key | in octetstring - key of the hash function
pl_input | in octetstring - message to be hashed
pl_length | in integer - length of the output hash value (should be 16 in most of the cases)

#### Return Value

octetstring | Hash value

#### Errors

-

#### Detailed description

- HMAC() is an openssl specific function, should be found under openssl/hmac.h

### f__calculate128__EEA3

Purpose: Encrypt TTCN-3 message using the confidentiality algorithm 128-EEA3

#### Parameters

key | in OCT__16 - confidentiality key
count | in OCT__4 - counter
bearer | in INT__5 - bearer identity
direction | in BIT__1 - direction of transmission
msg | in BIT__1__65504 - input bit stream (message to be encrypted)

#### Return Value

BIT__1__65504 | output bit stream (encrypted message)

#### Errors

-

#### Detailed description

-

### f__calculate128__EIA3

Purpose: Calculate 32 bit message authentication code (MAC) using integrity algorithm 128-EIA3 for TTCN-3 message

#### Parameters

key | in OCT__16 - integrity key key
count | in OCT__4 - counter
bearer | in INT__5 - bearer identity
direction | in BIT__1 - direction of transmission
msg | in BIT__1__65504 - input bit stream (the message)

#### Return Value

BIT__32 | message authentication code (MAC)

#### Errors

-

#### Detailed description

-