diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | scard/Ssh.bin.uu | 27 | ||||
-rw-r--r-- | scard/Ssh.java | 165 |
3 files changed, 91 insertions, 104 deletions
@@ -1,5 +1,6 @@ | |||
1 | 20010915 | 1 | 20010915 |
2 | - (djm) Make do_pre_login static to avoid prototype #ifdef hell | 2 | - (djm) Make do_pre_login static to avoid prototype #ifdef hell |
3 | - (djm) Sync scard/ stuff | ||
3 | 4 | ||
4 | 20010914 | 5 | 20010914 |
5 | - (bal) OpenBSD CVS Sync | 6 | - (bal) OpenBSD CVS Sync |
@@ -6431,4 +6432,4 @@ | |||
6431 | - Wrote replacements for strlcpy and mkdtemp | 6432 | - Wrote replacements for strlcpy and mkdtemp |
6432 | - Released 1.0pre1 | 6433 | - Released 1.0pre1 |
6433 | 6434 | ||
6434 | $Id: ChangeLog,v 1.1515 2001/09/15 02:25:53 djm Exp $ | 6435 | $Id: ChangeLog,v 1.1516 2001/09/15 10:58:46 djm Exp $ |
diff --git a/scard/Ssh.bin.uu b/scard/Ssh.bin.uu index 9af0adf04..1062e21d6 100644 --- a/scard/Ssh.bin.uu +++ b/scard/Ssh.bin.uu | |||
@@ -1,17 +1,16 @@ | |||
1 | begin 644 Ssh.bin | 1 | begin 644 Ssh.bin |
2 | M`P)!#``:01\`A``!`F@"`$$,014!_F#P!0!!#$$?`4$,01X!00Q!'0%!#$$< | 2 | M`P)!%P`501P`;``!`C@"`/Y@\`4`_J'P!0!!%T$;`?Z@\`4`01=!&@'^>/,! |
3 | M`4$,01L!00Q!&@'^H?`%`$$,01@!_J#P!0!!#$$7`?YX\P$!00Q!&0'^<]4` | 3 | M`4$701P!_G#S%P'^0],1`?Y@\!0`_G/S'0#^<]4``D$7L`4`_F'3``!!%T$9 |
4 | M`OYP\Q<!_D/3$0'^8/`4`$$,L`4`_F'3``!!#$$6`?YATP4`_G/5"P7^8=,' | 4 | M`?YATP4`_G/5"P7^8=,'`OZAT`$!_J#0$@1!%T$8`0```$$7!`$&`/Y@`;@` |
5 | M`OZAT`$!_J#0$@0``$$,"@$$`/Y@`=```$$5\`H(`$$6\`H``$$7\@\``$$8 | 5 | M`$$8\`H(`$$9\`H``$$:\@\``$$;\B$``$$<\A```/`&__(```0(`!8```9C |
6 | M\B$``$$9\A```$$:__0"`$$;__8"`$$<__8"`$$=__8"`$$>__8"`$$?__8" | 6 | M""T#"<(H+00$*"T%""A;`&19``#P$/_R`P(&`0#(```38`!!70!&$UP`1@09 |
7 | M`/`0__(#`@8!`,H``!-@`%]=`&037`!D!!D)I$L`"0J0`&``4!-<`&0$&58` | 7 | M":1+``D*D`!@`"@37`!&!!E6`````*(````$____P````*$````0````*@`` |
8 | M````H@````3____`````H0```!`````J````(````(T````P````:A-<`&0# | 8 | M`"````"-````,````&H37`!&`QD(2@`)"FX`8``H$UP`1@<9"@#_/2!@`$L1 |
9 | M&0A*``D*;@!@`%`37`!D!QD*`/\](&``:1%*``D*9P!@`%`37`!!$UP`9`@1 | 9 | M2@`)"F<`8``H$UP`'A-<`$8($1-<`$8(7@!0"!%@`%59"C\`8`!:*PIS:&`` |
10 | M$UP`9`A>`&X($6``<UD*/P!@`'@K"G-H8`!X*Q-<`&0#`PH`@&``?2L#"@"` | 10 | M6BL37`!&`P,*`(!@`%\K`PH`@&``55D37`!&`P<H$UP`1@0#*`,%8`!565D* |
11 | M8`!S61-<`&0#!R@37`!D!`,H`P5@`'-960IM`&``4%D```#P$__R`0$!"0`( | 11 | M;0!@`"A9`/`"__(!`0$)``@```J0`&``*%D`\!/_\@$!`@D`#```8D$7+5\` |
12 | M``!B00Q?`%I9`+`%__(!`00"`&P``!-?``43"%T`"A,)$%T`#Q,)(%T`%!,) | 12 | M/"M9````\!+_]@$!`P$`&```$UP`'EX`,D4`#Q-<`!X*`,@)$%X`-P17L`7_ |
13 | M,%T`&1,)P%T`'A,*!`!=`",38OZA+5\`*%T`+1-B_J`M7P`R70`W$V+^>"T* | 13 | M\@$!!`(`/```$U\``!-B_J$M7P`%70`*$V+^H"U?``]=`!038OYX+0H$`%\` |
14 | M!`!?`#Q=`$$37`!!"@#("1!>`$8*!`!@`$M%``D*9P!@`%`37@!56?`&__(` | 14 | <&5T`'@H$`&``(T4`"0IG`&``*!->`"U9```````` |
15 | ?``0(`!0```9C""T#"<(H+00$*"T%""A;``!9``````!@ | ||
16 | ` | 15 | ` |
17 | end | 16 | end |
diff --git a/scard/Ssh.java b/scard/Ssh.java index 05e2b4872..9ca6da385 100644 --- a/scard/Ssh.java +++ b/scard/Ssh.java | |||
@@ -1,64 +1,66 @@ | |||
1 | /* | 1 | // $Id: Ssh.java,v 1.2 2001/09/15 10:58:47 djm Exp $ |
2 | * copyright 1997, 2000 | 2 | // |
3 | * the regents of the university of michigan | 3 | // Ssh.java |
4 | * all rights reserved | 4 | // SSH / smartcard integration project, smartcard side |
5 | * | 5 | // |
6 | * permission is granted to use, copy, create derivative works | 6 | // Tomoko Fukuzawa, created, Feb., 2000 |
7 | * and redistribute this software and such derivative works | 7 | // |
8 | * for any purpose, so long as the name of the university of | 8 | // Naomaru Itoi, modified, Apr., 2000 |
9 | * michigan is not used in any advertising or publicity | 9 | // |
10 | * pertaining to the use or distribution of this software | 10 | |
11 | * without specific, written prior authorization. if the | 11 | // copyright 2000 |
12 | * above copyright notice or any other identification of the | 12 | // the regents of the university of michigan |
13 | * university of michigan is included in any copy of any | 13 | // all rights reserved |
14 | * portion of this software, then the disclaimer below must | 14 | // |
15 | * also be included. | 15 | // permission is granted to use, copy, create derivative works |
16 | * | 16 | // and redistribute this software and such derivative works |
17 | * this software is provided as is, without representation | 17 | // for any purpose, so long as the name of the university of |
18 | * from the university of michigan as to its fitness for any | 18 | // michigan is not used in any advertising or publicity |
19 | * purpose, and without warranty by the university of | 19 | // pertaining to the use or distribution of this software |
20 | * michigan of any kind, either express or implied, including | 20 | // without specific, written prior authorization. if the |
21 | * without limitation the implied warranties of | 21 | // above copyright notice or any other identification of the |
22 | * merchantability and fitness for a particular purpose. the | 22 | // university of michigan is included in any copy of any |
23 | * regents of the university of michigan shall not be liable | 23 | // portion of this software, then the disclaimer below must |
24 | * for any damages, including special, indirect, incidental, or | 24 | // also be included. |
25 | * consequential damages, with respect to any claim arising | 25 | // |
26 | * out of or in connection with the use of the software, even | 26 | // this software is provided as is, without representation |
27 | * if it has been or is hereafter advised of the possibility of | 27 | // from the university of michigan as to its fitness for any |
28 | * such damages. | 28 | // purpose, and without warranty by the university of |
29 | * | 29 | // michigan of any kind, either express or implied, including |
30 | * SSH / smartcard integration project, smartcard side | 30 | // without limitation the implied warranties of |
31 | * | 31 | // merchantability and fitness for a particular purpose. the |
32 | * Tomoko Fukuzawa, created, Feb., 2000 | 32 | // regents of the university of michigan shall not be liable |
33 | * Naomaru Itoi, modified, Apr., 2000 | 33 | // for any damages, including special, indirect, incidental, or |
34 | */ | 34 | // consequential damages, with respect to any claim arising |
35 | // out of or in connection with the use of the software, even | ||
36 | // if it has been or is hereafter advised of the possibility of | ||
37 | // such damages. | ||
35 | 38 | ||
36 | import javacard.framework.*; | 39 | import javacard.framework.*; |
37 | import javacardx.framework.*; | 40 | import javacardx.framework.*; |
38 | import javacardx.crypto.*; | 41 | import javacardx.crypto.*; |
39 | 42 | ||
40 | public class Ssh extends javacard.framework.Applet | 43 | public class Ssh extends javacard.framework.Applet |
41 | { | 44 | { |
42 | /* constants declaration */ | 45 | /* constants declaration */ |
43 | // code of CLA byte in the command APDU header | 46 | // code of CLA byte in the command APDU header |
44 | private final byte Ssh_CLA =(byte)0x05; | 47 | static final byte Ssh_CLA =(byte)0x05; |
45 | 48 | ||
46 | // codes of INS byte in the command APDU header | 49 | // codes of INS byte in the command APDU header |
47 | private final byte DECRYPT = (byte) 0x10; | 50 | static final byte DECRYPT = (byte) 0x10; |
48 | private final byte GET_KEYLENGTH = (byte) 0x20; | 51 | static final byte GET_KEYLENGTH = (byte) 0x20; |
49 | private final byte GET_PUBKEY = (byte) 0x30; | 52 | static final byte GET_PUBKEY = (byte) 0x30; |
50 | private final byte GET_RESPONSE = (byte) 0xc0; | 53 | static final byte GET_RESPONSE = (byte) 0xc0; |
51 | 54 | ||
52 | /* instance variables declaration */ | 55 | /* instance variables declaration */ |
53 | private final short keysize = 1024; | 56 | static final short keysize = 1024; |
54 | 57 | ||
55 | //RSA_CRT_PrivateKey rsakey; | 58 | //RSA_CRT_PrivateKey rsakey; |
56 | AsymKey rsakey; | 59 | AsymKey rsakey; |
57 | CyberflexFile file; | 60 | CyberflexFile file; |
58 | CyberflexOS os; | 61 | CyberflexOS os; |
59 | 62 | ||
60 | byte buffer[]; | 63 | byte buffer[]; |
61 | //byte pubkey[]; | ||
62 | 64 | ||
63 | static byte[] keyHdr = {(byte)0xC2, (byte)0x01, (byte)0x05}; | 65 | static byte[] keyHdr = {(byte)0xC2, (byte)0x01, (byte)0x05}; |
64 | 66 | ||
@@ -66,64 +68,64 @@ public class Ssh extends javacard.framework.Applet | |||
66 | { | 68 | { |
67 | file = new CyberflexFile(); | 69 | file = new CyberflexFile(); |
68 | os = new CyberflexOS(); | 70 | os = new CyberflexOS(); |
69 | 71 | ||
70 | rsakey = new RSA_CRT_PrivateKey (keysize); | 72 | rsakey = new RSA_CRT_PrivateKey (keysize); |
71 | rsakey.setKeyInstance ((short)0xc8, (short)0x10); | ||
72 | 73 | ||
73 | if ( ! rsakey.isSupportedLength (keysize) ) | 74 | if ( ! rsakey.isSupportedLength (keysize) ) |
74 | ISOException.throwIt (ISO.SW_WRONG_LENGTH); | 75 | ISOException.throwIt (ISO.SW_WRONG_LENGTH); |
75 | 76 | ||
76 | /* | 77 | register(); |
77 | pubkey = new byte[keysize/8]; | 78 | } // end of the constructor |
78 | file.selectFile((short)(0x3f<<8)); // select root | 79 | |
79 | file.selectFile((short)(('s'<<8)|'h')); // select public key file | 80 | public boolean select() { |
80 | os.readBinaryFile (pubkey, (short)0, (short)0, (short)(keysize/8)); | 81 | if (!rsakey.isInitialized()) |
81 | */ | 82 | rsakey.setKeyInstance ((short)0xc8, (short)0x10); |
82 | register(); | 83 | |
83 | } // end of the constructor | 84 | return true; |
85 | } | ||
84 | 86 | ||
85 | public static void install(APDU apdu) | 87 | public static void install(APDU apdu) |
86 | { | 88 | { |
87 | new Ssh(); // create a Ssh applet instance (card) | 89 | new Ssh(); // create a Ssh applet instance (card) |
88 | } // end of install method | 90 | } // end of install method |
89 | 91 | ||
92 | public static void main(String args[]) { | ||
93 | ISOException.throwIt((short) 0x9000); | ||
94 | } | ||
95 | |||
90 | public void process(APDU apdu) | 96 | public void process(APDU apdu) |
91 | { | 97 | { |
92 | // APDU object carries a byte array (buffer) to | 98 | // APDU object carries a byte array (buffer) to |
93 | // transfer incoming and outgoing APDU header | 99 | // transfer incoming and outgoing APDU header |
94 | // and data bytes between card and CAD | 100 | // and data bytes between card and CAD |
95 | buffer = apdu.getBuffer(); | 101 | buffer = apdu.getBuffer(); |
96 | 102 | ||
97 | // verify that if the applet can accept this | 103 | // verify that if the applet can accept this |
98 | // APDU message | 104 | // APDU message |
99 | // NI: change suggested by Wayne Dyksen, Purdue | 105 | // NI: change suggested by Wayne Dyksen, Purdue |
100 | if (buffer[ISO.OFFSET_INS] == ISO.INS_SELECT) | 106 | if (buffer[ISO.OFFSET_INS] == ISO.INS_SELECT) |
101 | ISOException.throwIt(ISO.SW_NO_ERROR); | 107 | ISOException.throwIt(ISO.SW_NO_ERROR); |
102 | 108 | ||
103 | switch (buffer[ISO.OFFSET_INS]) { | 109 | switch (buffer[ISO.OFFSET_INS]) { |
104 | case DECRYPT: | 110 | case DECRYPT: |
105 | if (buffer[ISO.OFFSET_CLA] != Ssh_CLA) | 111 | if (buffer[ISO.OFFSET_CLA] != Ssh_CLA) |
106 | ISOException.throwIt(ISO.SW_CLA_NOT_SUPPORTED); | 112 | ISOException.throwIt(ISO.SW_CLA_NOT_SUPPORTED); |
107 | //decrypt (apdu); | 113 | //decrypt (apdu); |
108 | short size = (short) (buffer[ISO.OFFSET_LC] & 0x00FF); | 114 | short size = (short) (buffer[ISO.OFFSET_LC] & 0x00FF); |
109 | 115 | ||
110 | if (apdu.setIncomingAndReceive() != size) | 116 | if (apdu.setIncomingAndReceive() != size) |
111 | ISOException.throwIt (ISO.SW_WRONG_LENGTH); | 117 | ISOException.throwIt (ISO.SW_WRONG_LENGTH); |
112 | 118 | ||
113 | rsakey.cryptoUpdate (buffer, (short) ISO.OFFSET_CDATA, size, | 119 | rsakey.cryptoUpdate (buffer, (short) ISO.OFFSET_CDATA, size, |
114 | buffer, (short) ISO.OFFSET_CDATA); | 120 | buffer, (short) ISO.OFFSET_CDATA); |
121 | |||
115 | apdu.setOutgoingAndSend ((short) ISO.OFFSET_CDATA, size); | 122 | apdu.setOutgoingAndSend ((short) ISO.OFFSET_CDATA, size); |
116 | return; | 123 | return; |
117 | case GET_PUBKEY: | 124 | case GET_PUBKEY: |
118 | file.selectFile((short)(0x3f<<8)); // select root | 125 | file.selectFile((short)(0x3f<<8)); // select root |
119 | file.selectFile((short)(('s'<<8)|'h')); // select public key file | 126 | file.selectFile((short)(('s'<<8)|'h')); // select public key file |
120 | os.readBinaryFile (buffer, (short)0, (short)0, (short)(keysize/8)); | 127 | os.readBinaryFile (buffer, (short)0, (short)0, (short)(keysize/8)); |
121 | apdu.setOutgoingAndSend((short)0, (short)(keysize/8)); | 128 | apdu.setOutgoingAndSend((short)0, (short)(keysize/8)); |
122 | /* | ||
123 | apdu.setOutgoing(); | ||
124 | apdu.setOutgoingLength((short)(keysize/8)); | ||
125 | apdu.sendBytesLong(pubkey, (short)0, (short)(keysize/8)); | ||
126 | */ | ||
127 | return; | 129 | return; |
128 | case GET_KEYLENGTH: | 130 | case GET_KEYLENGTH: |
129 | buffer[0] = (byte)((keysize >> 8) & 0xff); | 131 | buffer[0] = (byte)((keysize >> 8) & 0xff); |
@@ -133,24 +135,9 @@ public class Ssh extends javacard.framework.Applet | |||
133 | case GET_RESPONSE: | 135 | case GET_RESPONSE: |
134 | return; | 136 | return; |
135 | default: | 137 | default: |
136 | ISOException.throwIt (ISO.SW_INS_NOT_SUPPORTED); | 138 | ISOException.throwIt (ISO.SW_INS_NOT_SUPPORTED); |
137 | } | 139 | } |
138 | 140 | ||
139 | } // end of process method | 141 | } // end of process method |
140 | 142 | ||
141 | /* | 143 | } // end of class Ssh |
142 | private void decrypt (APDU apdu) | ||
143 | { | ||
144 | short size = (short) (buffer[ISO.OFFSET_LC] & 0x00FF); | ||
145 | |||
146 | if (apdu.setIncomingAndReceive() != size) | ||
147 | ISOException.throwIt (ISO.SW_WRONG_LENGTH); | ||
148 | |||
149 | //short offset = (short) ISO.OFFSET_CDATA; | ||
150 | |||
151 | rsakey.cryptoUpdate (buffer, (short) ISO.OFFSET_CDATA, size, buffer, | ||
152 | (short) ISO.OFFSET_CDATA); | ||
153 | apdu.setOutgoingAndSend ((short) ISO.OFFSET_CDATA, size); | ||
154 | } | ||
155 | */ | ||
156 | } // end of class Ssh | ||