|
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: Provides the functionality of a digital signature algorithm |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef STSSIGNATURE_H |
|
20 #define STSSIGNATURE_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <jni.h> |
|
25 #include <openssl/evp.h> |
|
26 #include "javajniutils.h" |
|
27 |
|
28 namespace java |
|
29 { |
|
30 namespace satsa |
|
31 { |
|
32 |
|
33 /** |
|
34 * STSSignature provides the functionality of a digital signature algorithm. |
|
35 * |
|
36 * Digital signatures are used for authentication and |
|
37 * integrity assurance of digital data. |
|
38 * There are three phases to the use of a Signature object |
|
39 * for verifying a signature: |
|
40 * 1. Initialization, with a public key, which initializes the signature for |
|
41 * verification |
|
42 * 2. Updating Depending on the type of initialization, |
|
43 * this will update the bytes to be verified. |
|
44 * 3. Verifying a signature on all updated bytes. |
|
45 * |
|
46 */ |
|
47 class STSSignature |
|
48 { |
|
49 public: |
|
50 |
|
51 static STSSignature* Create(); |
|
52 |
|
53 virtual ~STSSignature(); |
|
54 |
|
55 public: |
|
56 /** |
|
57 * Initializes this object for verification. If this method is called |
|
58 * again with a different argument, it negates the effect of this call. |
|
59 * |
|
60 * @param aKey The public key of the identity whose signature is going |
|
61 * to be verified. |
|
62 */ |
|
63 virtual int InitVerify(JNIEnv* aJni, jstring aKeyAlgorithm, |
|
64 jstring aKeyFormat, jbyteArray aKeyEncoded) = 0; |
|
65 |
|
66 /** |
|
67 * Updates the data to be verified. |
|
68 * |
|
69 * @param aData Data for update. |
|
70 */ |
|
71 virtual int Update(JNIEnv* aJni, jbyteArray aData, jint aOffset, |
|
72 jint aLength); |
|
73 |
|
74 /** |
|
75 * Verifies the passed-in signature. |
|
76 * A call to this method resets this signature object to the state it |
|
77 * was in when previously initialized for verification via a call to |
|
78 * InitVerify. That is, the object is reset and available to verify |
|
79 * another signature from the identity whose public key was specified |
|
80 * in the call to InitVerify. |
|
81 * |
|
82 * @param aSignature The signature to be verified. |
|
83 * @return ETrue if the signature was verified, EFalse if not. |
|
84 */ |
|
85 virtual int Verify(JNIEnv* aJni, jbyteArray aSignature) = 0; |
|
86 |
|
87 protected: |
|
88 |
|
89 STSSignature(); |
|
90 |
|
91 protected: |
|
92 |
|
93 EVP_MD_CTX *mdctx; |
|
94 const EVP_MD *md; |
|
95 bool mIsUpdated; |
|
96 }; |
|
97 } // namespace satsa |
|
98 } // namespace java |
|
99 #endif // STSSIGNATURE_H |
|
100 // End of File |