Smarx Cloud Security (WEB API) 4.0 White Paper
Purpose of this Solution: Online authentication for many fields of application (Premium or subscription services, updates and more), Access to content or administration panel only for authorized users
Version: WEB API 4.0
Last Update: 9 December 2013 by Steffen Kaetsch
Target Operating Systems: - Client: Windows 32 & 64 bit, Linux - Server with PHP, JSP or ASP.NET support Access to source code needed (of protection application): Yes No Supported Programming Tools/Environment: PHP, JSP or ASP.NET Applicable for Product: CRYPTO-BOX® SC / XS / Versa
Executive summary
Smarx® Cloud Security (WEB API) ensures only authenticated users who are in the possession of a valid
CRYPTO-BOX® hardware unit connected to the computer or in the network gain access to a web portal or any kind of content distributed via the Internet/Intranet.
There are many ways in which incorporating Smarx Cloud Security is smart and profitable for your business. Control that support is provided only for paying customers, allow access to content authorized only for service personnel, and much more.
Smarx Cloud Security offers the following possibilities: 1. Manage access to web content with the CRYPTO-BOX
2. Updating subscriptions and licensing information stored inside the CRYPTO-BOX
Smarx Cloud Security offers support for all popular web servers that support PHP, JSP or ASP.NET. The client site supports Internet Explorer, Chrome, Safari, Opera (Windows) and Firefox (Windows, Linux).
Table of Contents
1. Introduction to WEB API...6
2. How does WEB API work?...7
2.1. Client side ...7
2.1.1. Client knows PIN scenario: User Password (PIN/UPW) submission...8
2.1.2. Alternative scenario: Server knows PIN...8
2.2. Server side...8
2.2.1. Server side encryption...8
3. WEB API: General Requirements...9
3.1. Client side requirements...9
3.2. Server side requirements...10
4. Software Components...10
4.1. Client Component...10
4.1.1. Client Component for Microsoft Internet Explorer...11
4.1.2. Client Component for Firefox, Chrome, Safari, Opera...11
4.1.3. WEB API client setup...11
4.1.4. Client Diagnostic and Troubleshooting...11
4.2. Web Server application (ASP.NET or JSP or PHP based)...11
5. Developer’s Notes...12
5.1. Start building a Secure Server Solution...12
5.2. Handshake (sides authentication and verification, establishing secure connection)...12
5.2.1. Client knows PIN scenario...12
5.2.2. Server knows PIN scenario...13
5.3. WEB API: Client-Server Communication...13
5.4. WEB API: Client-Server Communication - Notifications...15
5.4.1. Microsoft Internet Explorer...15
5.4.2. Firefox, Chrome, Safari, and Opera...15
5.5. Web Security Client-Server communication chart...16
5.6. Server demo sample description...17
5.6.1. PHP demo sample module description...18
5.6.2. Java/JSP demo sample module description...19
5.6.3. ASP.NET demo sample module description...20
5.7. Login ...21
5.8. Verification ...23
5.9. DataObjects transaction generation...24
5.10. DataObjects transaction result proceeding...25
5.11. Error handling...25
5.11.1. Error messages generated by client...25
5.11.2. Special Case: Internet Explorer 10 and 11 on client side...25
5.11.3. Error messages generated by Web Security server...26
5.11.4. Errors generated by HTTP server or Tomcat...26
5.13. Client component...27
5.14. WEB API Server Side Source Code Samples...28
5.14.1. Generated HTML code for client side...28
5.14.2. PHP ...29
5.14.3. Java and Java Server Pages (JSP)...29
5.14.4. ASP.NET...30
5.14.5. Associated C# code to generate and control HTML form listed above...31
6. Contact and Support...32
1. Introduction to WEB API 6
1. Introduction to WEB API
Smarx® Cloud Security (WEB API) ensures only authenticated users (who are in the
possession of a valid CRYPTO-BOX) gain access to a web portal or any kind of content distributed via the Internet/Intranet.
There are many ways in which incorporating Smarx Cloud Security is smart and profitable for your business. Control that support is provided only for paying customers, allow access to content authorized only for service personnel, and much more.
Smarx Cloud Security offers the following possibilities: • Manage access to web content with the CRYPTO-BOX
This scenario is useful if you want to allow authorized users to view content only. When accessing the website it will look for a valid CRYPTO-BOX, depending on the status it will allow or deny access to the site.Furthermore, the content of the client’s CRYPTO-BOX can be used by Web applications (PHP-, JSP-, or ASP.NET-based) for making decision on providing access to various services to the client.
• Updating the CRYPTO-BOX
Smarx Cloud Security can also be used for secure transfer of information to the client's CRYPTO-BOX, and to update the CRYPTO-BOX. Unlike the Remote Update Management System (RUMS, part of the CRYPTO-BOX Protection Kit) there is no need to (manually) send the activation keys. Furthermore, with Online License Management defined update plans can be easily created via the Smarx Application Framework.
Smarx Cloud Security offers support for all popular web servers that support PHP, JSP or ASP.NET. The client site supports Internet Explorer, Chrome, Safari, Opera (Windows) and Firefox (Windows, Linux).
WEB API version 4.0 is based on Smarx® OS, so it’s compatible with other Smarx OS
programming interfaces and applications. Smarx OS base functionality is used by WEB API for:
• Establishing secure connection;
• Client authentication and transactions encryption;
• Reliable transaction mechanism, based on Smarx OS Data Objects (DO) API;
• Web Security Client shares Smarx OS SSO (Single Sign On) environment
2. How does WEB API work? 7
2. How does WEB API work?
2.1. Client side
WEB API contains two components: client’s component (end-user side) and web server component (server side). The client component is used to access the CRYPTO-BOX connected either to the local USB port of the computer or in the network (using CBIOS Network Server). It is implemented as a COM object for Microsoft Internet Explorer and as a plug-in for Mozilla Firefox, Google Chrome, Safari and Opera. The component receives requests (encrypted transactions) from HTML/JavaScript pages, generated by the remote server and downloaded by client’s browser. Requests are processed by client’s component and encrypted result of the transaction is sent back to the server.
Every Smarx® OS formatted CRYPTO-BOX contains client's private RSA key and distributor's
public RSA keys, which are used for the handshake - establishing secure connection and client authentication. In case of the CRYPTO-BOX SC all RSA operations are done in the hardware on the client site. In addition to hardware-implemented 128 bit Rijndael encryption, and software (Open SSL) 256 bit AES encryption are used to secure client-server
communication.
For more details about Web Security client-server handshake scenario, see chapter 5.2:
Handshake (sides authentication and verification, establishing secure connection).
Smarx Cloud Security (WEB API) version 4.0 supports two basic scenarios:
1) Client knows PIN: this scenario is common for various security applications, it assumes that the client side must provide the token (CRYPTO-BOX SC, XS or Versa) and enter valid PIN in order to “open” the token for further server side access - two factor local
authentication.
2) Server knows PIN: this scenario is specific for online distribution and license management, client side authentication is not important here. For this scenario the client side is only supposed to attach the valid token, while the server will open it remotely (by submitting valid PIN) for further access to token's secure data objects.
For software distribution and license management the “Server knows PIN” scenario has to be used, because exposing the PIN (User Password – UPW) of the CRYPTO-BOX to the user is not desired in that case.
2. How does WEB API work? 8
2.1.1. Client knows PIN scenario: User Password (PIN/UPW) submission
Local two-factor authentication requires CRYPTO-BOX User Password (PIN/UPW) to be submitted by the client. Further server side authentication (involving RSA
encryption/decryption) proceeds after the password is submitted.
2.1.2. Alternative scenario: Server knows PIN
This scenario is used mostly for web based distribution and license management, where client side authentication is not important. The alternative handshake scenario requires a CRYPTO-BOX XS or Versa with firmware 2.2 and higher, or a CRYPTO-BOX SC.
2.2. Server side
Smarx Cloud Security server side is supported for different environments:
• PHP (can be deployed on any server platform with PHP support: Win/FreeBSD/Linux, etc.); • ASP.NET technology (requires Win platform + IIS);
• Java/JSP (can be deployed on any server platform with Java/JSP support: Win32/FreeBSD/Linux/Sun Solaris, etc.);
NOTE: WEB API 4.0 is currently supported for PHP server environment only. WEB API 2.0 is available for ASP.NET and JSP/Java environments - support of WEB API 4.0 for these environments is under development.
For ASP.NET solution Windows is needed with IIS 6.0 or higher.
For Java/JSP solution – Jakarta Tomcat v4.1 or later is needed on server side. Various development tools, like Borland JBuilder can be used for server-side development.
For PHP solution, PHP 5.04 or later must be installed together with the following encryption libraries:
• php5-gmp, php5-mcrypt, php5-session for FreeBSD/Linux; • mcrypt.dll, bcmath.dll for Win32;
2.2.1. Server side encryption
Server side encryption required by Web Security includes: 1024 bit RSA, 128 bit AES (hardware-based Rijndael encryption with the CRYPTO-BOX) and 256 bit AES (Open SSL).
2. How does WEB API work? 9
WEB API (Smarx Cloud Security) general architecture
3. WEB API: General Requirements
This section describes the requirements for client and server side.
3.1. Client side requirements
• Hardware: Smarx OS formatted CRYPTO-BOX SC, XS or Versa, CRYPTO-BOX firmware 2.2 or higher is requires for “Server knows PIN” login scenario);
• Driver: CRYPTO-BOX driver must be installed for CRYPTO-BOX access on the client site (this driver is included to WEB API client setup or can be installed directly with CBUSetup or Windows Update);
NOTE: Driver is not required on local computer in case of network access
• Client component - installed via WEB API client setup (see chapter 4.1.3) or Google Play (Chrome only):
o SMRXWEB COM-object for Microsoft Internet Explorer; o npWebSec plug-in for FireFox, Chrome, Safari and Opera;
3. WEB API: General Requirements 10
• Single Sign On environment (for “Client knows PIN” scenario, optional);
• Operation System/Browser:
o Windows (32 and 64bit): Microsoft Internet Explorer 7 or higher, Firefox 3.6 or
higher; up-to-date versions of Chrome, Safari, Opera
o Linux: Firefox
o Mac OS X: Safari (currently under development)
3.2. Server side requirements
• Application: Customized Web application (PHP, Java/JSP or ASP.NET based)
• Web Server with PHP support:
o OS: Windows, Linux, FreeBSD or any other PHP enabled system o Apache, Xitami, IIS, PWS, ...
o PHP 5.04 or later
o Encryption libraries (php5-gmp, php5-mcrypt, php5-session for
FreeBSD/Linux; mcrypt.dll, bcmath.dll for Win32
• Web Server with ASP.NET support:
o OS: Windows 8/7/Vista/XP/Server 2008 o IIS 6.0 or higher
• Web Server with JSP support:
o OS: Windows, Linux, FreeBSD or any other JSP/Java enabled system o Apache, IIS, …
o Jakarta Tomcat v4.1 or later o Java JDK v1.4.2 or later
o Unlimited Strength Java(TM) Cryptography Extension (JCE) Policy Files for the
Java(TM) 2 SDK, Standard Edition, v 1.4.2 (J2SDK).
4. Software Components
4.1. Client Component
Depending on the browser used client component can be either COM-object (when using Microsoft Internet Explorer) or dynamic library plug-in when usinh Firefox, Chrome, Safari, or Opera. It provides direct access to the CRYPTO-BOX from the browser. Requests generated on the server side are encrypted and MIME-encoded, embedded into HTML/JavaScript page. They will be sent to the client's browser, where they are decrypted and executed by the WEB API client component. Transaction results are encrypted, MIME-encoded and sent back to the server.
4. Software Components 11
4.1.1. Client Component for Microsoft Internet Explorer
Consists of client side COM-object (SMRXWEB.EXE) and helper dynamic library (SMRXWEBNOTIFY.dll).
4.1.2. Client Component for Firefox, Chrome, Safari, Opera
Consists of Firebreath plug-in (npWebSec.DLL).
4.1.3. WEB API client setup
The easiest way to install the client component is to use the WEB API client setup. It installs the CRYPTO-BOX drivers for Windows 32/64 and the WEB API client component, depending on the installed browser type (COM object for Internet Explorer or plug-in for Firefox, Chrome, Opera and Safari).
The latest version of the WEB API client setup can be found on our website:
www.marx.com Support Downloads Driver and Diagnostic Tools.→ → →
4.1.4. Client Diagnostic and Troubleshooting
You can use MARX Analyzer diagnostics as well as Web API online diagnostic to check/troubleshoot your client configuration.
MARX Analyzer can be downloaded from our website:
www.marx.com Support Downloads Driver and Diagnostic Tools.→ → →
For WEB API online diagnostic please visit:
www.marx.com/webapi-check.
4.2. Web Server application (ASP.NET or JSP or PHP based)
The server side application, loads the Distributor Private RSA key and Client Public RSA key from binary profile files, obtained from MARX. Client Private RSA key and Distributor Public RSA key are pre-programmed to the CRYPTO-BOX by MARX at the production stage. The usage of these RSA key-pairs (unique for each MARX customer) allows client side CRYPTO-BOX authentication (proving that this CRYPTO-CRYPTO-BOX belongs to the customer) and to organize encryption/decryption of commands. All sensitive information have to be stored securely on server-side in the private area.
After successful authentication, a session-unique 128-bit AES Rijndael key is generated randomly and programmed into the CRYPTO-BOX unit of the client. All further commands (transactions requests and results) are encrypted/decrypted with transaction-unique 256-bit AES Rijndael key. This key in turn is transferred, being encrypted with hardware 128-bit AES Rijndael key, stored in the CYPTO-BOX of the client and known to the server site.
5. Developer’s Notes 12
5. Developer’s Notes
5.1. Start building a Secure Server Solution
This section describes steps of your own Web Security solution development. What do you need for this? Server and client requirements are described in the section 3.
The client side components and WEB API client setup setup were already described in section 4.1.
The end-user management (user profiles) and server side development will be described in further sections of this document.
5.2. Handshake (sides authentication and verification, establishing
secure connection)
5.2.1. Client knows PIN scenario
For the “Client knows PIN” scenario client-server authentication is performed using the Distributor's and Client's RSA key pairs (1024 bit strength), so that both sides are considered to be trusted.
If the CRYPTO-BOX SC model is used, all RSA operations are hardware implemented which increases security on the client side.
When loading the login page, the Server generates a random SessionID. This SessionID is sent to the Client, encrypted with the client’s RSA public key (known to distributor’s side) and digitally signed by the distributor’s RSA private key. Only having a CRYPTO-BOX unit with valid RSA keys (Client’s private and Distributor’s public), the SessionID can be successfully decrypted by the Client side. During this process both sides (Client and Server) are verified. After that, a random Session Key value (128-bit Rijndael key) is generated on the Client side and submitted to the CRYPTO-BOX. The CRYPTO-BOX token S/N, (optionally model, memory size, etc…) is encrypted with this Session Key and the Session Key itself is encrypted with Distributor’s RSA public key and digitally signed with Client’s RSA private key. This package is sent back to the server. Only trusted server side can decrypt the Session Key and obtain the CRYPTO-BOX information.
Finally, both sides are considered as verified and trusted and ready for secure
communication. For further secure transactions the Session Key (known to both sides) is used for encryption and SessionID is sent unencrypted.
5. Developer’s Notes 13
5.2.2. Server knows PIN scenario
The alternative handshake scenario (“Server knows PIN”) is a little bit different. In addition to Distributor/Client’s RSA key pairs, Server side also knows the hardware Fixed Key (128-bit Rijndael key), CRYPTO-BOX User Password (PIN) and/or Administrative Password (APW). Those values are provided by MARX in binary files.
If you did not receive the binary files for your CRYPTO-BOX required for the “Server knows PIN” scenario, please contact MARX to obtain them.
The end-user (client), accessing web login page, does not require to submit the PIN value. Instead the Server sends SessionID and PIN/APW, encrypted with the hardware Fixed Key. Only having a proper CRYPTO-BOX attached, the PIN can be decrypted and used for further CRYPTO-BOX access, including RSA key pairs verification.
After that, a random Session Key value (128-bit Rijndael key) is generated on the client side and submitted to the CRYPTO-BOX. The CRYPTO-BOX S/N, (optionally model, memory size, etc…) is encrypted with this session key and the session key itself is encrypted with
Distributor’s RSA public key and digitally signed with Client’s RSA private key. This package is sent back to the server.
5.3. WEB API: Client-Server Communication
After a secure connection is established, the server side can submit encrypted requests to be processed by the client side: get/update information in the internal memory of the CRYPTO-BOX . The results of the request are encrypted and returned to the server.
WEB API is based on Smarx OS Data Objects API. Every request contains the following data fields:
• App ID (partition number #999 is used for online demo);
• Memory zone (RAM1/RAM2/RAM3);
• Administrator Password (reserved for future customer specific implementations);
• Memory Offset
• Data Object Type (Expiration Date, Counter, Memory Object, etc...)
• Data Object Size (for Memory Object)
• Data Object Action
• Extra Parameters (reserved)
Each transaction request is encrypted with randomly generated Transaction Key (256 bit AES). The Transaction Key in turn is encrypted with the Session Key (obtained during client-server handshake and valid for all transactions of current session).
On the client side transaction request is decrypted using hardware Session Key and then software Transaction Key. After this, the request is executed. The result of the transaction
5. Developer’s Notes 14 and/or the error code is encrypted with a newly generated Transaction Key, which is
encrypted in turn with the Session Key and the result of transaction is sent back to the server. The transaction result is decrypted on the server side and used for further server side
processing.
Executing Data Object command (by the client) implies forming request and analyzing result (returned by the client) by the server side code. Forming request consists of calling the following sequence of methods on PHP/JSP/ASP.NET page:
1. call Command constructor;
2. submit DO transaction by calling submitDOCommand(Command command) 3. commit DO transaction by calling commitDOCommand()
There are two constructors used to initialize DO command:
public Command(short sPartitionId, // application partition Id
int iDOId, // Data Object Id
int iDOType, // Data Object type int iDOOperation, // Data Object operation
int iRAMBank, // RAM bank (RAM1 = 1, RAM2 = 2, RAM3 = 3) int iOffset, // offset in application partition int iReserved); // reserved
and:
public Command(short sPartitionId, // application partition Id int iDOId, // Data Object Id
int iDOType, // Data Object type
int iDOOperation,// Data Object operation
int iRAMBank, // RAM bank (RAM1 = 1, RAM2 = 2, RAM3 = 3) int iOffset, // offset in application partition
byte []bDOData, // Data Object data int iDOSize, // Data Object data size int iReserved); // reserved
First is used to form most of the DO commands, the second to form DO commands performing reading/writing to/from the internal CRYPTO-BOX memory.
For detailed information on Data Objects API, please refer to the Smarx Compendium, chapter 13 and the DO API Reference.
To analyze DO command results returned by the client the:
proceedExecuteResults(String executeResult, ArrayWraper result) is called on the next PHP/JSP/ASP.NET page.
Where:
executeResult – MIME string returned by the client;
5. Developer’s Notes 15 If the method returns non-zero, error took place during DO command execution. Error code can be further analyzed by calling getErrorMessage(int errCode).
5.4. WEB API: Client-Server Communication - Notifications
To receive notifications on CRYPTO-BOX attachment/detachment the following technique can be used.
5.4.1. Microsoft Internet Explorer
Notifications can be handled with WSNOTIFIER (SMRXWEBNOTIFY.dll) object implemented by the following code:
<OBJECT ID='WSNOTIFIER' CLASSID='CLSID:852B5BF4-0C53-4A83-BD04-1B4B632A0D30'/> The following API calls can be used to enable notifications:
WSNOTIFIER.attachEvent('BoxAttached',handlerA); WSNOTIFIER.attachEvent('BoxRemoved',handlerR);
where handlerA, handlerR – javascript handler-functions describing attachment/detachment reaction.
Example:
<script language='javascript'> function handlerR()
{
alert('Your CRYPTO-BOX is removed! Please, attach CRYPTO-BOX.'); }
if(navigator.appName.substring(0,9) == "Microsoft") {
document.write("<OBJECT ID='WSNOTIFIER' CLASSID='CLSID:852B5BF4-0C53-4A83-BD04-1B4B632A0D30'></OBJECT>");
WSNOTIFIER.attachEvent('BoxRemoved', handlerR); }
</script>
5.4.2. Firefox, Chrome, Safari, and Opera
The following API calls can be used to enable notifications: WEBSEC.addEventListener("BoxRemoved",HandleR,true); WEBSEC.addEventListener("BoxAttached",HandleA,true);
where HandleA, HandleR – javascript handler-functions describing attachment/detachment reaction (and WEBSEC is plugin object).
Example:
<script language='javascript'> function handlerR()
{
alert('Your CRYPTO-BOX is removed! Please, attach the CRYPTO-BOX.'); }
5. Developer’s Notes 16 if(navigator.appName.substring(0,8) == "Netscape")
{
WEBSEC.addEventListener('BoxRemoved', handlerR, true); }
</script>
5.5. Web Security Client-Server communication chart
Smarx®OS Cloud Security Client-Server Communication Chart
Generate SessionID Encrypt SessionID
Handshake Header (SessionID) public RSA Token
signed w/Distributor’s private RSA
Decrypt SessionID Generate Session Key
Submit Session Key Get PIN (UPW)
Encrypt Token Info Encrypt Session Key
Handshake Header SessionID (Session Key) Public RSA Distr
(Token Info) SessionKey signed w/Client’s private RSA
Decrypt Session Key
Session ID is associated with current session Decrypt Token Info
Prepare Request Generate Transaction Key
Encrypt Request Encrypt Transaction Key
Transaction Header SessionID (Transaction Key) Session Key
(Request) Transaction Key
Transaction Header SessionID (TransactionKey) SessionKey
(Transaction Result) TransactionKey
Server side Client side (CRYPTO-BOX)
Decrypt TransactionKey Decrypt Transaction Result
Proceed Request Generate new Transaction Key
Encrypt Transaction Results Encrypt Transaction Key
Proceed Transaction Result Server side
Client side
(CRYPTO-BOX) SessionIDsession transactions - unique Session ID, generated on server side for further recognition of this Session Key - 128 bit AES/Rijndael key, generated on client side and submitted into the CrypToken for hardware encryption, valid for this session (all its transactions) Transaction Key - 256 bit AES/Rijndael key, generated for software encryption, valid for encrypting/decrypting of transaction’s request or result package.
Digitally sign
Digitally sign Verify signature
Verify signature
Copyright © 2002,2013 MARX® CryptoTech LP
Smarx Cloud Security (WEB API) Client-Server communication chart for “Client knows PIN” scenario
5. Developer’s Notes 17
Smarx®OS Cloud Security Client-Server Communication Chart
Generate SessionID
Encrypt SessionID
Handshake Header (SessionID) Fixed Key signed w/Distributor’s private RSA
Decrypt SessionID Generate Session Key
Submit Session Key Encrypt Token Info Encrypt Session Key
Handshake Header SessionID (Session Key) Public RSA Distr
(Token Info) SessionKey signed w/Client’s private RSA
Decrypt Session Key
Session ID is associated with current session Decrypt Token Info
Prepare Request Generate Transaction Key
Encrypt Request Encrypt Transaction Key
Transaction Header SessionID (Transaction Key) Session Key
(Request) Transaction Key
Transaction Header SessionID (TransactionKey) SessionKey
(Transaction Result) TransactionKey Server side
Decrypt TransactionKey Decrypt Transaction Result
Proceed Request Generate new Transaction Key
Encrypt Transaction Results Encrypt Transaction Key
Proceed Transaction Result Server side (knows PIN)
Client side (CRYPTO-BOX)
SessionID - unique Session ID, generated on server side for further recognition of this session transactions
Fixed Key - 128 bit AES/Rijndael key, programmed in CRYPTO-BOX and known to server-side, used for secure UPW/APW transmission during handshake
Session Key - 128 bit AES/Rijndael key, generated on client side and submitted into the CRYPTO-BOX for hardware encryption, valid for this session (all its transactions) Transaction Key - 256 bit AES/Rijndael key, generated for software encryption, valid for encrypting/decrypting of transaction’s request or result package.
Digitally sign
Digitally sign Verify signature
Verify signature
Copyright © 2002,2013 MARX® CryptoTech LP Encrypt UPW/APW
Decrypt UPW/APW
(UPW / APW) Fixed Key
(Alternative handshake)
Submit UPW/APW
Client side (CRYPTO-BOX)
Smarx Cloud Security (WEB API) Client-Server communication chart for “Server knows PIN” scenario
Files, containing Distributor RSA Private key and Client RSA Public Key for the Demo
CRYPTO-BOX (part of the CRYPTO-BOX Evaluation Kit) are included to the sample code and can be used for testing (sample.d.prv.bin and sample.c.pub.bin). Key files for customer specific CRYPTO-BOX units will be provided when buying WEB API.
5.6. Server demo sample description
The data exchange between server and client is performed the following way: The server generates pages, with client component calls, embedded into JavaScript. The encrypted transaction string, transformed into MIME64 format is transmitted as parameter for
component functions. The result of client execution is also an encrypted string, which is sent to the server as form field value, using POST method.
Below is a description of the modules contained in the different samples available for the server site (PHP, JSP, ASP.NET).
5. Developer’s Notes 18
5.6.1. PHP demo sample module description
PHP classes:
WebSec.php - WebSec main class.
AuthStr.php - authorization string class. (is used to handle authorization)
BCMath.php - provides set of math functions, which are used by RSA.php under
Win32 platform
GMP.php - provides set of math functions, which are used by RSA.php under
FreeBSD platform
Command.php - Data Object Command class. (describes Data Object operation to
be performed)
Constants.php - constants class
CryptParam.php - cryptographic parameters loader (loads RSA keys)
DOCommandResults.php - Data Object command result class. (proceeds results of Data
Object operation returned by client)
DOCreateTransactStr.php - exception class
JSTag.php - class is used to generate client side JavaScript code
Rijndael.php - CRYPTO-BOX® compatible Rijndael implementation
RSA.php - CRYPTO-BOX® compatible RSA implementation
StringHeader.php - common header used to wrap/unwrap authorization and
transaction string
Token.php - contains information on current Token
Tools.php - used to perform data conversions
TransactStr.php - class is used to securely wrap/unwrap DO operation data
WrongPwdLength.php - exception class
Sample:
activation.php - activates CRYPTO-BOX previously bound to client's computer
bindingResult.php - displays binding results
footer.php - contains copyright information
header.php - contains WEB API online demo tabs
how_to_use.php - contains instructions on sample evaluation scenario
5. Developer’s Notes 19
texteditor.php - displays Text editor demo application (example for an application
which can be used only if a valid CRYPTO-BOX is attached to the client's computer).
texteditor_read_only.php - displays Text editor in read-only mode
transaction.php - displays transaction results, read from the client's
CRYPTO-BOX®:
1. Displays full information about the client, 2. Shows the number of visits
3. Displays the last visit date and time (including time zone)
verifyresult.php - validates the handshake results. In case of successful validation
it prepares further sample transactions: 1. Get client info
2. Increment visit counter 3. Get the counter value 4. Get last visit date
5. Update the last visit date
websechelp.html - help file with brief info about the WEB API Online Demo
jquery-1.5.2.min.js - JavaScript library
notifications.js - checks CRYPTO-BOX presence after log process. In case the
CRYPTO-BOX was removed, it processes an auto-logout The sample demonstrates the following steps of client authentication, transaction:
[hardware selection] login client and binding details (verifyresult, transaction)→ →
Furthermore, the sample demonstrates the following features: • ajax web development techniques
• network or local hardware selection, including support for FEST (allows testing of core features of the CRYPTO-BOX system without the need to a physical CRYPTO-BOX – ideal for immediate testing)
• license management via WEB API (including binding & activation)
The brief functionality and design of each page is described starting with chapter 5.7. See WEB API reference documentation (contained in the /doc subfolder of the WEB API package) for a detailed description of the PHP classes.
5.6.2. Java/JSP demo sample module description
Java packages:
5. Developer’s Notes 20
com.marx.jsmrxweb.crypt - encryption algorithms
com.marx.jsmrxweb.exception - exceptions
com.marx.jsmrxweb.Script - HTML/JavaScript tags generation
com.marx.jsmrxweb.transaction - transaction generation/processing
com.marx.jsmrxweb.util - service classes
org.bouncycastle.crypto - encryption algorithms**
org.bouncycastle.util.encoders - service classes**
** - some modified and original encryption services, developed by The Legion Of The Bouncy Castle (www.bouncycastle.org) are used.
Sample:
login.jsp - login page
verifyresult.jsp - CRYPTO-BOX® verification page
transaction.jsp - transactions page (client info)
securityviolation.jsp - transaction exception page
servererror.jsp - server error page
The sample demonstrates the following steps of client authentication, transaction:
login.jsp verifyresult.jsp transaction.jsp→ →
If a transaction error occurs, it is processed on servererror.jsp page.
The brief functionality and design of each page is described starting with chapter 5.7. See WEB API reference documentation (contained in the /doc subfolder of the WEB API package) for detailed description of Java packages/classes.
5.6.3. ASP.NET demo sample module description
\WebSec.sln - Smarx Cloud Security ASP.NET solution
\Web.config - Web configuration
1. WebSec project
\WebSec\*.* - Smarx Cloud Security sample files
\WebSec\bin\*.* - Dll files
5. Developer’s Notes 21 \WebSec\data\ *.* - RSA demo key files
\WebSec\netsetup\*.* - ASP.NET client diagnostic files
\WebSec\pics\*.* - sample images files
2. WebSec.Cryptography project
\WebSec.Cryptography\*.* - Smarx Cloud Security Cryptography files \WebSec.Cryptography\bin\*.* - Dll files
\WebSec.Cryptography\RSA\*.* - Dll files
The sample demonstrates the following steps of client authentication, transaction:
Login.aspx VerifyResult.aspx Transaction.aspx → →
The brief functionality and design of each page is described starting with chapter 5.7. See WEB API reference documentation (contained in the /doc subfolder of the WEB API package) for detailed description of the ASP.NET solution.
5.7. Login
The login page is the start page of the sample. It is generated by the server-side, using com.marx.jsmrxweb.WebSec class functions: getHTMLHeader(), getMozillaCode(), getHandshakeCode(), getHidePwdEntry(), getHandshakeSubmitButton() (see WEB API reference documentation package for details).
On this page client needs to submit password (if it was not submitted before). There should be input fields on this form holding client command execution results to be sent back to the server.
<form name="form1" method="post" action="verifyresult.jsp"> <input type="password" name="password" value="demo">
The password value is obtained from this input field.
The “handshake” code getting information about the CRYPTO-BOX, attached to the client computer and doing CRYPTO-BOX verification is also embedded. The results of the handshake process are sent to the server.
<input type="hidden" name="WEBSECHandshakeResult" value="-">
<input type="submit" name="websecsubmit" value="Login" onClick=' return doHandshake(this.form);'>
<script language='javascript'> function doHandshake(frm) { if(WEBSEC==null) {
5. Developer’s Notes 22 alert("SMRXWEB ActiveX is not installed !");
return false; }
else if(navigator.appName.substring(0,8) == "Netscape"){ alert("WEB API compatible browser plugin is NOT installed!"); return false;
} } else {
if (WEBSEC.isSSOInstalled()){ var ret = WEBSEC.SSOLogin();
if (ret == 0x05) {alert("No CRYPTO-BOX® was detected. \nPlease attach valid CRYPTO-BOX® and try again"); return false;} else if (ret == 0x0A) {alert("This CRYPTO-BOX® is not supported. \nPlease attach valid CRYPTO-BOX® and try again"); return false;} else if (ret == 0x09) {alert("Detected CRYPTO-BOX® is not formatted. \nPlease attach valid CRYPTO-BOX® and try again"); return false;} else if (ret == 0x0B) {alert("Detected CRYPTO-BOX® does not contain valid partition. \nPlease attach valid CRYPTO-BOX® and try again"); return false;}
else if ((ret != 0x04) && (ret != 0x07) && (ret != 0)) alert("Error logon to CRYPTO-BOX®. \nPlease try again. \nContact your vendor if problem persists");
if (ret != 0) return false; }
else{
var ret = WEBSEC.WebLogin(frm.password.value);
if (ret == 0x20001) alert("No CRYPTO-BOX® was detected. \nPlease attach CRYPTO-BOX® and try again");
else if (ret == 0x20003) alert("This CRYPTO-BOX® is not supported. \nPlease attach valid CRYPTO-BOX® and try again");
else if (ret == 0x20004) alert("Detected CRYPTO-BOX® is not formatted. \nPlease attach valid CRYPTO-BOX® and try again"); else if (ret == 0x20006) alert("Detected CRYPTO-BOX® does not contain valid partition. \nPlease attach valid CRYPTO-BOX® and try again");
else if (ret == 0x20008) alert("You have entered wrong password. \nPlease try again");
else if (ret != 0) alert("Error logon to CRYPTO-BOX®. \nPlease try again. \nContact your vendor if problem persists");
if (ret != 0) return false; } frm.WEBSECHandshakeResult.value = WEBSEC.Handshake('AgEAAAAAEAEAAAB1 HrB4qNucxXW5ogMZeApgjaeB5gvUkusEk3934jABBQAAAIAAAADK62/fSNmGsX0zEIplIQlsbwic1cxcq h5lA7TjbSxKbXokZRhYINsnKl7a6GKPGLUj4qMQ9ehA5lri8rH5KAFOrgQ5ZU9iZFER2GXLr3L4gJeuK5 riQTbTXmvozyhPKkIQZv0B0Vf6jdpxE/NqgRlr6ubzLTiwVBx5pbVDiwf6uBAAAACAAAAATLaOkmmkQpE U+FSwfCrL1QtV2LX1JA78vcT3Mw7FkOsojGc6+JDivHzEuT5DzPeFlRchNx5ZbFzGVx4RxlwFomGheOBq eWuAyX8OnyCQgHq1rQMhnUvZqb1xPjwvfGJ+Ahu2XXmxFt8qEy7WCqYKjDp2NzOsFj0sNAwLJRocQFM=' ); } } </script>
After the “Login” button is clicked, the handshake code is executed and the handshake result (form.WEBSECHandshakeResult) is sent to the server. The server receives and processes this data. If the CRYPTO-BOX was successfully verified the verification page is generated.
5. Developer’s Notes 23 For the demo sample, each demo-formatted CRYPTO-BOX matches (sample files contain demo values of Distributor RSA Private Key and Client RSA Public Key, used for verification). However in your own solution – it’s a good idea to limit number of matching units with unique criteria, for instance the serial number of the CRYPTO-BOX. In this case verification can only be continued if the end-user has a CRYPTO-BOX with the proper Serial Number (this information has to be stored on the server side).
5.8. Verification
Verification page contains information about the CRYPTO-BOX, found on client-side and result of its verification. Handshake results are preceded, using com.marx.jsmrxweb.WebSec class function: proceedHandshakeResults() (see WEB API reference documentation for details).
<%@ page errorPage="servererror.jsp"
import="com.marx.jsmrxweb.transaction.Command, com.marx.jsmrxweb.util.*, com.marx.jsmrxweb.exception.DOCreateTransactStr"%>
<%
// logout / restart if needed
if((request.getParameter("cancel") != null) | (request.getParameter("logout") ! = null)) {
websec = null;
session.invalidate();
response.sendRedirect("login.jsp"); }
// go to error page if cbweb bean does not exist if(websec == null) {
%>
<jsp:forward page="servererror.jsp">
<jsp:param name="message" value="WebSec bean is null!" /> </jsp:forward>
<% }
// handle security violations
if(websec.getState() < websec.STATE_VERIFYRESULT) { websec.setState(websec.STATE_LOGIN);
%>
<jsp:forward page="securityviolation.jsp">
<jsp:param name="error" value="invalid session" />
<jsp:param name="description" value="All stages of login and authentication must be passed from the beginning.<br>Please note that after a certain time of inactivity, a time out occures and the session becomes invalid." />
</jsp:forward> <%
}
String handshakeResults = request.getParameter("WEBSECHandshakeResult"); int r = websec.proceedHandshakeResults(handshakeResults);
if(r != 0){
websec.setState(websec.STATE_LOGIN); %>
<jsp:forward page="securityviolation.jsp">
<jsp:param name="error" value="varification failed" />
<jsp:param name="description" value="User was not authenticated" /> </jsp:forward>
5. Developer’s Notes 24 <%
}
// set bean to the next state
websec.setState(websec.STATE_TRANSACTION); websec.setVerified(true);
%>
If the CRYPTO-BOX was verified successfully, server and client sides are ready to execute memory transactions. However client can break connection by clicking the “Logout” button, and return to the start page.
If none of the attached CRYPTO-BOX units was verified (encryption key pairs don’t match), a page with an error message is generated, informing that client was not verified. If client was not verified, all further work with the CRYPTO-BOX is terminated.
5.9. DataObjects transaction generation
Scripts necessary for CRYPTO-BOX DataObjects transactions are only generated after successful CRYPTO-BOX verification. com.marx.jsmrxweb.transaction.Command class and the following functions of com.marx.jsmrxweb.WebSec class are used on server side for page generation:
submitDOCommand(), commitDOTransact(), getTransactionBoxSubmitButton(). <form name="form1" method="post" action="transaction.jsp">
<input type="hidden" name="WEBSECExecuteResult" value="-">
<input type="submit" name="websecsubmit" value="Client details" onClick=' return doTransaction(this.form);'>
<script language='javascript'> function doTransaction(frm) { if(WEBSEC==null) {
if(navigator.appName.substring(0,9) == "Microsoft") { alert("SMRXWEB ActiveX is not installed !");
return false; }
else if(navigator.appName.substring(0,8) == "Netscape"){
alert("WEB API compatible browser plugin is NOT installed !"); return false; } } else { frm.WEBSECExecuteResult.value = WEBSEC.Execute('AgIAAAAAEQEAAAA tkm8nyR2BxtrzF5K8umd3eeq0ugHjI8xppa6qma0YBQAAAGRueIKMEAAAACAAAAAwAAAAyKUSDw11PDNo Zqcoe8p1EJLSYmga9Dut+OqGD3QdVP7HsC0ORtfuw4f4cV2ulmUkEAAAAIAAAABfGPvIz5oLegvTM/uJP jsG89uYAYoHiN0ZSstr5uetiyPt2ABICJF/sxFNBXQwzaa/zSdSms3xxhWxEvr6ALqgd8kwOo7iuiPo+v dnAsU8i6JkBpgoPLOmElc/z50LPjfongQv3Aq86786OddUXBjQmCzNooY3Kd00QlMRUgJUXkAAAADe9xt /WiSiU6NhpIzzSfQMGKoQoCfsqtiJNU1YXVv8uOnRhfFzkKgxA+HW+bI0hy+lYm00NGZj4RRJwcC+AyQj '); } } </script>
5. Developer’s Notes 25 The result of transaction execution is sent back to the server with the
form.WEBSECExecuteResult field.
5.10. DataObjects transaction result proceeding
The transaction page is generated as the result of transaction execution on client side. getHTMLHeader(), getMozillaCode()and proceedExecuteResultsfunctions of
com.marx.jsmrxweb.WebSec class are used on server side for page generation – see WEB API reference documentation (contained in the /doc subfolder of the WEB API package) for details.
5.11. Error handling
Java and JSP mechanisms are used to control errors on server side. Here is a list of the most probable errors and how they are handled:
5.11.1. Error messages generated by client
The result of transaction contains an error code, if an error occurs on the client side. The return code can be used with the getErrorMessage() method to get an error description. It is a customers’ decision how to handle erroneous situation – either the last page should be generated again or any other steps should be taken (i.e. to alert the system administrator, to lock the account, to redirect the client to the NetSetup or driver’s update page, ..). Some errors should be processed locally on client-side, displaying alert messages (for example – check if compatible CRYPTO-BOX is attached, etc…)
5.11.2. Special Case: Internet Explorer 10 and 11 on client side
Starting with Internet Explorer 10, Microsoft has changed the logic of AJAX post processing. A discussion about this issue can be found here:
http://stackoverflow.com/questions/11235613/jquery-ajax-post-not-working-ie10
As suggested in the above discussion the problem can be fixed with adding the following string to the code:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" >
With the Internet Explorer released in November 2013, Microsoft changed the way the browser is detected. When being asked about its type, the Internet Explorer 11 does not identify itself as MSIE type browser (Microsoft standard definition for previous Internet Explorer versions). Instead it defines itself as a Gecko-type browser.
This issue was addressed with the following series of changes in our WEB API sample code (PHP and JSP):
5. Developer’s Notes 26
• index.php and \classes\JSTag.php:
if(navigator.appName.substring(0,9) \"Microsoft\") was replaced with:
if(navigator.userAgent.indexOf('Trident') > -1)
• \netsetup\netsetup-???.php:
if((strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "msie")=false was replaced with:
strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "trident")===false
• \netsetup\BrowserUtils.php:
else if (false !== strpos($userAgent, 'Trident')) was changed to:
else if (false !== strpos($userAgent, 'MSIE '))
If you are integrating WEB API code using iframe, the IE9 compatibility mode can be enforced from within iframe window by including this string:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" > to the parent page containing iframe.
More details can be found in this discussion:
http://stackoverflow.com/questions/3717932/will-an-iframe-render-in-quirks-mode
5.11.3. Error messages generated by Web Security server
In case of erroneous situation on the server side, the server will log all the errors to stderr using System.err.println(). If there are some problems with the server part of this solution, look through the log files of Tomcat.
5.11.4. Errors generated by HTTP server or Tomcat
There is always the possibility that errors occur on JSP server level. If problems persist even after a server restart, it is recommended to check the server configuration files (server.xml for Tomcat) and to monitor the log files of Tomcat and the HTTP server.
5. Developer’s Notes 27
5.12. WEB API reference documentation
Please refer to the JavaDoc-generated WEB API reference documentation package, which reflects the most up-to-date Java classes (see /doc subfolder in the WEB API package).
5.13. Client component
The client component comes both as ActiveX COM object (for Internet Explorer) and as plug-in (for Chrome, Firefox, Safari, Opera) – see chapter 4.1 for more details. This
component performs client side operations and is called from JavaScript code on JSP pages. It contains the following methods:
HRESULT Handshake([in] BSTR Command, [out, retval] BSTR* Result); Method accomplishes initial handshake.
Input parameter - MIME string sent by the server.
Output parameter - resulting MIME string, sent by the client to the server. Compatibility - used for both scenarios (“client knows PIN”; “server knows PIN”) HRESULT Execute([in] BSTR Command, [out, retval] BSTR* Result);
Method accomplishes Data Object transaction. Input parameter - MIME string sent by the server.
Output parameter - resulting MIME string, sent by the client to the server. Compatibility - used for both scenarios (“client knows PIN”; “server knows PIN”) HRESULT isSSOInstalled([out, retval] VARIANT_BOOL* fResult);
Method determines if SSO is installed.
Compatibility - used only for scenario “client knows PIN” HRESULT SSOLogin([out, retval] LONG* lResult); Method realizes client login by means of SSO.
Compatibility - used only for scenario “client knows PIN”
HRESULT WebLogin([in] BSTR UPW, [out, retval] LONG* lResult); Method realizes client login by standard means.
Compatibility - used only for scenario “client knows PIN” HRESULT GetCTFirmware([out, retval] LONG* fResult);
Method determines the firmware version of the attached CRYPTO-BOX
Compatibility - used only for scenario “server knows PIN” (firmware v2.2 and higher is needed)
HRESULT GetVersion([out, retval] BSTR *Version); Method returns client component’s version.
Compatibility - used for both scenarios (“client knows PIN”; “server knows PIN”) HRESULT Logout(void);
5. Developer’s Notes 28 Compatibility - used for both scenarios (“client knows PIN”; “server knows PIN”)
HRESULT SearchBoxes([in] BSTR Command,[in] BSTR UPW, [out, retval] BSTR* Result); Method searches local computer or network for available CRYPTO-BOX units specified by Command (in human-readable format, i.e.
"search=network,connect=broadcast,broadcastport=8766") .
Result lists what was found, UPW is optional (makes sense only for “client knows PIN” scenario).
HRESULT SetBox([in] BSTR Command,[in] BSTR UPW, [out, retval] BSTR* Result); Same as SearchBoxes except that only one CRYPTO-BOX (first-best) will be chosen for further work.
5.14. WEB API Server Side Source Code Samples
5.14.1. Generated HTML code for client side
The following sample is a fragment of HTML page generated by the WEB API server to be received and processed by the client's browser:
<script language=’javascript’>
function doHandshake(frm) { if(WEBSEC==null) { alert("SMRXWEB is not installed !");
return false; }
else {
if (WEBSEC.isSSOInstalled()){ //SSO detection
// perform auto login in case if SSO is installed
var ret = WEBSEC.SSOLogin();
if (ret == 0x05) {alert("No CRYPTO-BOX® is detected.
\nPlease, attach a valid CRYPTO-BOX® and try again"); return false;}
////////////////////////////////////////////////// /// … more error processing code … ///
/////////////////////////////////////////////////// if (ret != 0) return false;
}
else{ // Use manually entered password to perform login
var ret = WEBSEC.WebLogin(frm.password.value);
if (ret == 0x20001) alert("No CRYPTO-BOX® is detected.
\nPlease, attach a valid CRYPTO-BOX® and try again"); //////////////////////////////////////////////////
/// … more error processing code … ///
/////////////////////////////////////////////////// if (ret != 0) return false;
}
// proceed with handshake command and paste results into // a special hidden field ‘WEBSECHandshakeResult’
frm.WEBSECHandshakeResult.value =
WEBSEC.Handshake('AgEAAAAAEAEAAAB1HrB4qNucxXW5ogMZeApgjaeB5gvUkusEk3934jABBQAAAIA AAADK62/fSNmGsX0zEIplIQlsbwic1cxcqh5lA7TjbSxKbXokZRhYINsnKl7a6GKPGLUj4qMQ9ehA5lri
5. Developer’s Notes 29 Bx5pbVDiwf6uBAAAACAAAAATLaOkmmkQpEU+FSwfCrL1QtV2LX1JA78vcT3Mw7FkOsojGc6+JDivHzEuT 5DzPeFlRchNx5ZbFzGVx4RxlwFomGheOBqeWuAyX8OnyCQgHq1rQMhnUvZqb1xPjwvfGJ+Ahu2XXmxFt8 qEy7WCqYKjDp2NzOsFj0sNAwLJRocQFM='); } } </script>
<form name="form1" method="post" action="WebForm1.aspx">
// action= “…” depends on the server platform: // WebForm1.aspx/WebForm1.jsp/WebForm1.php
Input password <input type="password" name="password" value="demo"> <input type="hidden" name="WEBSECHandshakeResult" value="-"> <input type="submit" name="websecsubmit" value="Login" onClick=' return doHandshake(this.form);'>
</form>
5.14.2. PHP
HTML form/template code for CRYPTO-BOX validation and server/client handshake: // ******* WEBSEC - include WebSec *******
<?php include_once(“WebSec.php”);?> <?php
// Some code which provide logout/restart if needed
// create WebSec instance if needed
if($websec == null) $websec = new WebSec(); // set the instance to the next state
$websec->setState($websec->STATE_VERIFYRESULT);
$websec->setVerified(false); ?>
<html> <head>
// WebSec - insert header
<?php print($websec->getHTMLHeader()); ?>
</head>
<body bgcolor="#E7EBEB" text="#005AA0">
// WEBSEC - insert the JavaScript Handshake code in the page
<?php print($websec->getHandshakeCode()); ?>
<form name="form1" method="post" action="verifyresult.jsp">
Input password <input type="password" name="password" value="demo"> // disable password entry field if SSO is installed
<?php print($websec->getHidePwdEntry("form1", "password")); ?> // WEBSEC - place the submit-button here
<?php print($websec->getHandshakeSubmitButton("Login")); ?>
</form>
</body> </html>
5.14.3. Java and Java Server Pages (JSP)
5. Developer’s Notes 30 <%-- ******* WEBSEC - include WebSec ******* --%>
<jsp:useBean id="websec" scope="session" class="com.marx.jsmrxweb.WebSec" /> <%-- logout/restart if needed --%>
<&-- generate WebSec bean if needed --%>
If (websec == null) websec = new com.marx.jsmrxweb.WebSec(); <%-- set bean to the next state --%>
websec.setState(websec.STATE_VERIFYRESULT);
websec.setVerified(false);
%>
<html> <head>
<%-- ******* WebSec - insert header ******* --%> <% out.print(websec.getHTMLHeader()); %>
</head>
<body bgcolor="#E7EBEB" text="#005AA0">
<%-- *** WEBSEC - insert the JavaScript Handshake code in the page *** --%>
<% out.print(websec.getHandshakeCode()); %>
<form name="form1" method="post" action="verifyresult.jsp">
Input password <input type="password" name="password" value="demo"> <%-- *** WEBSEC - disable password entry field if SSO is installed *** --%>
<% out.print(websec.getHidePwdEntry("form1", "password")); %> <%-- ******* WEBSEC - place the submit-button here ******* --%>
<% out.print(websec.getHandshakeSubmitButton("Login")); %>
</form>
</body> </html>
5.14.4. ASP.NET
HTML form/template code for CRYPTO-BOX validation and server/client handshake:
<html>
<head>
// ASP labels are used here to insert
// client side JavaScript code
<asp:label id="JavaScriptHeader" runat="server">
<asp:label id="JavaScriptHandshakeCode" runat="server"> <asp:label id="JavaScriptDisablePWD" runat="server">
</head> </html>
<body>
<FORM id="Form1" method="post" runat="server" >
// ASP labels are used here to insert // hidden field and “Submit” button
<asp:textbox id="TextBox1" runat="server"></asp:textbox> <asp:label id="HandshakeSubmitButton" runat="server">
</FORM>
5. Developer’s Notes 31
5.14.5. Associated C# code to generate and control HTML form listed above
using System;
using System.Collections;
// … define more aliases for namespaces here namespace WebApplication1
{
public class WebForm1 : System.Web.UI.Page {
protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.HtmlControls.HtmlForm Form1; protected System.Web.UI.WebControls.TextBox TextBox1;
private void Page_Load(object sender, System.EventArgs e) {
if (this.IsPostBack)
{ Server.Transfer ("WebForm2.aspx", true);
// after HTML form submit we make a transfer to WebForm2.aspx
// which proceed received data
} else
{ // create WebSec instance if needed
if(websec == null) {
websec = new WebSec(); }
websec.setState(websec.STATE_VERIFYRESULT);
websec.setVerified(false);
// insert client side JavaScript code
JavaScriptHeader.Text=websec.getHTMLHeader(); JavaScriptHandshakeCode.Text= websec.getHandshakeCode(); JavaScriptDisablePWD.Text= websec.getHidePwdEntry ("Form1", " TextBox1"); HandshakeSubmitButton.Text= websec.getHandshakeSubmitButton("Login"); } }
override protected void OnInit(EventArgs e) {
// More code generated by VS.NET code designer… }
} }
6. Contact and Support 32
6. Contact and Support
USA
MARX CryptoTech LP
3355 Annandale Lane, Suite 2 Suwanee, GA 30024 USA www.marx.com Sales: Support: Phone: Fax: E-Mail: [email protected] [email protected] (+1) 770-904-0369 (+1) 678-730-1804 [email protected] Germany
MARX Software Security GmbH Vohburger Str. 68 D-85104 Wackerstein Germany www.marx.com Sales: Support: Phone: Fax: E-Mail: [email protected] [email protected] +49 (0) 8403 9295-0 +49 (0) 8403 1500 [email protected] Italy CS Computers S.r.l. Via Indipendenza, 4-12 I-47033 Cattolica (FO) Italia www.cscomputers.it Contact: Phone: Fax: E-Mail:
Giorgio del Bene +39 0 541/963-801 +39 0 541/953-847 [email protected] Poland BCSG Sp. z o.o. ul. Lubeckiego 16 60-348 Poznan Poland www.bcsg.pl Contact: Phone: E-Mail: Rafał Królak +48 667 633 915 [email protected]
6. Contact and Support 33
7. Alphabetical Index
A
AES Rijndael encryption 11 Apache 10 ASP.NET 6, 20, 30 ASP.NET sample 20 C Chrome 10 Client component 27 Client knows PIN 7, 12 Client side operations 27 Contact Information 32 Counter 13
D
Data Objects (DO) API 13 Diagnostic 11 E Error handling 25 Expiration Date 13 F FEST 19 Firefox 10 FreeBSD 10 H Handshake 12 I IE10/11 Issues 25
IE9 compatibility mode 26 IIS 10
Internet Explorer 10 J
Java sample 19
Java Server Pages 6, 19, 29 L Linux 10 Login 21 M Mac OS X 10 MARX Analyzer 11 O Opera 10 P PHP 6, 29 PHP sample 18 PIN 7 R Remote Update 6 S Safari 10
Server knows PIN 7, 13 SessionID 12
Support 32 U
User Password (UPW) 7 V
Verification 23 W
WEB API Client Component 10 WEB API reference 27
Windows 10