83. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:01 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

83.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\crypto\provider CipherWithWrappingSpi.java Mon Jan 22 14:46:50 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\crypto\provider CipherWithWrappingSpi.java Wed Sep 12 16:22:18 2018 UTC

83.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 5 510
Changed 4 8
Inserted 0 0
Removed 0 0

83.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

83.4 Active regular expressions

No regular expressions were active.

83.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 199 9, 2013, O racle and/ or its aff iliates. A ll rights  reserved.
  3    * DO NOT  ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER.
  4    *
  5    * This co de is free  software;  you can r edistribut e it and/o r modify i t
  6    * under t he terms o f the GNU  General Pu blic Licen se version  2 only, a s
  7    * publish ed by the  Free Softw are Founda tion.  Ora cle design ates this
  8    * particu lar file a s subject  to the "Cl asspath" e xception a s provided
  9    * by Orac le in the  LICENSE fi le that ac companied  this code.
  10    *
  11    * This co de is dist ributed in  the hope  that it wi ll be usef ul, but WI THOUT
  12    * ANY WAR RANTY; wit hout even  the implie d warranty  of MERCHA NTABILITY  or
  13    * FITNESS  FOR A PAR TICULAR PU RPOSE.  Se e the GNU  General Pu blic Licen se
  14    * version  2 for mor e details  (a copy is  included  in the LIC ENSE file  that
  15    * accompa nied this  code).
  16    *
  17    * You sho uld have r eceived a  copy of th e GNU Gene ral Public  License v ersion
  18    * 2 along  with this  work; if  not, write  to the Fr ee Softwar e Foundati on,
  19    * Inc., 5 1 Franklin  St, Fifth  Floor, Bo ston, MA 0 2110-1301  USA.
  20    *
  21    * Please  contact Or acle, 500  Oracle Par kway, Redw ood Shores , CA 94065  USA
  22    * or visi t www.orac le.com if  you need a dditional  informatio n or have  any
  23    * questio ns.
  24    */
  25  
  26   package co m.sun.cryp to.provide r;
  27  
  28   import jav a.security .Key;
  29   import jav a.security .PublicKey ;
  30   import jav a.security .PrivateKe y;
  31   import jav a.security .KeyFactor y;
  32   import jav a.security .InvalidKe yException ;
  33   import jav a.security .NoSuchPro viderExcep tion;
  34   import jav a.security .NoSuchAlg orithmExce ption;
  35   import jav a.security .spec.PKCS 8EncodedKe ySpec;
  36   import jav a.security .spec.X509 EncodedKey Spec;
  37   import jav a.security .spec.Inva lidKeySpec Exception;
  38  
  39   import jav ax.crypto. Cipher;
  40   import jav ax.crypto. CipherSpi;
  41   import jav ax.crypto. SecretKey;
  42   import jav ax.crypto. IllegalBlo ckSizeExce ption;
  43   import jav ax.crypto. BadPadding Exception;
  44   import jav ax.crypto. spec.Secre tKeySpec;
  45  
  46   /**
  47    * This cl ass entend s the java x.crypto.C ipherSpi c lass with  a concrete
  48    * impleme ntation of  the metho ds for wra pping and  unwrapping
  49    * keys.
  50    *
  51    * @author  Sharon Li u
  52    *
  53    *
  54    * @see ja vax.crypto .CipherSpi
  55    * @see Bl owfishCiph er
  56    * @see DE SCipher
  57    * @see PB EWithMD5An dDESCipher
  58    */
  59  
  60   public abs tract clas s CipherWi thWrapping Spi extend s CipherSp i {
  61  
  62       /**
  63        * Wra p a key.
  64        *
  65        * @pa ram key th e key to b e wrapped.
  66        *
  67        * @re turn the w rapped key .
  68        *
  69        * @ex ception Il legalBlock SizeExcept ion if thi s cipher i s a block
  70        * cip her, no pa dding has  been reque sted, and  the length  of the
  71        * enc oding of t he key to  be wrapped  is not a
  72        * mul tiple of t he block s ize.
  73        *
  74        * @ex ception In validKeyEx ception if  it is imp ossible or  unsafe to
  75        * wra p the key  with this  cipher (e. g., a hard ware prote cted key i s
  76        * bei ng passed  to a softw are only c ipher).
  77        */
  78       protec ted final  byte[] eng ineWrap(Ke y key)
  79           th rows Illeg alBlockSiz eException , InvalidK eyExceptio n
  80       {
  81           by te[] resul t = null;
  82  
  83           tr y {
  84                byte[] e ncodedKey  = key.getE ncoded();
  85                if ((enc odedKey ==  null) ||  (encodedKe y.length = = 0)) {
  86                    thro w new Inva lidKeyExce ption("Can not get an  encoding  of " +
  87                                                     "the  key to be  wrapped") ;
  88                }
  89  
  90                result =  engineDoF inal(encod edKey, 0,  encodedKey .length);
  91           }  catch (Bad PaddingExc eption e)  {
  92                // Shoul d never ha ppen
  93           }
  94  
  95           re turn resul t;
  96       }
  97  
  98       /**
  99        * Unw rap a prev iously wra pped key.
  100        *
  101        * @pa ram wrappe dKey the k ey to be u nwrapped.
  102        *
  103        * @pa ram wrappe dKeyAlgori thm the al gorithm th e wrapped  key is for .
  104        *
  105        * @pa ram wrappe dKeyType t he type of  the wrapp ed key.
  106        * Thi s is one o f <code>Ci pher.SECRE T_KEY</cod e>,
  107        * <co de>Cipher. PRIVATE_KE Y</code>,  or <code>C ipher.PUBL IC_KEY</co de>.
  108        *
  109        * @re turn the u nwrapped k ey.
  110        *
  111        * @ex ception In validKeyEx ception if  <code>wra ppedKey</c ode> does  not
  112        * rep resent a w rapped key , or if th e algorith m associat ed with th e
  113        * wra pped key i s differen t from <co de>wrapped KeyAlgorit hm</code>
  114        * and /or its ke y type is  different  from <code >wrappedKe yType</cod e>.
  115        *
  116        * @ex ception No SuchAlgori thmExcepti on if no i nstalled p roviders
  117        * can  create ke ys for the  <code>wra ppedKeyAlg orithm</co de>.
  118        */
  119       protec ted final  Key engine Unwrap(byt e[] wrappe dKey,
  120                                           Str ing wrappe dKeyAlgori thm,
  121                                           int  wrappedKe yType)
  122           th rows Inval idKeyExcep tion, NoSu chAlgorith mException
  123       {
  124           by te[] encod edKey;
  125           Ke y result =  null;
  126  
  127           tr y {
  128                encodedK ey = engin eDoFinal(w rappedKey,  0,
  129                                             w rappedKey. length);
  130           }  catch (Bad PaddingExc eption ePa dding) {
  131                throw ne w InvalidK eyExceptio n();
  132           }  catch (Ill egalBlockS izeExcepti on eBlockS ize) {
  133                throw ne w InvalidK eyExceptio n();
  134           }
  135  
  136           sw itch (wrap pedKeyType ) {
  137           ca se Cipher. SECRET_KEY :
  138                result =  construct SecretKey( encodedKey ,
  139                                               wrappedKey Algorithm) ;
  140                break;
  141           ca se Cipher. PRIVATE_KE Y:
  142                result =  construct PrivateKey (encodedKe y,
  143                                                wrappedKe yAlgorithm );
  144                break;
  145           ca se Cipher. PUBLIC_KEY :
  146                result =  construct PublicKey( encodedKey ,
  147                                               wrappedKey Algorithm) ;
  148                break;
  149           }
  150  
  151           re turn resul t;
  152  
  153       }
  154  
  155       /**
  156        * Con struct a p ublic key  from its e ncoding.
  157        *
  158        * @pa ram encode dKey the e ncoding of  a public  key.
  159        *
  160        * @pa ram encode dKeyAlgori thm the al gorithm th e encodedK ey is for.
  161        *
  162        * @re turn a pub lic key co nstructed  from the e ncodedKey.
  163        */
  164       privat e final Pu blicKey co nstructPub licKey(byt e[] encode dKey,
  165                                                      Str ing encode dKeyAlgori thm)
  166           th rows Inval idKeyExcep tion, NoSu chAlgorith mException
  167       {
  168           Pu blicKey ke y = null;
  169  
  170           tr y {
  171                KeyFacto ry keyFact ory =
  172                    KeyF actory.get Instance(e ncodedKeyA lgorithm,
  173                         SunJCE.get Instance() );
  174                X509Enco dedKeySpec  keySpec =  new X509E ncodedKeyS pec(encode dKey);
  175                key = ke yFactory.g eneratePub lic(keySpe c);
  176           }  catch (NoS uchAlgorit hmExceptio n nsae) {
  177                // Try t o see whet her there  is another
  178                // provi der which  supports t his algori thm
  179                try {
  180                    KeyF actory key Factory =
  181                         KeyFactory .getInstan ce(encoded KeyAlgorit hm);
  182                    X509 EncodedKey Spec keySp ec =
  183                         new X509En codedKeySp ec(encoded Key);
  184                    key  = keyFacto ry.generat ePublic(ke ySpec);
  185                } catch  (NoSuchAlg orithmExce ption nsae 2) {
  186                    thro w new NoSu chAlgorith mException ("No insta lled provi ders " +
  187                                                           "can crea te keys fo r the " +
  188                                                           encodedKe yAlgorithm  +
  189                                                           "algorith m");
  190                } catch  (InvalidKe ySpecExcep tion ikse2 ) {
  191                    // S hould neve r happen.
  192                }
  193           }  catch (Inv alidKeySpe cException  ikse) {
  194                // Shoul d never ha ppen.
  195           }
  196  
  197           re turn key;
  198       }
  199  
  200       /**
  201        * Con struct a p rivate key  from its  encoding.
  202        *
  203        * @pa ram encode dKey the e ncoding of  a private  key.
  204        *
  205        * @pa ram encode dKeyAlgori thm the al gorithm th e wrapped  key is for .
  206        *
  207        * @re turn a pri vate key c onstructed  from the  encodedKey .
  208        */
  209       privat e final Pr ivateKey c onstructPr ivateKey(b yte[] enco dedKey,
  210                                                        S tring enco dedKeyAlgo rithm)
  211           th rows Inval idKeyExcep tion, NoSu chAlgorith mException
  212       {
  213           Pr ivateKey k ey = null;
  214  
  215           tr y {
  216                KeyFacto ry keyFact ory =
  217                    KeyF actory.get Instance(e ncodedKeyA lgorithm,
  218                         SunJCE.get Instance() );
  219                PKCS8Enc odedKeySpe c keySpec  = new PKCS 8EncodedKe ySpec(enco dedKey);
  220                return k eyFactory. generatePr ivate(keyS pec);
  221           }  catch (NoS uchAlgorit hmExceptio n nsae) {
  222                // Try t o see whet her there  is another
  223                // provi der which  supports t his algori thm
  224                try {
  225                    KeyF actory key Factory =
  226                         KeyFactory .getInstan ce(encoded KeyAlgorit hm);
  227                    PKCS 8EncodedKe ySpec keyS pec =
  228                         new PKCS8E ncodedKeyS pec(encode dKey);
  229                    key  = keyFacto ry.generat ePrivate(k eySpec);
  230                } catch  (NoSuchAlg orithmExce ption nsae 2) {
  231                    thro w new NoSu chAlgorith mException ("No insta lled provi ders " +
  232                                                           "can crea te keys fo r the " +
  233                                                           encodedKe yAlgorithm  +
  234                                                           "algorith m");
  235                } catch  (InvalidKe ySpecExcep tion ikse2 ) {
  236                    // S hould neve r happen.
  237                }
  238           }  catch (Inv alidKeySpe cException  ikse) {
  239                // Shoul d never ha ppen.
  240           }
  241  
  242           re turn key;
  243       }
  244  
  245       /**
  246          * Construc t a  PW        key from i ts encodin g.
  247        *
  248          * @param e ncodedKey  the encodi ng of a  PW        key.
  249        *
  250          * @param e ncodedKeyA lgorithm t he algorit hm the  PW        key is for .
  251        *
  252          * @return  PW        key constr ucted from  the encod edKey.
  253        */
  254       privat e final Se cretKey co nstructSec retKey(byt e[] encode dKey,
  255                                                      Str ing encode dKeyAlgori thm)
  256       {
  257           re turn (new  SecretKeyS pec(encode dKey, enco dedKeyAlgo rithm));
  258       }
  259   }