Changes between Version 6 and Version 7 of security/electronic_signatures


Ignore:
Timestamp:
Feb 28, 2013, 5:57:56 PM (11 years ago)
Author:
Sam Habiel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • security/electronic_signatures

    v6 v7  
    112112 S X=OUTPUT ; X is output
    113113 QUIT
    114  ;
    115 RUNTESTS S IO=$P S DIQUIET=1 D DT^DICRW D:$L($T(EN^XTMUNIT)) EN^XTMUNIT($T(+0),1) QUIT
    116 THASH ; @TEST - Test Hashing
    117  N DUZ
    118  S DUZ=1 N X S X="HELLO WORLD" D HASH
    119  N RESULT1 S RESULT1=X
    120  S DUZ=1 N X S X="HELLO WORLD" D HASH
    121  N RESULT2 S RESULT2=X
    122  D CHKEQ^XTMUNIT(RESULT1,RESULT2,"Hash results are not equal")
    123  ;
    124  S DUZ=1 N X S X="HELLO WORLD" D HASH
    125  N RESULT1 S RESULT1=X
    126  S DUZ=2 N X S X="HELLO WORLD" D HASH
    127  N RESULT2 S RESULT2=X
    128  D CHKTF^XTMUNIT(RESULT1'=RESULT2,"Hash results are not supposed to be equal")
    129  ;
    130  S DUZ=1
    131  N X S X="Hello World" D HASH
    132  N RESULT1 S RESULT1=X
    133  N X S X="HELLO WORLD" D HASH
    134  N RESULT2 S RESULT2=X
    135  D CHKEQ^XTMUNIT(RESULT1,RESULT2,"Hash results of different cases aren't equal")
    136  QUIT
    137  ;
    138 THASH2 ; @TEST - Test Hashing using main calling routine XUSHSHP
    139  N DUZ
    140  S DUZ=1 N X S X="HELLO WORLD" D HASH^XUSHSHP
    141  N RESULT1 S RESULT1=X
    142  S DUZ=1 N X S X="HELLO WORLD" D HASH^XUSHSHP
    143  N RESULT2 S RESULT2=X
    144  D CHKEQ^XTMUNIT(RESULT1,RESULT2,"Hash results are not equal")
    145  ;
    146  S DUZ=1 N X S X="HELLO WORLD" D HASH^XUSHSHP
    147  N RESULT1 S RESULT1=X
    148  S DUZ=2 N X S X="HELLO WORLD" D HASH^XUSHSHP
    149  N RESULT2 S RESULT2=X
    150  D CHKTF^XTMUNIT(RESULT1'=RESULT2,"Hash results are not supposed to be equal")
    151  ;
    152  S DUZ=1
    153  N X S X="Hello World" D HASH^XUSHSHP
    154  N RESULT1 S RESULT1=X
    155  N X S X="HELLO WORLD" D HASH^XUSHSHP
    156  N RESULT2 S RESULT2=X
    157  D CHKEQ^XTMUNIT(RESULT1,RESULT2,"Hash results of different cases aren't equal")
    158  QUIT
    159  ;
    160 TENC ; @TEST - Test Encryption
    161  N VALUE S VALUE="Mary has a little lamb"
    162  S X=VALUE,X1=1,X2=234234234
    163  D EN,DE ; encrypt, decrypt X
    164  D CHKEQ^XTMUNIT(VALUE,X,"Encryption and decryption didn't happen properly")
    165  ;
    166  N VALUE2 S VALUE2="Mary has a little lamb"
    167  S X=VALUE2,X1=88,X2=234234234
    168  D EN ; encrypt
    169  N ENCSTR1 S ENCSTR1=X
    170  S X=VALUE2,X1=1,X2=234234234 ; Different X1
    171  D EN ; encrypt
    172  N ENCSTR2 S ENCSTR2=X
    173  D CHKTF^XTMUNIT(ENCSTR1'=ENCSTR2,"Encrypted strings with different passwords are not supposed to be equal")
    174  QUIT
    175  ;
    176 TENC2 ; @TEST - Test Encryption by calling XUSHSHP
    177  N VALUE S VALUE="Mary has a little lamb"
    178  S X=VALUE,X1=1,X2=234234234
    179  D EN^XUSHSHP,DE^XUSHSHP ; encrypt, decrypt X
    180  D CHKEQ^XTMUNIT(VALUE,X,"Encryption and decryption didn't happen properly")
    181  ;
    182  N VALUE2 S VALUE2="Mary has a little lamb"
    183  S X=VALUE2,X1=88,X2=234234234
    184  D EN^XUSHSHP ; encrypt
    185  N ENCSTR1 S ENCSTR1=X
    186  S X=VALUE2,X1=1,X2=234234234 ; Different X1
    187  D EN^XUSHSHP ; encrypt
    188  N ENCSTR2 S ENCSTR2=X
    189  D CHKTF^XTMUNIT(ENCSTR1'=ENCSTR2,"Encrypted strings with different passwords are not supposed to be equal")
    190  QUIT
    191 LENGTH ; @TEST - Test Lengths
    192  N X,X1,X2,I
    193  S (X1,X2)=982734987234
    194  W !
    195  F I=1:1:60 K X S $P(X,"A",I)="A" W $L(X) D EN W ?30,$L(X),!
    196  QUIT
    197114}}}
    198115
     
    225142        I $L($G(^UJO(400000001.3,IEN,1))) X ^(1) QUIT  ; Try Implementation specific first
    226143        I $L($G(^UJO(400000001.1,IEN,2))) X ^(2) QUIT  ; Otherwise, use default one
    227         ;
    228         ;
    229         ;
    230 RUNTESTS I $L($T(EN^XTMUNIT)) S IO=$P,DIQUIET=1 D DT^DICRW,EN^XTMUNIT($T(+0),1) QUIT
    231 TESTAPI ; @TEST - Test calling X(APINAME) with existent and non-existent entries.
    232         N X,X1,X2
    233         D X("UNIT TEST ENTRY")
    234         D CHKEQ^XTMUNIT(X,"HELLO WORLD","API wasn't called")
    235         ;
    236         N STR S STR="HELLO WORLD2"
    237         S X=STR,X1="LKJSDF",X2=23432
    238         D X("ENCRYPT STRING")
    239         D CHKTF^XTMUNIT(X'="HELLO WORLD2","Encrypt failed")
    240         D X("DECRYPT STRING")
    241         D CHKEQ^XTMUNIT(X,"HELLO WORLD2","Encrypt/Decrypt failed")
    242         ;
    243         D X("LKSJDKLFDF") ; Make sure there is no crash
    244         QUIT
    245144}}}
    246145
     
    380279}}}
    381280
     281Please note that while the above conversion can be made rerun-safe, this is not taken into consideration here. This code can only be run once without it proving to be harmful. However, if it is ran again, the reverse operation can be performed to correct the action of the second run.
     282
     283I didn't write example code for Radiology/Nuclear Medicine as I don't have test data in that package.
     284
     285== Impact on the rest of VISTA ==
     286Analysis of the impact will take two phases: That of the Hash and that of the change in encryption.
     287
     288=== Impact of the new hashing algorithm ===
     289Replacement of the Hash algorithm presents no foreseable problems. The maximum length of the output of the new hash is identical to the maximum length of the old. You only need to ensure that at the time of installing the new hash you convert the old unencrypted electronic signatures into the hashed form so that the user's electronic signatures will continue working.
     290
     291=== Impact of the new encryption algorithm ===
     292This area is far more problematic for two reasons: the output of the hash is random data (which Fileman cannot store), and with block ciphers input is padded to achieve block size. Both of these issues mean that to achieve proper encryption, you will need to base64 encode output from a block cipher so the result can be stored in Fileman. In the end, it means that the encrypted data is much longer than the original data (but not quite double the size). This means that we need to expand the Fileman fields where the encrypted data is stored. The KIDS file accompanying this article expands the 4 TIU fields that store encrypted data to 120 characters each from 60 characters. It's anticipated that other fields (especially field 10 in File 74) will need to be expanded depending on the number of packages you are using. The alternative is to change the encryption algorithm to something much weaker (even rot5) to be able to retain the current sizes.
     293
     294The following is an analysis of all the impacted area in VISTA:
     295{{{
     296r/DVBCHLUT.m: D EN^XUSHSHP
     297HINQ package. Unused.
     298
     299r/EEOEEXMT.m:LONG K EEOPT S EENOD=DECR,EEOL=$L(EENOD),EEOC="" F EEOC=0:50:250 S X=$E(EENOD,EEOC+1,EEOC+50) Q:X=""  D EN^XUSHSHP D
     300r/EEOEEXMT.m: D EN^XUSHSHP S ^TMP($J,FEE)=X
     301r/EEOEEXMT.m: I $L(DECR)<50 S X=DECR,X2=FEE+1 D EN^XUSHSHP S ^TMP($J,FEE+1)=X,FEE=FEE+2 Q
     302r/EEOEXMT2.m: K EEOPT S EENOD=DECR,EEOL=$L(EENOD),EEOC="" F EEOC=0:50:250 S X=$E(EENOD,EEOC+1,EEOC+50) Q:X=""  D EN^XUSHSHP D
     303r/EEOEXMT2.m: D EN^XUSHSHP S ^TMP($J,FEE)=X
     304r/EEOEXMT2.m: I $L(DECR)<50 S X=DECR,X2=FEE+1 D EN^XUSHSHP S ^TMP($J,FEE+1)=X,FEE=FEE+2 Q
     305EEO COMPLAINT TRACKING. Unused.
     306
     307r/ENTIUTL1.m: . S X=ENSTR,X1=ENDA,X2=1 D EN^XUSHSHP S ENSTRH=X ; hashed string
     308ENGINEERING. Unused.
     309
     310r/MCESPRT.m: D EN^XUSHSHP
     311MEDICINE. Probably unused. Used only by $$ENCODE^MCESPRT which is only called from SIGN^MCESEDT2 on the CLI.
     312
     313r/OOPSESIG.m: W "  ... signed." S X=ESNAM,X1=DUZ,X2=IEN D EN^XUSHSHP S ESIG=DUZ_"^"_X
     314r/OOPSGUIS.m: D EN^XUSHSHP
     315r/OOPSVAL1.m: D EN^XUSHSHP
     316Automated Safety Incident Surveillance Tracking System. Unused.
     317
     318r/PRCASIG.m: D EN^XUSHSHP
     319r/PRCUESIG.m:ENCODE(X,X1,X2) D EN^XUSHSHP Q X
     320IFCAP. Not sure if it's used.
     321
     322r/PRPFSIG.m:ENCODE(X,X1,X2) D EN^XUSHSHP Q X
     323Patient Funds. Direct Global Set. No risk.
     324
     325r/PRSAOTX.m: S X=ESNAM,X1=DUZ,X2=DA D EN^XUSHSHP
     326Global Set. No risk.
     327r/PRSASC1.m: S DFN=$P(AP(1,DA),"^",1),ACT=$P(AP(1,DA),"^",2),COM=$P(AP(1,DA),"^",3),X=ESNAM,X1=DUZ,X2=DA D EN^XUSHSHP
     328r/PRSASC1.m: S DFN=$P(AP(2,DA),"^",1),ACT=$P(AP(2,DA),"^",2),COM=$P(AP(2,DA),"^",3),X=ESNAM,X1=DUZ,X2=DA D EN^XUSHSHP
     329r/PRSASC1.m: S DFN=$P(AP(3,DA),"^",1),ACT=$P(AP(3,DA),"^",2),COM=$P(AP(3,DA),"^",3),X=ESNAM,X1=DUZ,X2=DA D EN^XUSHSHP
     330r/PRSASC1.m: S X=ESNAM,X1=DUZ,X2=DFN D EN^XUSHSHP
     331All global sets. No risk.
     332PAID.
     333
     334r/RACTVR4.m:X11 S X1=RASIG("PER"),X=RASIG("NAME"),X2=DA D EN^XUSHSHP S RASIGCDE=X
     335r/RACTVR.m:X34 S X1=RASIG("PER"),X=RASIG("NAME"),X2=DA D EN^XUSHSHP S RASIGCDE=X
     336r/RACTWR2.m:X5 S X1=RASIG("PER"),X=RASIG("NAME"),X2=DA D EN^XUSHSHP S RASIGCDE=X
     337r/RACTWR4.m:X5 S X1=RASIG("PER"),X=RASIG("NAME"),X2=DA D EN^XUSHSHP S RASIGCDE=X
     338r/RAHLO1.m:LOCK1 I $D(RAESIG) S X=RAESIG,X1=$G(RAVERF),X2=RARPT D EN^XUSHSHP S RAESIG=X
     33974,10         ELECTRONIC SIGNATURE CODE 0;10 FREE TEXT
     340
     341              INPUT TRANSFORM:  K:$L(X)>50!($L(X)<1) X
     342              OUTPUT TRANSFORM: S Y="  <Hidden>"
     343***THIS NEEDS TO CHANGE LENGTH TO 80 CHARACTERS AND RECORDS CONVERTED!***
     344Radiology
     345
     346r/RMPOBILU.m: D EN^XUSHSHP
     347r/RMPR4LI.m: D EN^XUSHSHP Q X
     348r/RMPRSEC.m: D EN^XUSHSHP Q X
     349Home Oxygen Billing. Unused.
     350
     351r/SPNLGUCD.m: D EN^XUSHSHP
     352Spinal code dysfunction. Unused.
     353
     354r/TIULC1.m: D EN^XUSHSHP
     355TIU Already accounted for.
     356
     357r/VAQHSH1.m: I ('DCRYPT) D EN^XUSHSHP Q X
     358PATIENT DATA EXHANGE. Unused.
     359
     360r/XUSESIG1.m: S X=ESBLK,X1=+CHKSUM,X2=1 D EN^XUSHSHP
     361API. Not referenced anywhere.
     362
     363r/XUSTZ.m: S X1=IOS,X2=DT F I=1:1:XUF(.2) S X=XUF(I) D EN^XUSHSHP S XUF(I)=X
     364Only used as hashing it seems. Global set. Throw away data. No action needed.
     365
     366No matches in the DD global.
     367}}}