/*## (c) SECURITY EXPLORATIONS    2018 poland                                #*/
/*##     http://www.security-explorations.com                                #*/

/* THIS SOFTWARE IS PROTECTED BY DOMESTIC AND INTERNATIONAL COPYRIGHT LAWS    */
/* UNAUTHORISED COPYING OF THIS SOFTWARE IN EITHER SOURCE OR BINARY FORM IS   */
/* EXPRESSLY FORBIDDEN. ANY USE, INCLUDING THE REPRODUCTION, MODIFICATION,    */
/* DISTRIBUTION, TRANSMISSION, RE-PUBLICATION, STORAGE OR DISPLAY OF ANY      */
/* PART OF THE SOFTWARE, FOR COMMERCIAL OR ANY OTHER PURPOSES REQUIRES A      */
/* VALID LICENSE FROM THE COPYRIGHT HOLDER.                                   */

/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS    */
/* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,*/
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    */
/* SECURITY EXPLORATIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF  */
/* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE     */
/* SOFTWARE.                                                                  */

import java.lang.*;

public class SCInfo {
 public static final int PAD   = 25;

 int version;
 int sys_id;
 int emm_pid;
 byte unique_addr[];
 byte shared_addr[];

 public SCInfo(int ver,int id,int epid,byte uaddr[],byte saddr[]) {
  version=ver;
  sys_id=id;
  emm_pid=epid;
  unique_addr=uaddr;
  shared_addr=saddr;
 }

 public static String addr2string(byte tab[]) {
  String s="";
  for(int i=0;i<tab.length;i++) {
   s+=Utils.hex_value(tab[i]&0xff,2);
   if (i<(tab.length-1)) s+=":";
  }

  return s;
 }

 public byte[] unique_addr() {
  return unique_addr;
 }

 public byte[] shared_addr() {
  return shared_addr;
 }

 public void print() throws Throwable {
  Output.text("[card info]");
  String s="- "+Utils.padded_string("version",PAD)+Utils.hex_value(version,2);
  Output.text(s);

  s="- "+Utils.padded_string("CA sys_id",PAD)+Utils.hex_value(sys_id,4);
  Output.text(s);

  s="- "+Utils.padded_string("EMM pid",PAD)+Utils.hex_value(emm_pid,4);
  Output.text(s);

  s="- "+Utils.padded_string("unique addr",PAD)+addr2string(unique_addr);
  Output.text(s);

  s="- "+Utils.padded_string("shared addr",PAD)+addr2string(shared_addr);
  Output.text(s);
 }
}
