IPWorks Auth 2020 Python Edition

Questions / Feedback?

calculate_response Method

This method calculates the response to the given challenge.

Syntax

def calculate_response() -> None: ...

Remarks

This method calculates response to the given challenge.

Before calling this method set ocra_suite to the suite obtained from the other party and set challenge to the received challenge.

After setting ocra_suite the following properties are populated, which provide requirements for the response:

Inspect these properties to determine the requirements and provide any required values such as counter or password. Set key to the key used during the HMAC computation. Set challenge to the received challenge.

Call this method to calculate the response. After calling this method the response property is populated. The response may then be transmitted to the other party for verification.

The following properties are applicable when calling this method:

Random Challenge Example

//First create the challenge on machine A
Ocra ocra = new Ocra();
ocra.ChallengeType = OcraChallengeTypes.ctRandom;
ocra.ChallengeLength = 10;
ocra.ChallengeFormat = OcraChallengeFormats.cfNumeric;
ocra.CreateChallenge();

string challenge = ocra.Challenge; //Value like "3891592139"
string ocraSuite = ocra.OCRASuite; //Value "OCRA-1:HOTP-SHA1-6:QN10"
//Send Challenge and OCRASuite to Machine B

//Upon receiving the challenge on Machine B, calculate a response
ocra = new Ocra();
ocra.OCRASuite = ocraSuite; //Received from other party
ocra.Challenge = challenge; //Received from other party
ocra.Key = "shared secret key";
ocra.CalculateResponse();

string response = ocra.Response; //Value like "574464"
//Send Response back to Machine A

//Upon receiving the response on Machine A, verify it
ocra = new Ocra();
ocra.OCRASuite = ocraSuite; //Original OCRASuite saved before sending the original challenge
ocra.Challenge = challenge; //Original challenge that was sent
ocra.Response = response;   //Received from other party
ocra.Key = "shared secret key";

bool isValid = ocra.VerifyResponse(); //Returns True if verified
Signature Challenge Example
//First create the challenge on machine A
Ocra ocra = new Ocra();
ocra.ChallengeType = OcraChallengeTypes.ctSignature;
ocra.ChallengeInput = "test input";
ocra.Key = "signature key";
ocra.ChallengeFormat = OcraChallengeFormats.cfHex;
ocra.CreateChallenge();

string challenge = ocra.Challenge; //Value like "973131F0"
string ocraSuite = ocra.OCRASuite; //Value "OCRA-1:HOTP-SHA1-6:QH08"
//Send Challenge and OCRASuite to Machine B

//Upon receiving the challenge on Machine B, calculate a response
ocra = new Ocra();
ocra.OCRASuite = ocraSuite; //Received from other party
ocra.Challenge = challenge; //Received from other party
ocra.Key = "shared secret key";
ocra.CalculateResponse();

string response = ocra.Response; //Value like "574464"
//Send Response back to Machine A

//Upon receiving the response on Machine A, verify it
ocra = new Ocra();
ocra.OCRASuite = ocraSuite; //Original OCRASuite saved before sending the original challenge
ocra.Challenge = challenge; //Original challenge that was sent
ocra.Response = response;   //Received from other party
ocra.Key = "shared secret key";

bool isValid = ocra.VerifyResponse(); //Returns True if verified

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Auth 2020 Python Edition - Version 20.0 [Build 8155]