Subversion Repositories oidplus

Rev

Rev 966 | Rev 1382 | Go to most recent revision | View as "text/javascript" | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.  * OIDplus 2.0
  3.  * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17.  
  18. var OIDplusObjectTypePluginAid = {
  19.  
  20.         OID: "1.3.6.1.4.1.37476.2.5.2.4.8.11",
  21.  
  22.         generateRandomAID: function() {
  23.                 var length     = 32; // 32 nibbles = 16 bytes
  24.                 var characters = '0123456789ABCDEF';
  25.                 do {
  26.                         var result = 'F'; // category "F" = Unregistered Proprietary AID
  27.                         for ( var i = 0 ; i < length - 1/*F*/ ; i++ ) {
  28.                                 result += characters.charAt(Math.floor(Math.random() * characters.length));
  29.                         }
  30.                 } while (result.endsWith('FF') && (result.length==32));
  31.  
  32.                 // Note that 16 byte AIDs ending with 0xFF *were* reserved by ISO in ISO 7816-4:1994,
  33.                 // but modern versions of ISO 7816-4 and ISO 7816-4 do not mention this case anymore.
  34.                 // It can be assumed that the usage is safe, but just to be sure, we exclude 16-byte
  35.                 // AIDs ending with 0xFF, in case there are some software implementations which
  36.                 // deny such AIDs.
  37.  
  38.                 $("#id").val(result);
  39.         }
  40.  
  41. };
  42.