예제 #1
0
        public virtual int sceMd5BlockInit(TPointer contextAddr)
        {
            md5.reset();

            // size of context seems to be 32 + 64 bytes
            contextAddr.setValue32(0, 0x67452301);
            contextAddr.setValue32(4, 0xEFCDAB89);
            contextAddr.setValue32(8, 0x98BADCFE);
            contextAddr.setValue32(12, 0x10325476);
            contextAddr.setValue16(20, (short)0);
            contextAddr.setValue16(22, (short)0);
            contextAddr.setValue32(24, 0);
            contextAddr.setValue32(28, 0);
            // followed by 64 bytes, not being initialized here (probably the data block being processed).

            return(0);
        }
        /**
         * Appends the authorization string to the StringBuilder.
         */
        private static void appendResponse(StringBuilder sb,
                                           string user,
                                           string realm,
                                           string pass,
                                           string requestMethod,
                                           string uri,
                                           string nonce,
                                           string nc,
                                           string cnonce,
                                           string qop,
                                           string algorithm)
        {
            MessageDigest resultDigest  = null;
            MessageDigest scratchDigest = null;

            try {
                resultDigest  = MessageDigest.getInstance(algorithm);
                scratchDigest = MessageDigest.getInstance(algorithm);
            }
            catch (NoSuchAlgorithmException e) {
                throw new QuercusModuleException(e);
            }

            {
                md5(scratchDigest, user);
                scratchDigest.update((byte)':');

                md5(scratchDigest, realm);
                scratchDigest.update((byte)':');

                md5(scratchDigest, pass);

                update(resultDigest, scratchDigest.digest());
                resultDigest.update((byte)':');
            }

            md5(resultDigest, nonce);
            resultDigest.update((byte)':');

            md5(resultDigest, nc);
            resultDigest.update((byte)':');

            md5(resultDigest, cnonce);
            resultDigest.update((byte)':');

            md5(resultDigest, qop);
            resultDigest.update((byte)':');

            {
                scratchDigest.reset();

                md5(scratchDigest, requestMethod);
                scratchDigest.update((byte)':');

                md5(scratchDigest, uri);

                update(resultDigest, scratchDigest.digest());
            }

            appendHex(sb, resultDigest.digest());
        }