49. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/10/2017 1:01:43 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.

49.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IV-ehmp_cif\ImagingCommon\main\src\java\gov\va\med\imaging\encryption AesEncryption.java Thu Jun 29 17:22:59 2017 UTC
2 C:\AraxisMergeCompare\Pri_re\IV-ehmp_cif\ImagingCommon\main\src\java\gov\va\med\imaging\encryption AesEncryption.java Fri Jul 7 16:43:49 2017 UTC

49.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 4 468
Changed 3 6
Inserted 0 0
Removed 0 0

49.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

49.4 Active regular expressions

No regular expressions were active.

49.5 Comparison detail

  1   /**
  2    * 
  3     Package:  MAG - Vis tA Imaging
  4     WARNING:  Per VHA D irective 2 004-038, t his routin e should n ot be modi fied.
  5     Date Cre ated: Feb  7, 2012
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:          
WERFEJ
  8     Descript ion: 
  9  
  10           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  11           ;;  Property  of the US  Government .
  12           ;;  No permis sion to co py or redi stribute t his softwa re is give n.
  13           ;;  Use of un released v ersions of  this soft ware requi res the us er
  14           ;;   to execu te a writt en test ag reement wi th the Vis tA Imaging
  15           ;;   Developm ent Office  of the De partment o f Veterans  Affairs,
  16           ;;   telephon e (301) 73 4-0100.
  17           ;;
  18           ;;  The Food  and Drug A dministrat ion classi fies this  software a s
  19           ;;  a Class I I medical  device.  A s such, it  may not b e changed
  20           ;;  in any wa y.  Modifi cations to  this soft ware may r esult in a n
  21           ;;  adulterat ed medical  device un der 21CFR8 20, the us e of which
  22           ;;  is consid ered to be  a violati on of US F ederal Sta tutes.
  23           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  24  
  25    */
  26   package go v.va.med.i maging.enc ryption;
  27  
  28   import jav a.security .InvalidAl gorithmPar ameterExce ption;
  29   import jav a.security .InvalidKe yException ;
  30   import jav a.security .NoSuchAlg orithmExce ption;
  31   import jav a.util.Ran dom;
  32  
  33   import gov .va.med.im aging.Base 64;
  34   import gov .va.med.im aging.encr yption.exc eptions.Ae sEncryptio nException ;
  35  
  36   import jav ax.crypto. BadPadding Exception;
  37   import jav ax.crypto. Cipher;
  38   import jav ax.crypto. IllegalBlo ckSizeExce ption;
  39   import jav ax.crypto. NoSuchPadd ingExcepti on;
  40   import jav ax.crypto. spec.IvPar ameterSpec ;
  41   import jav ax.crypto. spec.Secre tKeySpec;
  42  
  43   /**
  44    * @author         
WERFEJ
  45    *
  46    */
  47   public cla ss AesEncr yption
  48   {
  49           
  50           pr ivate fina l static b yte [] ses sionKey =  " REDACTED ".getBytes ();
  51           
  52           /* *
  53            *  encrypts  and base 6 4 encodes  the clearT ext string
  54            *  @param cl earText
  55            *  @return
  56            *  @throws N oSuchAlgor ithmExcept ion
  57            *  @throws N oSuchPaddi ngExceptio n
  58            *  @throws I nvalidKeyE xception
  59            *  @throws I llegalBloc kSizeExcep tion
  60            *  @throws B adPaddingE xception
  61            * /
  62           pu blic stati c String e ncrypt(Str ing clearT ext) 
  63           th rows AesEn cryptionEx ception
  64           {
  65                    byte  [] bytes  = clearTex t.getBytes ();
  66                    
  67                    Ciph er cipher  = null;
  68                    try
  69                    {
  70                             cipher  = Cipher. getInstanc e("AES");
  71                    } 
  72                    catc h (NoSuchA lgorithmEx ception e)
  73                    {
  74                             throw  new AesEnc ryptionExc eption("Ex ception fi nding AES  algorithm" , e);          
  75                    }
  76                    catc h (NoSuchP addingExce ption e)
  77                    {
  78                             throw  new AesEnc ryptionExc eption("Ex ception fi nding AES  algorithm" , e);
  79                    }                 
  80                    
  81                    try
  82                    {
  83                             cipher .init(Ciph er.ENCRYPT _MODE, new  SecretKey Spec(sessi onKey, "AE S"));
  84                    }
  85                    catc h (Invalid KeyExcepti on e)
  86                    {
  87                             throw  new AesEnc ryptionExc eption("Ex ception in itializing  cipher",  e);
  88                    }
  89                    
  90                    byte [] ciphert ext = null ;
  91                    try
  92                    {
  93                             cipher text = cip her.doFina l(bytes);
  94                    } 
  95                    catc h (Illegal BlockSizeE xception e )
  96                    {
  97                             throw  new AesEnc ryptionExc eption("Ex ception du ring encry ption", e) ;
  98                    } 
  99                    catc h (BadPadd ingExcepti on e)
  100                    {
  101                             throw  new AesEnc ryptionExc eption("Ex ception du ring encry ption", e) ;
  102                    }
  103                    //Sy stem.out.p rintln("En crypted le ngth: " +  ciphertext .length);
  104                    Stri ng encoded Result = B ase64.enco deBytes(ci phertext,  Base64.URL _SAFE);
  105                    
  106                    enco dedResult  = encodedR esult.repl ace("\n",  "");
  107                    retu rn encoded Result;
  108           }
  109           
  110           /* *
  111            *  encrypts  and base 6 4 encodes  the clearT ext string  to be use d for the  AWIV
  112            *  @param in itializati onVector
  113            *  @param cl earText
  114            *  @return
  115            *  @throws N oSuchAlgor ithmExcept ion
  116            *  @throws N oSuchPaddi ngExceptio n
  117            *  @throws I nvalidKeyE xception
  118            *  @throws I llegalBloc kSizeExcep tion
  119            *  @throws B adPaddingE xception
  120            * /
  121           pu blic stati c String e ncrypt(byt e[] iv, St ring clear Text) 
  122           th rows AesEn cryptionEx ception
  123           {
  124                    byte [] bytes =  clearText .getBytes( );
  125           
  126                    Ciph er cipher  = null;
  127                    try
  128                    {
  129                    ciph er = Ciphe r.getInsta nce("AES/C BC/PKCS5Pa dding");
  130                    } 
  131                    catc h (NoSuchA lgorithmEx ception e)
  132                    {
  133                             throw  new AesEnc ryptionExc eption("Ex ception fi nding AES  algorithm" , e);          
  134                    }
  135                    catc h (NoSuchP addingExce ption e)
  136                    {
  137                             throw  new AesEnc ryptionExc eption("Ex ception fi nding AES  algorithm" , e);
  138                    }                 
  139                    
  140                    try
  141                    {
  142                             cipher .init(Ciph er.ENCRYPT _MODE, new  SecretKey Spec(sessi onKey, "AE S"), new I vParameter Spec(iv));
  143                    }
  144                    catc h (Invalid AlgorithmP arameterEx ception e)
  145                    {
  146                             throw  new AesEnc ryptionExc eption("In valid algo rithm para meter", e) ;
  147                    }
  148                    catc h (Invalid KeyExcepti on e)
  149                    {
  150                             throw  new AesEnc ryptionExc eption("Ex ception in itializing  cipher",  e);
  151                    }
  152                    
  153                    byte [] ciphert ext = null ;
  154                    try
  155                    {
  156                             cipher text = cip her.doFina l(bytes);
  157                    } 
  158                    catc h (Illegal BlockSizeE xception e )
  159                    {
  160                             throw  new AesEnc ryptionExc eption("Ex ception du ring encry ption", e) ;
  161                    } 
  162                    catc h (BadPadd ingExcepti on e)
  163                    {
  164                             throw  new AesEnc ryptionExc eption("Ex ception du ring encry ption", e) ;
  165                    }
  166                    //Sy stem.out.p rintln("En crypted le ngth: " +  ciphertext .length);
  167                    retu rn encodeB yteArray(c iphertext) ;
  168           }
  169  
  170           pu blic stati c byte[] g etInitiali zationVect or()
  171           {
  172                    // C reate a by te array h olding 16  bytes
  173                    byte [] byteArr ay = new b yte[16];
  174                    
  175                    // F ill it wit h random d ata
  176                    Rand om r = new  Random();
  177                    r.ne xtBytes(by teArray);
  178                    
  179                    // C onvert it  to a strin g and retu rn it
  180                    retu rn byteArr ay;
  181  
  182           }
  183           
  184           pu blic stati c String e ncodeByteA rray(byte[ ] byteArra y)
  185           {
  186                    Stri ng encoded Result = B ase64.enco deBytes(by teArray, B ase64.URL_ SAFE);
  187                    
  188                    enco dedResult  = encodedR esult.repl ace("\n",  "");
  189                    retu rn encoded Result;
  190           }
  191           
  192           pu blic stati c String d ecodeByteA rray(Strin g base64En crypted)
  193           th rows AesEn cryptionEx ception
  194           {
  195                    
  196                    byte  [] encode d = Base64 .decode(ba se64Encryp ted, Base6 4.URL_SAFE );
  197                    //Sy stem.out.p rintln("Ba se64 decod ed, encryp ted length : " + enco ded.length );
  198                    Ciph er cipher  = null;
  199                    try
  200                    {
  201                             cipher  = Cipher. getInstanc e("AES");
  202                    } 
  203                    catc h (NoSuchA lgorithmEx ception e)
  204                    {
  205                             throw  new AesEnc ryptionExc eption("Ex ception fi nding AES  algorithm" , e);          
  206                    }
  207                    catc h (NoSuchP addingExce ption e)
  208                    {
  209                             throw  new AesEnc ryptionExc eption("Ex ception fi nding AES  algorithm" , e);
  210                    }                 
  211                    
  212                    try
  213                    {
  214                             cipher .init(Ciph er.DECRYPT _MODE, new  SecretKey Spec(sessi onKey, "AE S"));
  215                    }
  216                    catc h (Invalid KeyExcepti on e)
  217                    {
  218                             throw  new AesEnc ryptionExc eption("Ex ception in itializing  cipher",  e);
  219                    }
  220                    
  221                    byte [] decoded Text = nul l;
  222                    try
  223                    {
  224                             decode dText = ci pher.doFin al(encoded );
  225                    } 
  226                    catc h (Illegal BlockSizeE xception e )
  227                    {
  228                             throw  new AesEnc ryptionExc eption("Ex ception du ring decry ption", e) ;
  229                    } 
  230                    catc h (BadPadd ingExcepti on e)
  231                    {
  232                             throw  new AesEnc ryptionExc eption("Ex ception du ring decry ption", e) ;
  233                    }
  234                    retu rn new Str ing(decode dText);
  235           }
  236  
  237   }