<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    JSS part rolled in comments, please review again:<br>
<a class="moz-txt-link-freetext" href="https://bugzilla.redhat.com/attachment.cgi?id=571545&action=diff&context=patch&collapsed=&headers=1&format=raw">https://bugzilla.redhat.com/attachment.cgi?id=571545&action=diff&context=patch&collapsed=&headers=1&format=raw</a><br>
    <br>
    Note: all other CS components have dependency on the availability of
    this patch, so this one needs to be ack'd separately ahead of time.<br>
    <br>
    thanks,<br>
    Christina<br>
    <br>
    <br>
    On 03/19/2012 06:00 PM, Christina Fu wrote:
    <blockquote cite="mid:4F67D6CA.6040302@redhat.com" type="cite">On
      03/19/2012 05:41 PM, John Magne wrote:
      <br>
      <blockquote type="cite">
        <br>
        Took a look at this patch for ECC support.
        <br>
        <br>
        Comments and questions below.
        <br>
        <br>
        <br>
        1.
        <br>
        <br>
        KeyRecord.java line 273
        <br>
        <br>
             public MetaInfo getMetaInfo() throws EBaseException {
        <br>
        <br>
                 return mMetaInfo;
        <br>
        <br>
             }
        <br>
        <br>
        <br>
        Why does this throw the EBaseException?
        <br>
        All it does is return a value.
        <br>
        <br>
      </blockquote>
      <br>
      yes, it does not need to declare such throw of exception, even
      though it is the trend in that file and I was just copying them. 
      Will change.
      <br>
      <br>
      <blockquote type="cite">2.
        <br>
        <br>
        <br>
        CryptUtil.java line 186
        <br>
        <br>
                 if (sensitive == 1 )
        <br>
        <br>
                     keygen.sensitivePairs(true);
        <br>
        <br>
                 else if (sensitive == 0)
        <br>
        <br>
                     keygen.sensitivePairs(false);
        <br>
        <br>
                 if (extractable == 1 )
        <br>
        <br>
                     keygen.extractablePairs(true);
        <br>
        <br>
                 else if (extractable == 0)
        <br>
        <br>
                     keygen.extractablePairs(false);
        <br>
        <br>
        <br>
                 keygen.initialize(keysize);
        <br>
        <br>
        <br>
        <br>
        <br>
        The values extractable and sensitive are sent in as integer?
        <br>
        Should they be a boolean? I see the function calls have -1,-1
        <br>
        for those two final params. How does not setting sensitive and
        <br>
        extractable different from setting them to false?
        <br>
        <br>
        I can see this being normal.
        <br>
      </blockquote>
      <br>
      As explained in the comment, the definitions are defined in JSS
      <br>
      pkcs11/PK11KeyPairGenerator.java, so I just followed the
      definition.
      <br>
      For your information, here is what it says in JSS:
      <br>
            private boolean temporaryPairMode = false;
      <br>
            //  1: sensitive
      <br>
            //  0: insensitive
      <br>
            // -1: sensitive if temporaryPairMode is false,
      <br>
            //     insensitive if temporaryPairMode is true
      <br>
            //     (the default depends on temporaryPairMode for
      backward
      <br>
            //     compatibility)
      <br>
            private int sensitivePairMode = -1;
      <br>
            //  1: extractable
      <br>
            //  0: unextractable
      <br>
            // -1: unspecified (token dependent)
      <br>
            private int extractablePairMode = -1;
      <br>
      <br>
      <blockquote type="cite">
        <br>
        3.
        <br>
        <br>
        RecoveryService.java  line 363
        <br>
        <br>
        <br>
                if (!isRSA) {
        <br>
                     CMS.debug("RecoverService: recoverKey: key to
        recover is RSA");
        <br>
                } else {
        <br>
        <br>
                     CMS.debug("RecoverService: recoverKey: key to
        recover is not RSA");
        <br>
                }
        <br>
        <br>
        Would it not be simpler to print out the value of isRSA?
        <br>
      </blockquote>
      <br>
      It really does not matter.  A smarter question would be, why did I
      even
      <br>
      bother to have "isRSA" parameter for this method? The reason is
      that
      <br>
      there is an existing recoverKey for RSA, and the function
      signature does
      <br>
      not take return type into account so it doesn't allow
      polyinstantiation
      <br>
      of the function unless I add one more parameter to it.  So I added
      this
      <br>
      isRSA param which really serves no purpose other than getting the
      JAVA compiler to comply.
      <br>
      That said, I'll change it so that it prints isRSA instead.
      <br>
      <br>
      <blockquote type="cite">
        <br>
        4.
        <br>
        <br>
        EnrollmentService.java line 451
        <br>
        <br>
                         metaInfo.set("EllipticCurve", oidDescription);
        <br>
        <br>
        I think in KeyRecord.java you have a static public member
        variable for "EllipticCurve"
        <br>
        Probably should use that here for clarity.
        <br>
      </blockquote>
      <br>
      Will do
      <br>
      <br>
      <blockquote type="cite">
        <br>
        5.
        <br>
        <br>
        ASN1Util.c line 58
        <br>
        <br>
        SECItem *oid;
        <br>
        <br>
        Initialize to null?
        <br>
      </blockquote>
      <br>
      will do
      <br>
      <br>
      <blockquote type="cite">
        <br>
        6.
        <br>
        <br>
        <br>
        ASN1Util.c line 78
        <br>
        <br>
                 oidTag = SECOID_FindOIDTag(oid);
        <br>
        <br>
                 if (oidTag == SEC_OID_UNKNOWN) {
        <br>
        <br>
                     JSS_throwMsg(env, INVALID_PARAMETER_EXCEPTION,
        <br>
        <br>
                         "JSS getTagDescriptionByOid: OID UNKNOWN");
        <br>
        <br>
                     goto finish;
        <br>
        <br>
                 }
        <br>
        <br>
        What if oidTag is null? Perhaps the call can never return this
        but some well known constant?
        <br>
      </blockquote>
      <br>
      It can't be.  It was initialized to SEC_OID_UNKNOWN, and NSS
      returns
      <br>
      SEC_OID_UNKNOWN to you as well if it can't find it.
      <br>
      I will add comment to explain.
      <br>
      <br>
      <br>
      <blockquote type="cite">
        <br>
        7.
        <br>
        <br>
        <br>
        ASN1Uti.java line 126
        <br>
        <br>
        Question, it looks like the routine takes in an entire public
        key blob as input.
        <br>
        Would there be some simpler input that could end up giving us
        the same answer? I do not know.
        <br>
      </blockquote>
      There isn't any.  You would have to require callers to parse down
      the
      <br>
      pubkey if we take a smaller byte array for this function.
      <br>
      <br>
      <blockquote type="cite">
        <br>
        8.
        <br>
        <br>
        Also, the routine throws a InvalidBERException exception or some
        such.
        <br>
        <br>
        There are a bunch of calls to methods such as :
        Arrays.copyOfRange
        <br>
        <br>
        That method appears to throw the following exceptions:
        <br>
        <br>
             ArrayIndexOutOfBoundsException -
        <br>
             IllegalArgumentException -
        <br>
             NullPointerException -
        <br>
        <br>
        Instead of catching only an "Exception" and forcing a
        "InvalidBERException", would it make sense to
        <br>
        declare the function to also throw those exceptions?
        <br>
        <br>
      </blockquote>
      will do
      <br>
      <blockquote type="cite">8.
        <br>
        <br>
        <br>
        Should we check for  X509PubKeyBytes input parameter for null?
        <br>
      </blockquote>
      will do
      <br>
      <blockquote type="cite">
        <br>
        9.
        <br>
        <br>
        <br>
        File displayBySerial.template line 103
        <br>
        <br>
        if ((result.header.keyLength == null) ||
        (result.header.keyLength<= 0))  {
        <br>
        <br>
        It looks like we use the above check to assume an ECC key. Is
        this the best way to make
        <br>
        this determination? Is there any info that actually tells us we
        have an ECC key instead of this
        <br>
        lack of information?
        <br>
        <br>
        Actually it looks like this check is used everywhere in this
        part of the patch when a decision is needed.
        <br>
        <br>
        <br>
      </blockquote>
      I wonder about that myself.  I use rec.EllipticCurve != null at
      certain
      <br>
      places which worked well, but at some specific places, I couldn't
      for
      <br>
      some reason.  That's why I used<=0 check.
      <br>
      I can try again.
      <br>
      <blockquote type="cite">
        <br>
        <br>
        <br>
        <br>
        ----- Original Message -----
        <br>
        From: "Christina"<a class="moz-txt-link-rfc2396E" href="mailto:cfu@redhat.com"><cfu@redhat.com></a>
        <br>
        To: <a class="moz-txt-link-abbreviated" href="mailto:pki-devel@redhat.com">pki-devel@redhat.com</a>
        <br>
        Sent: Wednesday, March 14, 2012 2:49:37 PM
        <br>
        Subject: [Pki-devel] patches for review - ECC key archival /
        recovery feature implementation - Bug 745278 - [RFE] ECC
        encryption keys cannot be archived
        <br>
        <br>
        <br>
        <br>
        This is the ECC phase 2 implementation (ECC key archival /
        recovery feature) in the JSS and DRM (KRA)
        <br>
        <br>
        Bug: Bug 745278 - [RFE] ECC encryption keys cannot be archived
        <br>
        <br>
        Please review the following patches (see "BEFORE you review" at
        later part of this email):
        <br>
        <br>
        *
<a class="moz-txt-link-freetext" href="https://bugzilla.redhat.com/attachment.cgi?id=570109&action=diff&context=patch&collapsed=&headers=1&format=raw">https://bugzilla.redhat.com/attachment.cgi?id=570109&action=diff&context=patch&collapsed=&headers=1&format=raw</a><br>
        *
<a class="moz-txt-link-freetext" href="https://bugzilla.redhat.com/attachment.cgi?id=570110&action=diff&context=patch&collapsed=&headers=1&format=raw">https://bugzilla.redhat.com/attachment.cgi?id=570110&action=diff&context=patch&collapsed=&headers=1&format=raw</a><br>
        *
<a class="moz-txt-link-freetext" href="https://bugzilla.redhat.com/attachment.cgi?id=570112&action=diff&context=patch&collapsed=&headers=1&format=raw">https://bugzilla.redhat.com/attachment.cgi?id=570112&action=diff&context=patch&collapsed=&headers=1&format=raw</a><br>
        <br>
        thanks,
        <br>
        Christina
        <br>
        ==============
        <br>
        BEFORE you review:
        <br>
        <br>
        For the ECC plan and design for the different phases, please
        refer to <a class="moz-txt-link-freetext" href="http://pki.fedoraproject.org/wiki/ECC_in_Dogtag">http://pki.fedoraproject.org/wiki/ECC_in_Dogtag</a>
        <br>
        <br>
        Note: the designs beyond phase 2 were more like a brain dump.
        Although I said "Do Not Review," you are free to take a peak at
        what's intended down the road. I will go back and take a closer
        look and refine/adjust the designs when I begin implementation
        for each new phase.
        <br>
        <br>
        This patch contains code for the following packages:
        <br>
        JSS, pki-kra, pki-common, pki-util, and pki-kra-ui
        <br>
        <br>
        What you need to know:
        <br>
        <br>
        * Problem 1 - nethsm issue:
        <br>
        On the server side, if you turn on FIPS mode, in addition to
        nethsm, you need to attach certicom as well to have ECC SSL
        working on the server side. This problem has already been
        reported to Thales last year and they said they'd look into
        putting the item on their next release. Recently through a
        different contact, we learned there might be a way to "turn it
        on" (still waiting for their further instruction)
        <br>
        <br>
        * Problem 2- Certicom issue:
        <br>
        This is a show-stopper. Initially, on the client side, I used
        Kai's special version of Xulrunner/Firefox, attached to Certicom
        token, so that the CRMF requests can be generated with key
        archival option. However, I encountered (or, re-encountered) an
        issue with certicom token. Certicom generates ECC keys with the
        wrong format (not PKCS7 conforming), which makes ECC key
        archival impossible on the server side if you use non-certicom
        token with DRM (but we expect an HSM in most product
        deployment). I have contacted Certicom for this issue, and they
        confirmed that they indeed have such issue. We are waiting for
        their fix.
        <br>
        <br>
        But then you might ask, "I thought I saw some ECC enrollment
        profiles/javascripts being checked in? How were the tests done?"
        The tests for those profiles were done against this ECC key
        archival/recovery DRM prototype I implemented last year (needs
        to be turned on manually in 8.1), where I "cheated" (yeah,
        that's why it's called a prototype) by decrypting the private
        key in the CRMF on DRM, and then manipulating the byte array to
        strip off the offending bytes before archival.
        <br>
        In the real, non-prototype implementation, which is what's in
        this patch, for security reasons, private keys are unwrapped
        directly onto the token during key archival, so there is no way
        to manipulate the keys in memory and bypass the Certicom issue.
        <br>
        <br>
        A word about Kai's special version of Xulrunner/Firefox. It is
        not yet publicly available.
        <br>
        <br>
        * Problem 3- Firefox with nethsm issue:
        <br>
        Another option was to connect Kai's special version firefox with
        an HSM to test my DRM/JSS code. However, for whatever reason, I
        could not get SSL going between such Firefox and ECC CA ( I did
        not try very hard though, as I have one other option -- writing
        my own ECC CRMF generation tool. I might come back to try the
        nethsm Firefox idea later)
        <br>
        <br>
        My solution (how I work on this official implementation):
        <br>
        * I hacked up a ECC CRMF tool by taking the CRMFPopClient
        (existing in current releases), gutting out the RSA part of the
        code, and replacing it with ECC code. I call it CRMFPopClientEC.
        Two types of ECC key pairs could be generated: ECDSA or ECDH
        (That's another benefit of writing my own tool -- I don't know
        if you can select which type to generate in the Javascript...
        maybe you can, I just don't know). I'm in no way condoning
        archival of signing keys!! This is just a test tool.
        <br>
        This tool takes a curve name as option (along with others),
        generates an ECC key pair, crafts up an CRMF request with key
        archival option, and sends request directly to the specified CA.
        You will see a "Deferred" message in the HTML response (see
        attachment for example)
        <br>
        Once CA agent approves the request, the archival request goes to
        DRM and the user private key is archived.
        <br>
        For recovery, DRM agent selects key recovery, etc, and you get
        your pkcs12.
        <br>
        <br>
        I did some sanity test with the pkcs12 recovered:
        <br>
        * Import the recovered pkcs12 into a certicom library:
        <br>
        pk12util -d . -h "Certicom FIPS Cert/Key Services" -i userEC.p12
        <br>
        <br>
        I also tested by retrieving a p12, importing it into a browser,
        and adding the user as an agent and the user could act as agent
        via ssl client auth to the CA.
        <br>
        <br>
        Finally, much of the RSA-centric code had been cleared out of
        the way at the time when I worked on the DRM ECC prototype, so
        you don't see much of that in this round.
        <br>
        <br>
        About SELinux:
        <br>
        I have a set of rules generated on my system to run in enforcing
        mode. I do a writeup.
        <br>
        <br>
        For QE:
        <br>
        How to set up the servers? The internal wiki is at
        <a class="moz-txt-link-freetext" href="https://wiki.idm.lab.bos.redhat.com/export/idmwiki/Working_with_ECC">https://wiki.idm.lab.bos.redhat.com/export/idmwiki/Working_with_ECC</a>
        . I might have given someone a copy of how to set up ECC CA to
        publish on fedora.org when I worked on phase1 back a couple
        years ago. I will put an updated copy to cover both CA and DRM
        when I am checking in to dogtag.
        <br>
        <br>
        How do you test? Well, unless you want to use my CRMFPopClientEC
        tool hooked up with a nethsm (like I did), or write your own
        tool, you can't really test it until Certicom fixes their issue.
        (BTW CRMFPopClientEC can also be changed to work with ceriticom,
        although you would run into the same issue I mentioned above)
        <br>
        It is not on my schedule to work on this tool; It is certainly
        not in production quality to be released as a regular tool.
        However, if you are interested in it, if we get enough request
        maybe we can think about doing something with it.
        <br>
        Other test suggestion: I did not try to clone the ECC DRM. It's
        a good idea to test it out.
        <br>
        <br>
        For techpub:
        <br>
        TBD
        <br>
        <br>
        _______________________________________________
        <br>
        Pki-devel mailing list
        <br>
        <a class="moz-txt-link-abbreviated" href="mailto:Pki-devel@redhat.com">Pki-devel@redhat.com</a>
        <br>
        <a class="moz-txt-link-freetext" href="https://www.redhat.com/mailman/listinfo/pki-devel">https://www.redhat.com/mailman/listinfo/pki-devel</a>
        <br>
      </blockquote>
      <br>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Pki-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Pki-devel@redhat.com">Pki-devel@redhat.com</a>
<a class="moz-txt-link-freetext" href="https://www.redhat.com/mailman/listinfo/pki-devel">https://www.redhat.com/mailman/listinfo/pki-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>