javaextensions/satsa/crypto/javasrc/java/security/MessageDigest.java
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 package java.security;
       
    20 
       
    21 import com.nokia.mj.impl.security.MessageDigestImpl;
       
    22 import java.security.PrivMessageDigestImpl;
       
    23 
       
    24 /**
       
    25  * Refer JSR-177 Specification for details
       
    26  */
       
    27 public abstract class MessageDigest
       
    28 {
       
    29 
       
    30     // MessageDigest implementation
       
    31     private MessageDigestImpl iDigest;
       
    32 
       
    33     // Package private constructor.
       
    34     MessageDigest(MessageDigestImpl aDigest)
       
    35     {
       
    36         iDigest = aDigest;
       
    37     }
       
    38 
       
    39     /**
       
    40     * Refer JSR-177 Specification for details
       
    41     */
       
    42     static public MessageDigest getInstance(String aAlgorithm)
       
    43     throws NoSuchAlgorithmException
       
    44     {
       
    45         MessageDigestImpl digest = new MessageDigestImpl(aAlgorithm);
       
    46         return new PrivMessageDigestImpl(digest);
       
    47     }
       
    48 
       
    49     /**
       
    50     * Refer JSR-177 Specification for details
       
    51     */
       
    52     public int digest(byte[] aBuf, int aOffset, int aLength)
       
    53     throws DigestException
       
    54     {
       
    55         return iDigest.digest(aBuf, aOffset, aLength);
       
    56     }
       
    57 
       
    58     // Resets the digest for further use.
       
    59     public void reset()
       
    60     {
       
    61         iDigest.reset();
       
    62     }
       
    63 
       
    64     /**
       
    65     * Refer JSR-177 Specification for details
       
    66     */
       
    67     public void update(byte[] aInput, int aOffset, int aLength)
       
    68     {
       
    69         iDigest.update(aInput, aOffset, aLength);
       
    70     }
       
    71 }