From 14dd8cc0789de0d0518038b5d0410b7f751b207a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 7 May 2014 16:31:28 +0200 Subject: [PATCH 01/28] Initial import from main repo --- .gitignore | 29 ++ AndroidManifest.xml | 13 + LICENSE | 202 +++++++++++++ build.gradle | 35 +++ build.xml | 92 ++++++ proguard-project.txt | 20 ++ project.properties | 15 + .../ic_action_cancel_launchersize.png | Bin 0 -> 1520 bytes .../ic_action_cancel_launchersize_light.png | Bin 0 -> 1940 bytes .../ic_action_cancel_launchersize.png | Bin 0 -> 1032 bytes .../ic_action_cancel_launchersize_light.png | Bin 0 -> 1098 bytes .../ic_action_cancel_launchersize.png | Bin 0 -> 1570 bytes .../ic_action_cancel_launchersize_light.png | Bin 0 -> 2039 bytes .../ic_action_cancel_launchersize.png | Bin 0 -> 2345 bytes .../ic_action_cancel_launchersize_light.png | Bin 0 -> 2404 bytes res/values/strings.xml | 7 + .../openintents/openpgp/IOpenPgpService.aidl | 24 ++ src/org/openintents/openpgp/OpenPgpError.java | 118 ++++++++ .../openpgp/OpenPgpSignatureResult.java | 163 +++++++++++ .../openintents/openpgp/util/OpenPgpApi.java | 270 ++++++++++++++++++ .../openpgp/util/OpenPgpListPreference.java | 257 +++++++++++++++++ .../util/OpenPgpServiceConnection.java | 118 ++++++++ .../openpgp/util/OpenPgpUtils.java | 76 +++++ .../util/ParcelFileDescriptorUtil.java | 103 +++++++ 24 files changed, 1542 insertions(+) create mode 100644 .gitignore create mode 100644 AndroidManifest.xml create mode 100644 LICENSE create mode 100644 build.gradle create mode 100644 build.xml create mode 100644 proguard-project.txt create mode 100644 project.properties create mode 100644 res/drawable-hdpi/ic_action_cancel_launchersize.png create mode 100644 res/drawable-hdpi/ic_action_cancel_launchersize_light.png create mode 100644 res/drawable-mdpi/ic_action_cancel_launchersize.png create mode 100644 res/drawable-mdpi/ic_action_cancel_launchersize_light.png create mode 100644 res/drawable-xhdpi/ic_action_cancel_launchersize.png create mode 100644 res/drawable-xhdpi/ic_action_cancel_launchersize_light.png create mode 100644 res/drawable-xxhdpi/ic_action_cancel_launchersize.png create mode 100644 res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png create mode 100644 res/values/strings.xml create mode 100644 src/org/openintents/openpgp/IOpenPgpService.aidl create mode 100644 src/org/openintents/openpgp/OpenPgpError.java create mode 100644 src/org/openintents/openpgp/OpenPgpSignatureResult.java create mode 100644 src/org/openintents/openpgp/util/OpenPgpApi.java create mode 100644 src/org/openintents/openpgp/util/OpenPgpListPreference.java create mode 100644 src/org/openintents/openpgp/util/OpenPgpServiceConnection.java create mode 100644 src/org/openintents/openpgp/util/OpenPgpUtils.java create mode 100644 src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..aa8bb5760 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +#Android specific +bin +gen +obj +lint.xml +local.properties +release.properties +ant.properties +*.class +*.apk + +#Gradle +.gradle +build +gradle.properties + +#Maven +target +pom.xml.* + +#Eclipse +.project +.classpath +.settings +.metadata + +#IntelliJ IDEA +.idea +*.iml diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 000000000..98cb89faa --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/build.gradle b/build.gradle new file mode 100644 index 000000000..69b937c1a --- /dev/null +++ b/build.gradle @@ -0,0 +1,35 @@ +// please leave this here, so this library builds on its own +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:0.10.0' + } +} + +apply plugin: 'android-library' + +android { + compileSdkVersion 19 + buildToolsVersion '19.0.3' + + // NOTE: We are using the old folder structure to also support Eclipse + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + } + + // Do not abort build if lint finds errors + lintOptions { + abortOnError false + } +} diff --git a/build.xml b/build.xml new file mode 100644 index 000000000..48ebf198c --- /dev/null +++ b/build.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proguard-project.txt b/proguard-project.txt new file mode 100644 index 000000000..f2fe1559a --- /dev/null +++ b/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/project.properties b/project.properties new file mode 100644 index 000000000..91d2b0246 --- /dev/null +++ b/project.properties @@ -0,0 +1,15 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-19 +android.library=true diff --git a/res/drawable-hdpi/ic_action_cancel_launchersize.png b/res/drawable-hdpi/ic_action_cancel_launchersize.png new file mode 100644 index 0000000000000000000000000000000000000000..71b9118dc0f992fc88cf91375090f1c04fc76e84 GIT binary patch literal 1520 zcmVtkNV_&UONB z1J};M3SN_RJ8T+Ttx+8#srdT}@FQ?f(ubV$b4kBT`jk@o;`5V?p7JqmUj**PLM;Gu zwqHnkJB|$_IjA^M&N+p1egu*mO_QN_kJJC4xeqf!Dx? z;N6n2Juj&ZtmT}Mv?b}FgyhK1>Veg)?G<1RXalXVL4d-x*OETh?x2*?A@C~poU0Kz z^MHXF+qYsbcxQWO9NhY0W&66M`?lMXW^89kNcsru*?yiFtC~_e05;>j zgv;A(OMk8_AJ(CwYO|Pvb|^fD2|^cwIai;kD1+8fOTL|Qp!2rixW%h@Exc)C-vsZhzQ*78kl~`%XWsfW8@U(rQ)Zpl;maf=c(msS!^KZokz8%jM#E)$f?JIrTE{n?fn9=Djx*Y z?x4t6r`}tYHtC}>Vzw_xx(wU_u1umc`L!U{uL#@+-o$HvkbAeUI)Y9s6eDtqLXqe~ zzO?-;zOx*WQ+%ef2LZJ^Xb`M=6@kEJk*#d+OS&>ltE4L2(v-34*$Irlhia8n6+x;C ztJ7K*-9_Ml_io#^H-Pis?&ybA(O@66WijNv+bu~8wkyT0O2k%(2Kz8Ai(y+Ok}Abb z=LM@#n)Y?z)|xg}z3#0FOp4=A6Sqk}7dwGfIOhablC}m4?H(&1-#vj_v_(3&g$)zK zP3HxxQP0KkL`P+~jWs|Oh!n#Ml{DDL!0m0$xih>lY9vi!lm3b0$*#`x_`vEAcqQo( zuv3nlNsYfmb-r%9bJH8qR8;3rB>g&-G#}HXZH{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uani~NlpV^u%wvE+30(%w$`>DX`5pWy0De2FV*>Bi>E#|KtZ~^$n>^3_8{Z9la z%QBKA*@IOrut#uKqKw=2rldQzZTQ8=f{yO$n%^uO)1NgBuO?UJpqm+m9&N1Vw+fn z5;(+4(z6K8CU6J15m*6`rYW|EdQw$YkJ2>V0?ybTi<_iYaa%YEtoD;E>Q4JO%4A5f zt>L!VCRUO%+lMNFbx%_(foYnOBuP`L+_ZgUWpb9dO>??qY!f&ufqmS*+c;%1vhrbc z+%s<`r$%hF3ABAJzQA&*h6iG`-?^P}`);GSMJ5g6USpfdY3H|D9l=vLw(r*Ss1kUb zt><{ZfbYiBy9~TtV--!{)Jot%xJ8g^WwI~nAHe6)NBuq4KA!|) zvV9hKH>y<@BK#oEDIOcE!=#dNxY;g%jR;P?5s<~a_bx9FRB7&2EKSqXaW?ViQOds) zO`Rn@0!m6}wC$D9v$uf9CvkwP2mAo|p`?`mp22wn z+#PKKXQAPY3sT)o#*Fr6=t{f5=?LCeFW)*@fTlt0S#-m{;pKrz@$x{`9pK|>u{thp zwm%Mkw!)X|;oF_?b$*D|6``uC=V_X5#P-Yu;0xe0N$b;MH34p0ygbO>12!f74!B literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/ic_action_cancel_launchersize.png b/res/drawable-mdpi/ic_action_cancel_launchersize.png new file mode 100644 index 0000000000000000000000000000000000000000..270abf45fdd55510fc885046717a66bd73cc9379 GIT binary patch literal 1032 zcmV+j1o!)iP)cc zK~!ko?U*}n6iF0?zf&H`Uda4NNrr$;On?v;j>rh?V1!5riSe&-z9HF)00(4_jAn(b zl^j?bFv+HX1EXb)wA3NFZS~Hh-R*8?eWQ`O>fWmAZ|*tO&_^GA^wCEj6_Il$=Un-` zP422^wy(^Q+HO$Njm)i^w{~^gw}CshA4vLW`$J0UM{!z`Y8Nd|wiustUXt_>xCYfI^BTn2f#C68F&or zNgCQ#lhjgU;^v|hqhA`ei8^Q#AzBE+e1lvF*n;zz#*_NX%e-%*+5wb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Ukeoc+?WX{zLF`KjzgCvbZ2qO5x@e;% zpBpw;;{3Y`94JFA+Mo&dcNk00z!<#OBVU&H;&21Uazv8Z@Up(~MuWcA1D$;d?l}gK zzkwh7SsSgyKC|YsvjN?>c6S8@}nmTrbI;(LtwoyY{4b1?P(PEyq_KhlF9KS{qIs#Jp vgKLXCc{2(za7-%QWB2;e-GCp+leZz4glXscvESez$eI5EA(-c} literal 0 HcmV?d00001 diff --git a/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png b/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png new file mode 100644 index 0000000000000000000000000000000000000000..d505046b4d59b4c26511f68b404cdbc4f933edff GIT binary patch literal 2039 zcmaJ?eKZq}8lGV*`N+44_=#G+lFu@f^0lU+D3hYlSY||%)@D>ftk5MNW0_w{WMd{I zE1`(Rtu{8yRHL?pntmu(_y2pJ_dM@&&U4=L{PUjoyg7kLUo{m&6#xLB2KVzivaXST zxB;}@#dlKotPAK2!q*G1_NQo_wMFaB#za3 z7ChKBzV2LwdwB+59FtYZa5_BQ-t?Q3jNQr)%MRS{)71G1n6s0#|o?!OViK<)d*KnqVtZSlk7(XWU#|9amsQA(I=lekDK31>}r{%^$L z-_9+~F0Fh>BZ-!-6DO37-+fwkN{AC0LvySDX(j9KXQyURo2=JI{4PzU*SddW?;L2_ z`oSVnlObzpvL=R_q(9UP`zo+Z9F=F*5ZG%QRn0FX$X&)9H7-Z4xWl;_yE1CA)YQ8@ zs2{~L4GW@KT#vkpobSd>x6D1$nm_veM5i-%(Obmj?1iT*u*o~pDkq`2Vo$3q+}(pf zB>#8tNY5R3U&b0>5-!bD?bwVZMiamnkB?XgBD^MDZ<>yt z%0qQo&T4*hz!iptGn`1~qu=K|zAO#-Q zLOd{XnU=7*v4|ajuxE^Z`9XSAms?jiv$PV8@(BrPP`lj7+tM=x5jnuCfVE^BIDzvd z%XUHMv6}F9a7c*LjAN#`3^1t}ai|^S*4i0Q7?N*g*u*h=3ujhz|pKL@b4BNO=!#$Ub zrTmGOPW5mm@u7MNwl(wRdm7;-P@=^+yOJ_Ke@AJ6)1Afa)iO5Ll7*{CD=4wG@0|Sy z0d#{LeL89ab?<4COAK*eyCSsF3gf8BhD@#)u^B zeKXIj33whU;8e;keZnb?oqA02*M?CS{+qWK-bYsXd0h1aY(H1t%w9y`>J>=dDUSM~ zW*&_Z)V`s&bQ&**63-hRR!_9vo*%^k7lP&|=ErvnU~C>Xb^BQ9MvXm6z6jNaR=?F( z)h=2+5t$AuY8ZT-BB=>+UWcg9kPX-$fqa#g01;WVQ5RJoLfMAcM!_72a*V7d;Q2(Yk-9W) zRnv}pA{<(yRx)K40`BM79eQDlY{@nred@1O)zCs#6)g9b^Ix%fX?K5J3te3`rh(nc zudQ;S4z(WNP{sLYB>s^S{g0VUtqD+q7jlMV@ImH-iHRhb&PE$>3rRts^(zRox>8XZ z9+;f;HvAV59anSv3(EM_<8$n;f)p1aOLAP=ej2TpRO6xsYtEuOZ+)L3OM}n(o=r6n(l&>?|8)3wk28}=}-N9{+Tl~`IgxB_wuiV zN=YiP+)lV5Eb?cKj)PD%nP)!5cW=pu#tz7j7e2BR+J*y>qZ1n|kw&n_Tzag)wfp+{ zil$B_;mxO)d)BP%+jD3jAN-jT46M59FuWBTL3PBFEGS63%dvgk*>4hbyyqvKkGzla z4s@7C>GWJ7b)}yiF%i2hkxgz?8~7{28Z+o7kgwZT%crI>kMzCgztcSMLjZ8_Rvch0 zJ2BP8vK02fM*!v=&U$yDnDwL31CN+})&T!MpboDAUI&I8C@jCZu>PU}aBrm7qXUtd F{{iyG+f)Dm literal 0 HcmV?d00001 diff --git a/res/drawable-xxhdpi/ic_action_cancel_launchersize.png b/res/drawable-xxhdpi/ic_action_cancel_launchersize.png new file mode 100644 index 0000000000000000000000000000000000000000..52044601e4036ee1da50f18550af7cdf9dc458b0 GIT binary patch literal 2345 zcmb7G`#;l*8=nm;*V8E#)k&|E+>+y%n#*$E$8z81GLq23J}8DIrQ|prb?Pj+PxE!F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slsw<4Sfa?G3Al}2elG`@4{0eS7AEew7UxS^x_Iw9jPp^alA zJdn)N**qR`0MOa&wC$^FJEDO0Dah0&bcLu`JcV#=QN%xPo*_p|N1airdUd|Qx6XD^ zgE;dN6kq1=Rc+JwJI(>|4obqcwf3DNt=2fDH4qC_$C)N`Osp|nuKt-Gs#VSahN`o*V= z$e*{{mugO>GHa`0Nd~T#|KMb`e?~|#%1e8HyjKu@!In_KbkUmJO?VIV9=6<)$neQ$ zbm5j76vN@n0> + + + None + Install OpenKeychain via %s + + \ No newline at end of file diff --git a/src/org/openintents/openpgp/IOpenPgpService.aidl b/src/org/openintents/openpgp/IOpenPgpService.aidl new file mode 100644 index 000000000..7ee79d6ab --- /dev/null +++ b/src/org/openintents/openpgp/IOpenPgpService.aidl @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp; + +interface IOpenPgpService { + + // see OpenPgpApi for documentation + Intent execute(in Intent data, in ParcelFileDescriptor input, in ParcelFileDescriptor output); + +} \ No newline at end of file diff --git a/src/org/openintents/openpgp/OpenPgpError.java b/src/org/openintents/openpgp/OpenPgpError.java new file mode 100644 index 000000000..b894a4609 --- /dev/null +++ b/src/org/openintents/openpgp/OpenPgpError.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Parcelable versioning has been copied from Dashclock Widget + * https://code.google.com/p/dashclock/source/browse/api/src/main/java/com/google/android/apps/dashclock/api/ExtensionData.java + */ +public class OpenPgpError implements Parcelable { + /** + * Since there might be a case where new versions of the client using the library getting + * old versions of the protocol (and thus old versions of this class), we need a versioning + * system for the parcels sent between the clients and the providers. + */ + public static final int PARCELABLE_VERSION = 1; + + // possible values for errorId + public static final int CLIENT_SIDE_ERROR = -1; + public static final int GENERIC_ERROR = 0; + public static final int INCOMPATIBLE_API_VERSIONS = 1; + public static final int NO_OR_WRONG_PASSPHRASE = 2; + public static final int NO_USER_IDS = 3; + + int errorId; + String message; + + public OpenPgpError() { + } + + public OpenPgpError(int errorId, String message) { + this.errorId = errorId; + this.message = message; + } + + public OpenPgpError(OpenPgpError b) { + this.errorId = b.errorId; + this.message = b.message; + } + + public int getErrorId() { + return errorId; + } + + public void setErrorId(int errorId) { + this.errorId = errorId; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + /** + * NOTE: When adding fields in the process of updating this API, make sure to bump + * {@link #PARCELABLE_VERSION}. + */ + dest.writeInt(PARCELABLE_VERSION); + // Inject a placeholder that will store the parcel size from this point on + // (not including the size itself). + int sizePosition = dest.dataPosition(); + dest.writeInt(0); + int startPosition = dest.dataPosition(); + // version 1 + dest.writeInt(errorId); + dest.writeString(message); + // Go back and write the size + int parcelableSize = dest.dataPosition() - startPosition; + dest.setDataPosition(sizePosition); + dest.writeInt(parcelableSize); + dest.setDataPosition(startPosition + parcelableSize); + } + + public static final Creator CREATOR = new Creator() { + public OpenPgpError createFromParcel(final Parcel source) { + int parcelableVersion = source.readInt(); + int parcelableSize = source.readInt(); + int startPosition = source.dataPosition(); + + OpenPgpError error = new OpenPgpError(); + error.errorId = source.readInt(); + error.message = source.readString(); + + // skip over all fields added in future versions of this parcel + source.setDataPosition(startPosition + parcelableSize); + + return error; + } + + public OpenPgpError[] newArray(final int size) { + return new OpenPgpError[size]; + } + }; +} diff --git a/src/org/openintents/openpgp/OpenPgpSignatureResult.java b/src/org/openintents/openpgp/OpenPgpSignatureResult.java new file mode 100644 index 000000000..7a4d799dc --- /dev/null +++ b/src/org/openintents/openpgp/OpenPgpSignatureResult.java @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp; + +import android.os.Parcel; +import android.os.Parcelable; + +import org.openintents.openpgp.util.OpenPgpUtils; + +import java.util.Locale; + +/** + * Parcelable versioning has been copied from Dashclock Widget + * https://code.google.com/p/dashclock/source/browse/api/src/main/java/com/google/android/apps/dashclock/api/ExtensionData.java + */ +public class OpenPgpSignatureResult implements Parcelable { + /** + * Since there might be a case where new versions of the client using the library getting + * old versions of the protocol (and thus old versions of this class), we need a versioning + * system for the parcels sent between the clients and the providers. + */ + public static final int PARCELABLE_VERSION = 1; + + // generic error on signature verification + public static final int SIGNATURE_ERROR = 0; + // successfully verified signature, with certified public key + public static final int SIGNATURE_SUCCESS_CERTIFIED = 1; + // no public key was found for this signature verification + public static final int SIGNATURE_UNKNOWN_PUB_KEY = 2; + // successfully verified signature, but with uncertified public key + public static final int SIGNATURE_SUCCESS_UNCERTIFIED = 3; + + int status; + boolean signatureOnly; + String userId; + long keyId; + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public boolean isSignatureOnly() { + return signatureOnly; + } + + public void setSignatureOnly(boolean signatureOnly) { + this.signatureOnly = signatureOnly; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public long getKeyId() { + return keyId; + } + + public void setKeyId(long keyId) { + this.keyId = keyId; + } + + public OpenPgpSignatureResult() { + + } + + public OpenPgpSignatureResult(int signatureStatus, String signatureUserId, + boolean signatureOnly, long keyId) { + this.status = signatureStatus; + this.signatureOnly = signatureOnly; + this.userId = signatureUserId; + this.keyId = keyId; + } + + public OpenPgpSignatureResult(OpenPgpSignatureResult b) { + this.status = b.status; + this.userId = b.userId; + this.signatureOnly = b.signatureOnly; + this.keyId = b.keyId; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + /** + * NOTE: When adding fields in the process of updating this API, make sure to bump + * {@link #PARCELABLE_VERSION}. + */ + dest.writeInt(PARCELABLE_VERSION); + // Inject a placeholder that will store the parcel size from this point on + // (not including the size itself). + int sizePosition = dest.dataPosition(); + dest.writeInt(0); + int startPosition = dest.dataPosition(); + // version 1 + dest.writeInt(status); + dest.writeByte((byte) (signatureOnly ? 1 : 0)); + dest.writeString(userId); + dest.writeLong(keyId); + // Go back and write the size + int parcelableSize = dest.dataPosition() - startPosition; + dest.setDataPosition(sizePosition); + dest.writeInt(parcelableSize); + dest.setDataPosition(startPosition + parcelableSize); + } + + public static final Creator CREATOR = new Creator() { + public OpenPgpSignatureResult createFromParcel(final Parcel source) { + int parcelableVersion = source.readInt(); + int parcelableSize = source.readInt(); + int startPosition = source.dataPosition(); + + OpenPgpSignatureResult vr = new OpenPgpSignatureResult(); + vr.status = source.readInt(); + vr.signatureOnly = source.readByte() == 1; + vr.userId = source.readString(); + vr.keyId = source.readLong(); + + // skip over all fields added in future versions of this parcel + source.setDataPosition(startPosition + parcelableSize); + + return vr; + } + + public OpenPgpSignatureResult[] newArray(final int size) { + return new OpenPgpSignatureResult[size]; + } + }; + + @Override + public String toString() { + String out = new String(); + out += "\nstatus: " + status; + out += "\nuserId: " + userId; + out += "\nsignatureOnly: " + signatureOnly; + out += "\nkeyId: " + OpenPgpUtils.convertKeyIdToHex(keyId); + return out; + } + +} diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java new file mode 100644 index 000000000..f6a78d0ef --- /dev/null +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -0,0 +1,270 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp.util; + +import android.annotation.TargetApi; +import android.content.Context; +import android.content.Intent; +import android.os.AsyncTask; +import android.os.Build; +import android.os.ParcelFileDescriptor; +import android.util.Log; + +import org.openintents.openpgp.IOpenPgpService; +import org.openintents.openpgp.OpenPgpError; + +import java.io.InputStream; +import java.io.OutputStream; + +public class OpenPgpApi { + + public static final String TAG = "OpenPgp API"; + + public static final int API_VERSION = 3; + public static final String SERVICE_INTENT = "org.openintents.openpgp.IOpenPgpService"; + + /** + * General extras + * -------------- + * + * required extras: + * int EXTRA_API_VERSION (always required) + * + * returned extras: + * int RESULT_CODE (RESULT_CODE_ERROR, RESULT_CODE_SUCCESS or RESULT_CODE_USER_INTERACTION_REQUIRED) + * OpenPgpError RESULT_ERROR (if RESULT_CODE == RESULT_CODE_ERROR) + * PendingIntent RESULT_INTENT (if RESULT_CODE == RESULT_CODE_USER_INTERACTION_REQUIRED) + */ + + /** + * Sign only + *

+ * optional extras: + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput) + * String EXTRA_PASSPHRASE (key passphrase) + */ + public static final String ACTION_SIGN = "org.openintents.openpgp.action.SIGN"; + + /** + * Encrypt + *

+ * required extras: + * String[] EXTRA_USER_IDS (=emails of recipients, if more than one key has a user_id, a PendingIntent is returned via RESULT_INTENT) + * or + * long[] EXTRA_KEY_IDS + *

+ * optional extras: + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput) + * String EXTRA_PASSPHRASE (key passphrase) + */ + public static final String ACTION_ENCRYPT = "org.openintents.openpgp.action.ENCRYPT"; + + /** + * Sign and encrypt + *

+ * required extras: + * String[] EXTRA_USER_IDS (=emails of recipients, if more than one key has a user_id, a PendingIntent is returned via RESULT_INTENT) + * or + * long[] EXTRA_KEY_IDS + *

+ * optional extras: + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput) + * String EXTRA_PASSPHRASE (key passphrase) + */ + public static final String ACTION_SIGN_AND_ENCRYPT = "org.openintents.openpgp.action.SIGN_AND_ENCRYPT"; + + /** + * Decrypts and verifies given input stream. This methods handles encrypted-only, signed-and-encrypted, + * and also signed-only input. + *

+ * If OpenPgpSignatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY + * in addition a PendingIntent is returned via RESULT_INTENT to download missing keys. + *

+ * optional extras: + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput) + *

+ * returned extras: + * OpenPgpSignatureResult RESULT_SIGNATURE + */ + public static final String ACTION_DECRYPT_VERIFY = "org.openintents.openpgp.action.DECRYPT_VERIFY"; + + /** + * Get key ids based on given user ids (=emails) + *

+ * required extras: + * String[] EXTRA_USER_IDS + *

+ * returned extras: + * long[] RESULT_KEY_IDS + */ + public static final String ACTION_GET_KEY_IDS = "org.openintents.openpgp.action.GET_KEY_IDS"; + + /** + * This action returns RESULT_CODE_SUCCESS if the OpenPGP Provider already has the key + * corresponding to the given key id in its database. + *

+ * It returns RESULT_CODE_USER_INTERACTION_REQUIRED if the Provider does not have the key. + * The PendingIntent from RESULT_INTENT can be used to retrieve those from a keyserver. + *

+ * required extras: + * long EXTRA_KEY_ID + */ + public static final String ACTION_GET_KEY = "org.openintents.openpgp.action.GET_KEY"; + + /* Intent extras */ + public static final String EXTRA_API_VERSION = "api_version"; + + public static final String EXTRA_ACCOUNT_NAME = "account_name"; + + // SIGN, ENCRYPT, SIGN_AND_ENCRYPT, DECRYPT_VERIFY + // request ASCII Armor for output + // OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53) + public static final String EXTRA_REQUEST_ASCII_ARMOR = "ascii_armor"; + + // ENCRYPT, SIGN_AND_ENCRYPT + public static final String EXTRA_USER_IDS = "user_ids"; + public static final String EXTRA_KEY_IDS = "key_ids"; + // optional extras: + public static final String EXTRA_PASSPHRASE = "passphrase"; + + // GET_KEY + public static final String EXTRA_KEY_ID = "key_id"; + public static final String RESULT_KEY_IDS = "key_ids"; + + /* Service Intent returns */ + public static final String RESULT_CODE = "result_code"; + + // get actual error object from RESULT_ERROR + public static final int RESULT_CODE_ERROR = 0; + // success! + public static final int RESULT_CODE_SUCCESS = 1; + // get PendingIntent from RESULT_INTENT, start PendingIntent with startIntentSenderForResult, + // and execute service method again in onActivityResult + public static final int RESULT_CODE_USER_INTERACTION_REQUIRED = 2; + + public static final String RESULT_ERROR = "error"; + public static final String RESULT_INTENT = "intent"; + + // DECRYPT_VERIFY + public static final String RESULT_SIGNATURE = "signature"; + + IOpenPgpService mService; + Context mContext; + + public OpenPgpApi(Context context, IOpenPgpService service) { + this.mContext = context; + this.mService = service; + } + + public interface IOpenPgpCallback { + void onReturn(final Intent result); + } + + private class OpenPgpAsyncTask extends AsyncTask { + Intent data; + InputStream is; + OutputStream os; + IOpenPgpCallback callback; + + private OpenPgpAsyncTask(Intent data, InputStream is, OutputStream os, IOpenPgpCallback callback) { + this.data = data; + this.is = is; + this.os = os; + this.callback = callback; + } + + @Override + protected Intent doInBackground(Void... unused) { + return executeApi(data, is, os); + } + + protected void onPostExecute(Intent result) { + callback.onReturn(result); + } + + } + + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public void executeApiAsync(Intent data, InputStream is, OutputStream os, IOpenPgpCallback callback) { + OpenPgpAsyncTask task = new OpenPgpAsyncTask(data, is, os, callback); + + // don't serialize async tasks! + // http://commonsware.com/blog/2012/04/20/asynctask-threading-regression-confirmed.html + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); + } else { + task.execute((Void[]) null); + } + } + + public Intent executeApi(Intent data, InputStream is, OutputStream os) { + try { + data.putExtra(EXTRA_API_VERSION, OpenPgpApi.API_VERSION); + + Intent result; + + // pipe the input and output + ParcelFileDescriptor input = null; + if (is != null) { + input = ParcelFileDescriptorUtil.pipeFrom(is, + new ParcelFileDescriptorUtil.IThreadListener() { + + @Override + public void onThreadFinished(Thread thread) { + //Log.d(OpenPgpApi.TAG, "Copy to service finished"); + } + } + ); + } + ParcelFileDescriptor output = null; + if (os != null) { + output = ParcelFileDescriptorUtil.pipeTo(os, + new ParcelFileDescriptorUtil.IThreadListener() { + + @Override + public void onThreadFinished(Thread thread) { + //Log.d(OpenPgpApi.TAG, "Service finished writing!"); + } + } + ); + } + + // blocks until result is ready + result = mService.execute(data, input, output); + // close() is required to halt the TransferThread + if (output != null) { + output.close(); + } + // TODO: close input? + + // set class loader to current context to allow unparcelling + // of OpenPgpError and OpenPgpSignatureResult + // http://stackoverflow.com/a/3806769 + result.setExtrasClassLoader(mContext.getClassLoader()); + + return result; + } catch (Exception e) { + Log.e(OpenPgpApi.TAG, "Exception in executeApi call", e); + Intent result = new Intent(); + result.putExtra(RESULT_CODE, RESULT_CODE_ERROR); + result.putExtra(RESULT_ERROR, + new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, e.getMessage())); + return result; + } + } + +} diff --git a/src/org/openintents/openpgp/util/OpenPgpListPreference.java b/src/org/openintents/openpgp/util/OpenPgpListPreference.java new file mode 100644 index 000000000..cf5864620 --- /dev/null +++ b/src/org/openintents/openpgp/util/OpenPgpListPreference.java @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp.util; + +import android.app.AlertDialog.Builder; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.pm.ResolveInfo; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.preference.DialogPreference; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ListAdapter; +import android.widget.TextView; +import org.openintents.openpgp.R; + +import java.util.ArrayList; +import java.util.List; + +/** + * Does not extend ListPreference, but is very similar to it! + * http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/4.4_r1/android/preference/ListPreference.java/?v=source + */ +public class OpenPgpListPreference extends DialogPreference { + private static final String OPENKEYCHAIN_PACKAGE = "org.sufficientlysecure.keychain"; + private static final String MARKET_INTENT_URI_BASE = "market://details?id=%s"; + private static final Intent MARKET_INTENT = new Intent(Intent.ACTION_VIEW, Uri.parse( + String.format(MARKET_INTENT_URI_BASE, OPENKEYCHAIN_PACKAGE))); + + private ArrayList mLegacyList = new ArrayList(); + private ArrayList mList = new ArrayList(); + + private String mSelectedPackage; + + public OpenPgpListPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public OpenPgpListPreference(Context context) { + this(context, null); + } + + /** + * Public method to add new entries for legacy applications + * + * @param packageName + * @param simpleName + * @param icon + */ + public void addLegacyProvider(int position, String packageName, String simpleName, Drawable icon) { + mLegacyList.add(position, new OpenPgpProviderEntry(packageName, simpleName, icon)); + } + + @Override + protected void onPrepareDialogBuilder(Builder builder) { + mList.clear(); + + // add "none"-entry + mList.add(0, new OpenPgpProviderEntry("", + getContext().getString(R.string.openpgp_list_preference_none), + getContext().getResources().getDrawable(R.drawable.ic_action_cancel_launchersize))); + + // add all additional (legacy) providers + mList.addAll(mLegacyList); + + // search for OpenPGP providers... + ArrayList providerList = new ArrayList(); + Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT); + List resInfo = getContext().getPackageManager().queryIntentServices(intent, 0); + if (!resInfo.isEmpty()) { + for (ResolveInfo resolveInfo : resInfo) { + if (resolveInfo.serviceInfo == null) + continue; + + String packageName = resolveInfo.serviceInfo.packageName; + String simpleName = String.valueOf(resolveInfo.serviceInfo.loadLabel(getContext() + .getPackageManager())); + Drawable icon = resolveInfo.serviceInfo.loadIcon(getContext().getPackageManager()); + + providerList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); + } + } + + if (providerList.isEmpty()) { + // add install links if provider list is empty + resInfo = getContext().getPackageManager().queryIntentActivities + (MARKET_INTENT, 0); + for (ResolveInfo resolveInfo : resInfo) { + Intent marketIntent = new Intent(MARKET_INTENT); + marketIntent.setPackage(resolveInfo.activityInfo.packageName); + Drawable icon = resolveInfo.activityInfo.loadIcon(getContext().getPackageManager()); + String marketName = String.valueOf(resolveInfo.activityInfo.applicationInfo + .loadLabel(getContext().getPackageManager())); + String simpleName = String.format(getContext().getString(R.string + .openpgp_install_openkeychain_via), marketName); + mList.add(new OpenPgpProviderEntry(OPENKEYCHAIN_PACKAGE, simpleName, + icon, marketIntent)); + } + } else { + // add provider + mList.addAll(providerList); + } + + // Init ArrayAdapter with OpenPGP Providers + ListAdapter adapter = new ArrayAdapter(getContext(), + android.R.layout.select_dialog_singlechoice, android.R.id.text1, mList) { + public View getView(int position, View convertView, ViewGroup parent) { + // User super class to create the View + View v = super.getView(position, convertView, parent); + TextView tv = (TextView) v.findViewById(android.R.id.text1); + + // Put the image on the TextView + tv.setCompoundDrawablesWithIntrinsicBounds(mList.get(position).icon, null, + null, null); + + // Add margin between image and text (support various screen densities) + int dp10 = (int) (10 * getContext().getResources().getDisplayMetrics().density + 0.5f); + tv.setCompoundDrawablePadding(dp10); + + return v; + } + }; + + builder.setSingleChoiceItems(adapter, getIndexOfProviderList(getValue()), + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + OpenPgpProviderEntry entry = mList.get(which); + + if (entry.intent != null) { + /* + * Intents are called as activity + * + * Current approach is to assume the user installed the app. + * If he does not, the selected package is not valid. + * + * However applications should always consider this could happen, + * as the user might remove the currently used OpenPGP app. + */ + getContext().startActivity(entry.intent); + } + + mSelectedPackage = entry.packageName; + + /* + * Clicking on an item simulates the positive button click, and dismisses + * the dialog. + */ + OpenPgpListPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE); + dialog.dismiss(); + } + }); + + /* + * The typical interaction for list-based dialogs is to have click-on-an-item dismiss the + * dialog instead of the user having to press 'Ok'. + */ + builder.setPositiveButton(null, null); + } + + @Override + protected void onDialogClosed(boolean positiveResult) { + super.onDialogClosed(positiveResult); + + if (positiveResult && (mSelectedPackage != null)) { + if (callChangeListener(mSelectedPackage)) { + setValue(mSelectedPackage); + } + } + } + + private int getIndexOfProviderList(String packageName) { + for (OpenPgpProviderEntry app : mList) { + if (app.packageName.equals(packageName)) { + return mList.indexOf(app); + } + } + + return -1; + } + + public void setValue(String packageName) { + mSelectedPackage = packageName; + persistString(packageName); + } + + public String getValue() { + return mSelectedPackage; + } + + public String getEntry() { + return getEntryByValue(mSelectedPackage); + } + + @Override + protected Object onGetDefaultValue(TypedArray a, int index) { + return a.getString(index); + } + + @Override + protected void onSetInitialValue(boolean restoreValue, Object defaultValue) { + setValue(restoreValue ? getPersistedString(mSelectedPackage) : (String) defaultValue); + } + + public String getEntryByValue(String packageName) { + for (OpenPgpProviderEntry app : mList) { + if (app.packageName.equals(packageName)) { + return app.simpleName; + } + } + + return null; + } + + private static class OpenPgpProviderEntry { + private String packageName; + private String simpleName; + private Drawable icon; + private Intent intent; + + public OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon) { + this.packageName = packageName; + this.simpleName = simpleName; + this.icon = icon; + } + + public OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon, Intent intent) { + this(packageName, simpleName, icon); + this.intent = intent; + } + + @Override + public String toString() { + return simpleName; + } + } +} diff --git a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java b/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java new file mode 100644 index 000000000..0395a7bc5 --- /dev/null +++ b/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp.util; + +import org.openintents.openpgp.IOpenPgpService; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.os.IBinder; + +public class OpenPgpServiceConnection { + + // interface to create callbacks for onServiceConnected + public interface OnBound { + public void onBound(IOpenPgpService service); + } + + private Context mApplicationContext; + + private IOpenPgpService mService; + private String mProviderPackageName; + + private OnBound mOnBoundListener; + + /** + * Create new OpenPgpServiceConnection + * + * @param context + * @param providerPackageName specify package name of OpenPGP provider, + * e.g., "org.sufficientlysecure.keychain" + */ + public OpenPgpServiceConnection(Context context, String providerPackageName) { + this.mApplicationContext = context.getApplicationContext(); + this.mProviderPackageName = providerPackageName; + } + + /** + * Create new OpenPgpServiceConnection + * + * @param context + * @param providerPackageName specify package name of OpenPGP provider, + * e.g., "org.sufficientlysecure.keychain" + * @param onBoundListener callback, executed when connection to service has been established + */ + public OpenPgpServiceConnection(Context context, String providerPackageName, + OnBound onBoundListener) { + this.mApplicationContext = context.getApplicationContext(); + this.mProviderPackageName = providerPackageName; + this.mOnBoundListener = onBoundListener; + } + + public IOpenPgpService getService() { + return mService; + } + + public boolean isBound() { + return (mService != null); + } + + private ServiceConnection mServiceConnection = new ServiceConnection() { + public void onServiceConnected(ComponentName name, IBinder service) { + mService = IOpenPgpService.Stub.asInterface(service); + if (mOnBoundListener != null) { + mOnBoundListener.onBound(mService); + } + } + + public void onServiceDisconnected(ComponentName name) { + mService = null; + } + }; + + /** + * If not already bound, bind to service! + * + * @return + */ + public boolean bindToService() { + // if not already bound... + if (mService == null) { + try { + Intent serviceIntent = new Intent(); + serviceIntent.setAction(IOpenPgpService.class.getName()); + // NOTE: setPackage is very important to restrict the intent to this provider only! + serviceIntent.setPackage(mProviderPackageName); + mApplicationContext.bindService(serviceIntent, mServiceConnection, + Context.BIND_AUTO_CREATE); + + return true; + } catch (Exception e) { + return false; + } + } else { + return true; + } + } + + public void unbindFromService() { + mApplicationContext.unbindService(mServiceConnection); + } + +} diff --git a/src/org/openintents/openpgp/util/OpenPgpUtils.java b/src/org/openintents/openpgp/util/OpenPgpUtils.java new file mode 100644 index 000000000..e24c937aa --- /dev/null +++ b/src/org/openintents/openpgp/util/OpenPgpUtils.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp.util; + +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.ResolveInfo; + +public class OpenPgpUtils { + + public static final Pattern PGP_MESSAGE = Pattern.compile( + ".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*", + Pattern.DOTALL); + + public static final Pattern PGP_SIGNED_MESSAGE = Pattern.compile( + ".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*", + Pattern.DOTALL); + + public static final int PARSE_RESULT_NO_PGP = -1; + public static final int PARSE_RESULT_MESSAGE = 0; + public static final int PARSE_RESULT_SIGNED_MESSAGE = 1; + + public static int parseMessage(String message) { + Matcher matcherSigned = PGP_SIGNED_MESSAGE.matcher(message); + Matcher matcherMessage = PGP_MESSAGE.matcher(message); + + if (matcherMessage.matches()) { + return PARSE_RESULT_MESSAGE; + } else if (matcherSigned.matches()) { + return PARSE_RESULT_SIGNED_MESSAGE; + } else { + return PARSE_RESULT_NO_PGP; + } + } + + public static boolean isAvailable(Context context) { + Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT); + List resInfo = context.getPackageManager().queryIntentServices(intent, 0); + if (!resInfo.isEmpty()) { + return true; + } else { + return false; + } + } + + public static String convertKeyIdToHex(long keyId) { + return "0x" + convertKeyIdToHex32bit(keyId >> 32) + convertKeyIdToHex32bit(keyId); + } + + private static String convertKeyIdToHex32bit(long keyId) { + String hexString = Long.toHexString(keyId & 0xffffffffL).toLowerCase(Locale.US); + while (hexString.length() < 8) { + hexString = "0" + hexString; + } + return hexString; + } +} diff --git a/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java b/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java new file mode 100644 index 000000000..58c62110d --- /dev/null +++ b/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * 2013 Flow (http://stackoverflow.com/questions/18212152/transfer-inputstream-to-another-service-across-process-boundaries-with-parcelf) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp.util; + +import android.os.ParcelFileDescriptor; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public class ParcelFileDescriptorUtil { + + public interface IThreadListener { + void onThreadFinished(final Thread thread); + } + + public static ParcelFileDescriptor pipeFrom(InputStream inputStream, IThreadListener listener) + throws IOException { + ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe(); + ParcelFileDescriptor readSide = pipe[0]; + ParcelFileDescriptor writeSide = pipe[1]; + + // start the transfer thread + new TransferThread(inputStream, new ParcelFileDescriptor.AutoCloseOutputStream(writeSide), + listener) + .start(); + + return readSide; + } + + public static ParcelFileDescriptor pipeTo(OutputStream outputStream, IThreadListener listener) + throws IOException { + ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe(); + ParcelFileDescriptor readSide = pipe[0]; + ParcelFileDescriptor writeSide = pipe[1]; + + // start the transfer thread + new TransferThread(new ParcelFileDescriptor.AutoCloseInputStream(readSide), outputStream, + listener) + .start(); + + return writeSide; + } + + static class TransferThread extends Thread { + final InputStream mIn; + final OutputStream mOut; + final IThreadListener mListener; + + TransferThread(InputStream in, OutputStream out, IThreadListener listener) { + super("ParcelFileDescriptor Transfer Thread"); + mIn = in; + mOut = out; + mListener = listener; + setDaemon(true); + } + + @Override + public void run() { + byte[] buf = new byte[1024]; + int len; + + try { + while ((len = mIn.read(buf)) > 0) { + mOut.write(buf, 0, len); + } + mOut.flush(); // just to be safe + } catch (IOException e) { + //Log.e(OpenPgpApi.TAG, "TransferThread" + getId() + ": writing failed", e); + } finally { + try { + mIn.close(); + } catch (IOException e) { + //Log.e(OpenPgpApi.TAG, "TransferThread" + getId(), e); + } + try { + mOut.close(); + } catch (IOException e) { + //Log.e(OpenPgpApi.TAG, "TransferThread" + getId(), e); + } + } + if (mListener != null) { + //Log.d(OpenPgpApi.TAG, "TransferThread " + getId() + " finished!"); + mListener.onThreadFinished(this); + } + } + } +} \ No newline at end of file From 650e1ebda82596cd4fbfaae406e6eccf189f4f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 7 May 2014 17:01:17 +0200 Subject: [PATCH 02/28] Add readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..da8361e88 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# OpenPGP Remote API library + +For usage instructions, please consult our Wiki page about the [OpenPGP Remote API](https://github.com/open-keychain/open-keychain/wiki/OpenPGP-API). \ No newline at end of file From a77887d32fae68171fcd0d2989bf537c0c11f0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 9 Jun 2014 21:54:19 +0200 Subject: [PATCH 03/28] Update buildTools to 19.1 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 69b937c1a..096f358e9 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:0.10.0' + classpath 'com.android.tools.build:gradle:0.11.1' } } @@ -13,7 +13,7 @@ apply plugin: 'android-library' android { compileSdkVersion 19 - buildToolsVersion '19.0.3' + buildToolsVersion '19.1' // NOTE: We are using the old folder structure to also support Eclipse sourceSets { From 289d48b633b7493f2a760583c88670b9fc4ef96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 22 Jun 2014 12:01:13 +0200 Subject: [PATCH 04/28] Add transifex config --- .tx/config | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .tx/config diff --git a/.tx/config b/.tx/config new file mode 100644 index 000000000..9e6de6164 --- /dev/null +++ b/.tx/config @@ -0,0 +1,8 @@ +[main] +host = https://www.transifex.com +lang_map = af_ZA: af-rZA, am_ET: am-rET, ar_AE: ar-rAE, ar_BH: ar-rBH, ar_DZ: ar-rDZ, ar_EG: ar-rEG, ar_IQ: ar-rIQ, ar_JO: ar-rJO, ar_KW: ar-rKW, ar_LB: ar-rLB, ar_LY: ar-rLY, ar_MA: ar-rMA, ar_OM: ar-rOM, ar_QA: ar-rQA, ar_SA: ar-rSA, ar_SY: ar-rSY, ar_TN: ar-rTN, ar_YE: ar-rYE, arn_CL: arn-rCL, as_IN: as-rIN, az_AZ: az-rAZ, ba_RU: ba-rRU, be_BY: be-rBY, bg_BG: bg-rBG, bn_BD: bn-rBD, bn_IN: bn-rIN, bo_CN: bo-rCN, br_FR: br-rFR, bs_BA: bs-rBA, ca_ES: ca-rES, co_FR: co-rFR, cs_CZ: cs-rCZ, cy_GB: cy-rGB, da_DK: da-rDK, de_AT: de-rAT, de_CH: de-rCH, de_DE: de-rDE, de_LI: de-rLI, de_LU: de-rLU, dsb_DE: dsb-rDE, dv_MV: dv-rMV, el_GR: el-rGR, en_AU: en-rAU, en_BZ: en-rBZ, en_CA: en-rCA, en_GB: en-rGB, en_IE: en-rIE, en_IN: en-rIN, en_JM: en-rJM, en_MY: en-rMY, en_NZ: en-rNZ, en_PH: en-rPH, en_SG: en-rSG, en_TT: en-rTT, en_US: en-rUS, en_ZA: en-rZA, en_ZW: en-rZW, es_AR: es-rAR, es_BO: es-rBO, es_CL: es-rCL, es_CO: es-rCO, es_CR: es-rCR, es_DO: es-rDO, es_EC: es-rEC, es_ES: es-rES, es_GT: es-rGT, es_HN: es-rHN, es_MX: es-rMX, es_NI: es-rNI, es_PA: es-rPA, es_PE: es-rPE, es_PR: es-rPR, es_PY: es-rPY, es_SV: es-rSV, es_US: es-rUS, es_UY: es-rUY, es_VE: es-rVE, et_EE: et-rEE, eu_ES: eu-rES, fa_IR: fa-rIR, fi_FI: fi-rFI, fil_PH: fil-rPH, fo_FO: fo-rFO, fr_BE: fr-rBE, fr_CA: fr-rCA, fr_CH: fr-rCH, fr_FR: fr-rFR, fr_LU: fr-rLU, fr_MC: fr-rMC, fy_NL: fy-rNL, ga_IE: ga-rIE, gd_GB: gd-rGB, gl_ES: gl-rES, gsw_FR: gsw-rFR, gu_IN: gu-rIN, ha_NG: ha-rNG, hi_IN: hi-rIN, hr_BA: hr-rBA, hr_HR: hr-rHR, hsb_DE: hsb-rDE, hu_HU: hu-rHU, hy_AM: hy-rAM, id_ID: id-rID, ig_NG: ig-rNG, ii_CN: ii-rCN, is_IS: is-rIS, it_CH: it-rCH, it_IT: it-rIT, iu_CA: iu-rCA, ja_JP: ja-rJP, ka_GE: ka-rGE, kk_KZ: kk-rKZ, kl_GL: kl-rGL, km_KH: km-rKH, kn_IN: kn-rIN, ko_KR: ko-rKR, kok_IN: kok-rIN, ky_KG: ky-rKG, lb_LU: lb-rLU, lo_LA: lo-rLA, lt_LT: lt-rLT, lv_LV: lv-rLV, mi_NZ: mi-rNZ, mk_MK: mk-rMK, ml_IN: ml-rIN, mn_CN: mn-rCN, mn_MN: mn-rMN, moh_CA: moh-rCA, mr_IN: mr-rIN, ms_BN: ms-rBN, ms_MY: ms-rMY, mt_MT: mt-rMT, nb_NO: nb-rNO, ne_NP: ne-rNP, nl_BE: nl-rBE, nl_NL: nl-rNL, nn_NO: nn-rNO, nso_ZA: nso-rZA, oc_FR: oc-rFR, or_IN: or-rIN, pa_IN: pa-rIN, pl_PL: pl-rPL, prs_AF: prs-rAF, ps_AF: ps-rAF, pt_BR: pt-rBR, pt_PT: pt-rPT, qut_GT: qut-rGT, quz_BO: quz-rBO, quz_EC: quz-rEC, quz_PE: quz-rPE, rm_CH: rm-rCH, ro_RO: ro-rRO, ru_RU: ru-rRU, rw_RW: rw-rRW, sa_IN: sa-rIN, sah_RU: sah-rRU, se_FI: se-rFI, se_NO: se-rNO, se_SE: se-rSE, si_LK: si-rLK, sk_SK: sk-rSK, sl_SI: sl-rSI, sma_NO: sma-rNO, sma_SE: sma-rSE, smj_NO: smj-rNO, smj_SE: smj-rSE, smn_FI: smn-rFI, sms_FI: sms-rFI, sq_AL: sq-rAL, sr_BA: sr-rBA, sr_CS: sr-rCS, sr_ME: sr-rME, sr_RS: sr-rRS, sv_FI: sv-rFI, sv_SE: sv-rSE, sw_KE: sw-rKE, syr_SY: syr-rSY, ta_IN: ta-rIN, te_IN: te-rIN, tg_TJ: tg-rTJ, th_TH: th-rTH, tk_TM: tk-rTM, tn_ZA: tn-rZA, tr_TR: tr-rTR, tt_RU: tt-rRU, tzm_DZ: tzm-rDZ, ug_CN: ug-rCN, uk_UA: uk-rUA, ur_PK: ur-rPK, uz_UZ: uz-rUZ, vi_VN: vi-rVN, wo_SN: wo-rSN, xh_ZA: xh-rZA, yo_NG: yo-rNG, zh_CN: zh-rCN, zh_HK: zh-rHK, zh_MO: zh-rMO, zh_SG: zh-rSG, zh_TW: zh-rTW, zu_ZA: zu-rZA, no_NO: no-rNO, he_IL: iw-rIL, he: iw + +[open-keychain.api-strings] +file_filter = res/values-/strings.xml +source_file = res/values/strings.xml +source_lang = en From aa9ecf871ce4db462034662675b258f9839d3f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 28 Jun 2014 20:16:10 +0200 Subject: [PATCH 05/28] Update android gradle plugin to 0.12.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 096f358e9..184a4b94c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:0.11.1' + classpath 'com.android.tools.build:gradle:0.12.0' } } From cd1a6748dd7a4c7a251a4f75eb289955dfbb1058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 17 Jul 2014 20:29:59 +0200 Subject: [PATCH 06/28] Extend for NFC --- src/org/openintents/openpgp/util/OpenPgpApi.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index f6a78d0ef..c88f9ceaf 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -141,6 +141,9 @@ public class OpenPgpApi { // optional extras: public static final String EXTRA_PASSPHRASE = "passphrase"; + // internal + public static final String EXTRA_NFC_DATA = "nfc_data"; + // GET_KEY public static final String EXTRA_KEY_ID = "key_id"; public static final String RESULT_KEY_IDS = "key_ids"; From 869ab96e6dcd4821fd5360248429e49dae6fbaca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 22 Jul 2014 18:10:06 +0200 Subject: [PATCH 07/28] Add values for NFC support --- src/org/openintents/openpgp/util/OpenPgpApi.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index c88f9ceaf..029584423 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -141,8 +141,9 @@ public class OpenPgpApi { // optional extras: public static final String EXTRA_PASSPHRASE = "passphrase"; - // internal - public static final String EXTRA_NFC_DATA = "nfc_data"; + // internal NFC states + public static final String EXTRA_NFC_SIGNED_HASH = "nfc_signed_hash"; + public static final String EXTRA_NFC_SIG_CREATION_TIMESTAMP = "nfc_sig_creation_timestamp"; // GET_KEY public static final String EXTRA_KEY_ID = "key_id"; From e515a49027fc5de36b8977cf8b096afc9838a9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 27 Jul 2014 18:28:20 +0200 Subject: [PATCH 08/28] Update gradle plugin to 0.12.2 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 184a4b94c..6e8fdfb5d 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:0.12.0' + classpath 'com.android.tools.build:gradle:0.12.2' } } From fab79b605f0317891fe4260dcec0dea1a76fa04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 4 Aug 2014 17:09:59 +0200 Subject: [PATCH 09/28] Lint fixes --- src/org/openintents/openpgp/util/OpenPgpUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpUtils.java b/src/org/openintents/openpgp/util/OpenPgpUtils.java index e24c937aa..416b2841b 100644 --- a/src/org/openintents/openpgp/util/OpenPgpUtils.java +++ b/src/org/openintents/openpgp/util/OpenPgpUtils.java @@ -67,7 +67,7 @@ public class OpenPgpUtils { } private static String convertKeyIdToHex32bit(long keyId) { - String hexString = Long.toHexString(keyId & 0xffffffffL).toLowerCase(Locale.US); + String hexString = Long.toHexString(keyId & 0xffffffffL).toLowerCase(Locale.ENGLISH); while (hexString.length() < 8) { hexString = "0" + hexString; } From 4f6475f11bb8b268775b6633d9f23e3a269aff96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 11 Aug 2014 17:12:02 +0200 Subject: [PATCH 10/28] Add metadata parcel --- .../openpgp/OpenPgpDecryptMetadata.java | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/org/openintents/openpgp/OpenPgpDecryptMetadata.java diff --git a/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java b/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java new file mode 100644 index 000000000..cfb507458 --- /dev/null +++ b/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.openpgp; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Parcelable versioning has been copied from Dashclock Widget + * https://code.google.com/p/dashclock/source/browse/api/src/main/java/com/google/android/apps/dashclock/api/ExtensionData.java + */ +public class OpenPgpDecryptMetadata implements Parcelable { + /** + * Since there might be a case where new versions of the client using the library getting + * old versions of the protocol (and thus old versions of this class), we need a versioning + * system for the parcels sent between the clients and the providers. + */ + public static final int PARCELABLE_VERSION = 1; + + String filename; + long modificationTime; + int format; + long originalSize; + + public String getFilename() { + return filename; + } + + public long getModificationTime() { + return modificationTime; + } + + public long getOriginalSize() { + return originalSize; + } + + public int getFormat() { + return format; + } + + public OpenPgpDecryptMetadata() { + } + + public OpenPgpDecryptMetadata(String filename, long modificationTime, + int format, long originalSize) { + this.filename = filename; + this.modificationTime = modificationTime; + this.format = format; + this.originalSize = originalSize; + } + + public OpenPgpDecryptMetadata(OpenPgpDecryptMetadata b) { + this.filename = b.filename; + this.modificationTime = b.modificationTime; + this.format = b.format; + this.originalSize = b.originalSize; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + /** + * NOTE: When adding fields in the process of updating this API, make sure to bump + * {@link #PARCELABLE_VERSION}. + */ + dest.writeInt(PARCELABLE_VERSION); + // Inject a placeholder that will store the parcel size from this point on + // (not including the size itself). + int sizePosition = dest.dataPosition(); + dest.writeInt(0); + int startPosition = dest.dataPosition(); + // version 1 + dest.writeString(filename); + dest.writeLong(modificationTime); + dest.writeInt(format); + dest.writeLong(originalSize); + // Go back and write the size + int parcelableSize = dest.dataPosition() - startPosition; + dest.setDataPosition(sizePosition); + dest.writeInt(parcelableSize); + dest.setDataPosition(startPosition + parcelableSize); + } + + public static final Creator CREATOR = new Creator() { + public OpenPgpDecryptMetadata createFromParcel(final Parcel source) { + int parcelableVersion = source.readInt(); + int parcelableSize = source.readInt(); + int startPosition = source.dataPosition(); + + OpenPgpDecryptMetadata vr = new OpenPgpDecryptMetadata(); + vr.filename = source.readString(); + vr.modificationTime = source.readLong(); + vr.format = source.readInt(); + vr.originalSize = source.readLong(); + + // skip over all fields added in future versions of this parcel + source.setDataPosition(startPosition + parcelableSize); + + return vr; + } + + public OpenPgpDecryptMetadata[] newArray(final int size) { + return new OpenPgpDecryptMetadata[size]; + } + }; + + @Override + public String toString() { + String out = new String(); + out += "\nfilename: " + filename; + out += "\nmodificationTime: " + modificationTime; + out += "\nformat: " + format; + out += "\noriginalSize: " + originalSize; + return out; + } + +} From 6bec5eedde31bacbafcb541a728719eeff99d3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 11 Aug 2014 17:19:23 +0200 Subject: [PATCH 11/28] Increase version to 4 --- .../openintents/openpgp/util/OpenPgpApi.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index 029584423..238447502 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -34,9 +34,22 @@ public class OpenPgpApi { public static final String TAG = "OpenPgp API"; - public static final int API_VERSION = 3; public static final String SERVICE_INTENT = "org.openintents.openpgp.IOpenPgpService"; + /** + * Version history + * --------------- + *

+ * 3: + * - first public stable version + *

+ * 4: + * - No changes to existing methods -> backward compatible + * - Introduction of ACTION_DECRYPT_METADATA, RESULT_METADATA, and OpenPgpDecryptMetadata parcel + * - Introduction of internal NFC extras: EXTRA_NFC_SIGNED_HASH, EXTRA_NFC_SIG_CREATION_TIMESTAMP + */ + public static final int API_VERSION = 4; + /** * General extras * -------------- @@ -54,7 +67,7 @@ public class OpenPgpApi { * Sign only *

* optional extras: - * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput) + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for output) * String EXTRA_PASSPHRASE (key passphrase) */ public static final String ACTION_SIGN = "org.openintents.openpgp.action.SIGN"; @@ -68,7 +81,7 @@ public class OpenPgpApi { * long[] EXTRA_KEY_IDS *

* optional extras: - * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput) + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for output) * String EXTRA_PASSPHRASE (key passphrase) */ public static final String ACTION_ENCRYPT = "org.openintents.openpgp.action.ENCRYPT"; @@ -82,7 +95,7 @@ public class OpenPgpApi { * long[] EXTRA_KEY_IDS *

* optional extras: - * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput) + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for output) * String EXTRA_PASSPHRASE (key passphrase) */ public static final String ACTION_SIGN_AND_ENCRYPT = "org.openintents.openpgp.action.SIGN_AND_ENCRYPT"; @@ -95,13 +108,24 @@ public class OpenPgpApi { * in addition a PendingIntent is returned via RESULT_INTENT to download missing keys. *

* optional extras: - * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput) + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for output) *

* returned extras: * OpenPgpSignatureResult RESULT_SIGNATURE + * OpenPgpDecryptMetadata RESULT_METADATA */ public static final String ACTION_DECRYPT_VERIFY = "org.openintents.openpgp.action.DECRYPT_VERIFY"; + /** + * Decrypts the header of an encrypted file to retrieve metadata such as original filename. + *

+ * This does not decrypt the actual content of the file. + *

+ * returned extras: + * OpenPgpDecryptMetadata RESULT_METADATA + */ + public static final String ACTION_DECRYPT_METADATA = "org.openintents.openpgp.action.DECRYPT_METADATA"; + /** * Get key ids based on given user ids (=emails) *

@@ -165,6 +189,7 @@ public class OpenPgpApi { // DECRYPT_VERIFY public static final String RESULT_SIGNATURE = "signature"; + public static final String RESULT_METADATA = "metadata"; IOpenPgpService mService; Context mContext; From 9aa5f23788f19689fb172fd209de72bc6941afdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 11 Aug 2014 20:16:30 +0200 Subject: [PATCH 12/28] Support mime type in metadata --- .../openpgp/OpenPgpDecryptMetadata.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java b/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java index cfb507458..832feb8d6 100644 --- a/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java +++ b/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java @@ -32,14 +32,18 @@ public class OpenPgpDecryptMetadata implements Parcelable { public static final int PARCELABLE_VERSION = 1; String filename; + String mimeType; long modificationTime; - int format; long originalSize; public String getFilename() { return filename; } + public String getMimeType() { + return mimeType; + } + public long getModificationTime() { return modificationTime; } @@ -48,25 +52,21 @@ public class OpenPgpDecryptMetadata implements Parcelable { return originalSize; } - public int getFormat() { - return format; - } - public OpenPgpDecryptMetadata() { } - public OpenPgpDecryptMetadata(String filename, long modificationTime, - int format, long originalSize) { + public OpenPgpDecryptMetadata(String filename, String mimeType, long modificationTime, + long originalSize) { this.filename = filename; + this.mimeType = mimeType; this.modificationTime = modificationTime; - this.format = format; this.originalSize = originalSize; } public OpenPgpDecryptMetadata(OpenPgpDecryptMetadata b) { this.filename = b.filename; + this.mimeType = b.mimeType; this.modificationTime = b.modificationTime; - this.format = b.format; this.originalSize = b.originalSize; } @@ -87,8 +87,8 @@ public class OpenPgpDecryptMetadata implements Parcelable { int startPosition = dest.dataPosition(); // version 1 dest.writeString(filename); + dest.writeString(mimeType); dest.writeLong(modificationTime); - dest.writeInt(format); dest.writeLong(originalSize); // Go back and write the size int parcelableSize = dest.dataPosition() - startPosition; @@ -105,8 +105,8 @@ public class OpenPgpDecryptMetadata implements Parcelable { OpenPgpDecryptMetadata vr = new OpenPgpDecryptMetadata(); vr.filename = source.readString(); + vr.mimeType = source.readString(); vr.modificationTime = source.readLong(); - vr.format = source.readInt(); vr.originalSize = source.readLong(); // skip over all fields added in future versions of this parcel @@ -122,10 +122,9 @@ public class OpenPgpDecryptMetadata implements Parcelable { @Override public String toString() { - String out = new String(); - out += "\nfilename: " + filename; + String out = "\nfilename: " + filename; + out += "\nmimeType: " + mimeType; out += "\nmodificationTime: " + modificationTime; - out += "\nformat: " + format; out += "\noriginalSize: " + originalSize; return out; } From 777d22d75da9bfecf0bcfe2088da3fef01b2259f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 11 Aug 2014 21:26:34 +0200 Subject: [PATCH 13/28] Rename to OpenPgpMetadata --- ...ryptMetadata.java => OpenPgpMetadata.java} | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) rename src/org/openintents/openpgp/{OpenPgpDecryptMetadata.java => OpenPgpMetadata.java} (84%) diff --git a/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java b/src/org/openintents/openpgp/OpenPgpMetadata.java similarity index 84% rename from src/org/openintents/openpgp/OpenPgpDecryptMetadata.java rename to src/org/openintents/openpgp/OpenPgpMetadata.java index 832feb8d6..2a99e406f 100644 --- a/src/org/openintents/openpgp/OpenPgpDecryptMetadata.java +++ b/src/org/openintents/openpgp/OpenPgpMetadata.java @@ -23,7 +23,7 @@ import android.os.Parcelable; * Parcelable versioning has been copied from Dashclock Widget * https://code.google.com/p/dashclock/source/browse/api/src/main/java/com/google/android/apps/dashclock/api/ExtensionData.java */ -public class OpenPgpDecryptMetadata implements Parcelable { +public class OpenPgpMetadata implements Parcelable { /** * Since there might be a case where new versions of the client using the library getting * old versions of the protocol (and thus old versions of this class), we need a versioning @@ -52,18 +52,18 @@ public class OpenPgpDecryptMetadata implements Parcelable { return originalSize; } - public OpenPgpDecryptMetadata() { + public OpenPgpMetadata() { } - public OpenPgpDecryptMetadata(String filename, String mimeType, long modificationTime, - long originalSize) { + public OpenPgpMetadata(String filename, String mimeType, long modificationTime, + long originalSize) { this.filename = filename; this.mimeType = mimeType; this.modificationTime = modificationTime; this.originalSize = originalSize; } - public OpenPgpDecryptMetadata(OpenPgpDecryptMetadata b) { + public OpenPgpMetadata(OpenPgpMetadata b) { this.filename = b.filename; this.mimeType = b.mimeType; this.modificationTime = b.modificationTime; @@ -97,13 +97,13 @@ public class OpenPgpDecryptMetadata implements Parcelable { dest.setDataPosition(startPosition + parcelableSize); } - public static final Creator CREATOR = new Creator() { - public OpenPgpDecryptMetadata createFromParcel(final Parcel source) { + public static final Creator CREATOR = new Creator() { + public OpenPgpMetadata createFromParcel(final Parcel source) { int parcelableVersion = source.readInt(); int parcelableSize = source.readInt(); int startPosition = source.dataPosition(); - OpenPgpDecryptMetadata vr = new OpenPgpDecryptMetadata(); + OpenPgpMetadata vr = new OpenPgpMetadata(); vr.filename = source.readString(); vr.mimeType = source.readString(); vr.modificationTime = source.readLong(); @@ -115,8 +115,8 @@ public class OpenPgpDecryptMetadata implements Parcelable { return vr; } - public OpenPgpDecryptMetadata[] newArray(final int size) { - return new OpenPgpDecryptMetadata[size]; + public OpenPgpMetadata[] newArray(final int size) { + return new OpenPgpMetadata[size]; } }; From 940a1d8eebe297e6a94f417a24c0403f1d8d650f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 11 Aug 2014 23:56:25 +0200 Subject: [PATCH 14/28] Add EXTRA_ORIGINAL_FILENAME --- src/org/openintents/openpgp/util/OpenPgpApi.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index 238447502..485d3710b 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -45,7 +45,7 @@ public class OpenPgpApi { *

* 4: * - No changes to existing methods -> backward compatible - * - Introduction of ACTION_DECRYPT_METADATA, RESULT_METADATA, and OpenPgpDecryptMetadata parcel + * - Introduction of ACTION_DECRYPT_METADATA, RESULT_METADATA, EXTRA_ORIGINAL_FILENAME, and OpenPgpMetadata parcel * - Introduction of internal NFC extras: EXTRA_NFC_SIGNED_HASH, EXTRA_NFC_SIG_CREATION_TIMESTAMP */ public static final int API_VERSION = 4; @@ -83,6 +83,7 @@ public class OpenPgpApi { * optional extras: * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for output) * String EXTRA_PASSPHRASE (key passphrase) + * String EXTRA_ORIGINAL_FILENAME (original filename to be encrypted as metadata) */ public static final String ACTION_ENCRYPT = "org.openintents.openpgp.action.ENCRYPT"; @@ -97,6 +98,7 @@ public class OpenPgpApi { * optional extras: * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for output) * String EXTRA_PASSPHRASE (key passphrase) + * String EXTRA_ORIGINAL_FILENAME (original filename to be encrypted as metadata) */ public static final String ACTION_SIGN_AND_ENCRYPT = "org.openintents.openpgp.action.SIGN_AND_ENCRYPT"; @@ -164,6 +166,7 @@ public class OpenPgpApi { public static final String EXTRA_KEY_IDS = "key_ids"; // optional extras: public static final String EXTRA_PASSPHRASE = "passphrase"; + public static final String EXTRA_ORIGINAL_FILENAME = "original_filename"; // internal NFC states public static final String EXTRA_NFC_SIGNED_HASH = "nfc_signed_hash"; From cbfeb90cec9d9ecea2576eddf42e37154286c667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 12 Aug 2014 13:46:34 +0200 Subject: [PATCH 15/28] Refactor OpenPgpServiceConnection with better callback --- .../util/OpenPgpServiceConnection.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java b/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java index 0395a7bc5..2700caf01 100644 --- a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java +++ b/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java @@ -26,9 +26,11 @@ import android.os.IBinder; public class OpenPgpServiceConnection { - // interface to create callbacks for onServiceConnected + // callback interface public interface OnBound { public void onBound(IOpenPgpService service); + + public void onError(Exception e); } private Context mApplicationContext; @@ -39,19 +41,19 @@ public class OpenPgpServiceConnection { private OnBound mOnBoundListener; /** - * Create new OpenPgpServiceConnection + * Create new connection * * @param context * @param providerPackageName specify package name of OpenPGP provider, * e.g., "org.sufficientlysecure.keychain" */ public OpenPgpServiceConnection(Context context, String providerPackageName) { - this.mApplicationContext = context.getApplicationContext(); + this.mApplicationContext = context; this.mProviderPackageName = providerPackageName; } /** - * Create new OpenPgpServiceConnection + * Create new connection with callback * * @param context * @param providerPackageName specify package name of OpenPGP provider, @@ -60,8 +62,7 @@ public class OpenPgpServiceConnection { */ public OpenPgpServiceConnection(Context context, String providerPackageName, OnBound onBoundListener) { - this.mApplicationContext = context.getApplicationContext(); - this.mProviderPackageName = providerPackageName; + this(context, providerPackageName); this.mOnBoundListener = onBoundListener; } @@ -91,23 +92,25 @@ public class OpenPgpServiceConnection { * * @return */ - public boolean bindToService() { + public void bindToService() { // if not already bound... if (mService == null) { try { - Intent serviceIntent = new Intent(); - serviceIntent.setAction(IOpenPgpService.class.getName()); + Intent serviceIntent = new Intent(OpenPgpApi.SERVICE_INTENT); // NOTE: setPackage is very important to restrict the intent to this provider only! serviceIntent.setPackage(mProviderPackageName); mApplicationContext.bindService(serviceIntent, mServiceConnection, Context.BIND_AUTO_CREATE); - - return true; } catch (Exception e) { - return false; + if (mOnBoundListener != null) { + mOnBoundListener.onError(e); + } } } else { - return true; + // already bound, but also inform client about it with callback + if (mOnBoundListener != null) { + mOnBoundListener.onBound(mService); + } } } From 9e1f732b23d3b5df042f627d65a8ca37cec023fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 12 Aug 2014 14:38:28 +0200 Subject: [PATCH 16/28] More fixes for OpenPgpServiceConnection --- .../openpgp/util/OpenPgpServiceConnection.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java b/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java index 2700caf01..dad27ccbe 100644 --- a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java +++ b/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java @@ -16,14 +16,14 @@ package org.openintents.openpgp.util; -import org.openintents.openpgp.IOpenPgpService; - import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.IBinder; +import org.openintents.openpgp.IOpenPgpService; + public class OpenPgpServiceConnection { // callback interface @@ -99,8 +99,11 @@ public class OpenPgpServiceConnection { Intent serviceIntent = new Intent(OpenPgpApi.SERVICE_INTENT); // NOTE: setPackage is very important to restrict the intent to this provider only! serviceIntent.setPackage(mProviderPackageName); - mApplicationContext.bindService(serviceIntent, mServiceConnection, + boolean connect = mApplicationContext.bindService(serviceIntent, mServiceConnection, Context.BIND_AUTO_CREATE); + if (!connect) { + throw new Exception("bindService() returned false!"); + } } catch (Exception e) { if (mOnBoundListener != null) { mOnBoundListener.onError(e); From 1d0eeef047c4938f4e25bc06f7e92e83aa46a4c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 12 Aug 2014 15:03:00 +0200 Subject: [PATCH 17/28] Use application context --- src/org/openintents/openpgp/util/OpenPgpServiceConnection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java b/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java index dad27ccbe..15096d9eb 100644 --- a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java +++ b/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java @@ -48,7 +48,7 @@ public class OpenPgpServiceConnection { * e.g., "org.sufficientlysecure.keychain" */ public OpenPgpServiceConnection(Context context, String providerPackageName) { - this.mApplicationContext = context; + this.mApplicationContext = context.getApplicationContext(); this.mProviderPackageName = providerPackageName; } From d15482c22a17c4d07b993d8e576dcb953620ee4b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 30 Aug 2014 15:19:43 +0200 Subject: [PATCH 18/28] Add my Real-name to the Copyright statement of ParcelFileDescriptorUtil. --- .../openintents/openpgp/util/ParcelFileDescriptorUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java b/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java index 58c62110d..4fd4b39a7 100644 --- a/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java +++ b/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2014 Dominik Schürmann - * 2013 Flow (http://stackoverflow.com/questions/18212152/transfer-inputstream-to-another-service-across-process-boundaries-with-parcelf) + * 2013 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +/** + * Partially based on Stackoverflow: Transfer InputStream to another Service (across process boundaries) + **/ public class ParcelFileDescriptorUtil { public interface IThreadListener { @@ -100,4 +103,4 @@ public class ParcelFileDescriptorUtil { } } } -} \ No newline at end of file +} From e0be0f648ade84a83c7561c0521853447ca8b3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 31 Aug 2014 23:39:56 +0200 Subject: [PATCH 19/28] Add SIGNATURE_KEY_REVOKED, SIGNATURE_KEY_EXPIRED, rename SIGNATURE_PUB_KEY_UNKNOWN --- .../openintents/openpgp/OpenPgpSignatureResult.java | 12 ++++++++---- src/org/openintents/openpgp/util/OpenPgpApi.java | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/org/openintents/openpgp/OpenPgpSignatureResult.java b/src/org/openintents/openpgp/OpenPgpSignatureResult.java index 7a4d799dc..23401a1d8 100644 --- a/src/org/openintents/openpgp/OpenPgpSignatureResult.java +++ b/src/org/openintents/openpgp/OpenPgpSignatureResult.java @@ -37,12 +37,16 @@ public class OpenPgpSignatureResult implements Parcelable { // generic error on signature verification public static final int SIGNATURE_ERROR = 0; - // successfully verified signature, with certified public key + // successfully verified signature, with certified key public static final int SIGNATURE_SUCCESS_CERTIFIED = 1; - // no public key was found for this signature verification - public static final int SIGNATURE_UNKNOWN_PUB_KEY = 2; - // successfully verified signature, but with uncertified public key + // no key was found for this signature verification + public static final int SIGNATURE_KEY_MISSING = 2; + // successfully verified signature, but with uncertified key public static final int SIGNATURE_SUCCESS_UNCERTIFIED = 3; + // key has been revoked + public static final int SIGNATURE_KEY_REVOKED = 4; + // key is expired + public static final int SIGNATURE_KEY_EXPIRED = 5; int status; boolean signatureOnly; diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index 485d3710b..a248a0e2e 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -47,8 +47,10 @@ public class OpenPgpApi { * - No changes to existing methods -> backward compatible * - Introduction of ACTION_DECRYPT_METADATA, RESULT_METADATA, EXTRA_ORIGINAL_FILENAME, and OpenPgpMetadata parcel * - Introduction of internal NFC extras: EXTRA_NFC_SIGNED_HASH, EXTRA_NFC_SIG_CREATION_TIMESTAMP + * 5: + * - OpenPgpSignatureResult: new SIGNATURE_KEY_REVOKED and SIGNATURE_KEY_EXPIRED */ - public static final int API_VERSION = 4; + public static final int API_VERSION = 5; /** * General extras @@ -106,7 +108,7 @@ public class OpenPgpApi { * Decrypts and verifies given input stream. This methods handles encrypted-only, signed-and-encrypted, * and also signed-only input. *

- * If OpenPgpSignatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY + * If OpenPgpSignatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_KEY_MISSING * in addition a PendingIntent is returned via RESULT_INTENT to download missing keys. *

* optional extras: From 575b9d2279cd36b607316b76af6a968d54102660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 31 Aug 2014 23:48:21 +0200 Subject: [PATCH 20/28] Add userIds to OpenPgpSignatureResult --- .../openpgp/OpenPgpSignatureResult.java | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/org/openintents/openpgp/OpenPgpSignatureResult.java b/src/org/openintents/openpgp/OpenPgpSignatureResult.java index 23401a1d8..3b78abcf8 100644 --- a/src/org/openintents/openpgp/OpenPgpSignatureResult.java +++ b/src/org/openintents/openpgp/OpenPgpSignatureResult.java @@ -21,6 +21,7 @@ import android.os.Parcelable; import org.openintents.openpgp.util.OpenPgpUtils; +import java.util.ArrayList; import java.util.Locale; /** @@ -33,7 +34,7 @@ public class OpenPgpSignatureResult implements Parcelable { * old versions of the protocol (and thus old versions of this class), we need a versioning * system for the parcels sent between the clients and the providers. */ - public static final int PARCELABLE_VERSION = 1; + public static final int PARCELABLE_VERSION = 2; // generic error on signature verification public static final int SIGNATURE_ERROR = 0; @@ -50,7 +51,8 @@ public class OpenPgpSignatureResult implements Parcelable { int status; boolean signatureOnly; - String userId; + String primaryUserId; + ArrayList userIds; long keyId; public int getStatus() { @@ -69,12 +71,20 @@ public class OpenPgpSignatureResult implements Parcelable { this.signatureOnly = signatureOnly; } - public String getUserId() { - return userId; + public String getPrimaryUserId() { + return primaryUserId; } - public void setUserId(String userId) { - this.userId = userId; + public void setPrimaryUserId(String primaryUserId) { + this.primaryUserId = primaryUserId; + } + + public ArrayList getUserIds() { + return userIds; + } + + public void setUserIds(ArrayList userIds) { + this.userIds = userIds; } public long getKeyId() { @@ -90,18 +100,20 @@ public class OpenPgpSignatureResult implements Parcelable { } public OpenPgpSignatureResult(int signatureStatus, String signatureUserId, - boolean signatureOnly, long keyId) { + boolean signatureOnly, long keyId, ArrayList userIds) { this.status = signatureStatus; this.signatureOnly = signatureOnly; - this.userId = signatureUserId; + this.primaryUserId = signatureUserId; this.keyId = keyId; + this.userIds = userIds; } public OpenPgpSignatureResult(OpenPgpSignatureResult b) { this.status = b.status; - this.userId = b.userId; + this.primaryUserId = b.primaryUserId; this.signatureOnly = b.signatureOnly; this.keyId = b.keyId; + this.userIds = b.userIds; } public int describeContents() { @@ -122,8 +134,10 @@ public class OpenPgpSignatureResult implements Parcelable { // version 1 dest.writeInt(status); dest.writeByte((byte) (signatureOnly ? 1 : 0)); - dest.writeString(userId); + dest.writeString(primaryUserId); dest.writeLong(keyId); + // version 2 + dest.writeList(userIds); // Go back and write the size int parcelableSize = dest.dataPosition() - startPosition; dest.setDataPosition(sizePosition); @@ -140,8 +154,9 @@ public class OpenPgpSignatureResult implements Parcelable { OpenPgpSignatureResult vr = new OpenPgpSignatureResult(); vr.status = source.readInt(); vr.signatureOnly = source.readByte() == 1; - vr.userId = source.readString(); + vr.primaryUserId = source.readString(); vr.keyId = source.readLong(); + source.readStringList(vr.userIds); // skip over all fields added in future versions of this parcel source.setDataPosition(startPosition + parcelableSize); @@ -156,9 +171,9 @@ public class OpenPgpSignatureResult implements Parcelable { @Override public String toString() { - String out = new String(); - out += "\nstatus: " + status; - out += "\nuserId: " + userId; + String out = "\nstatus: " + status; + out += "\nprimaryUserId: " + primaryUserId; + out += "\nuserIds: " + userIds; out += "\nsignatureOnly: " + signatureOnly; out += "\nkeyId: " + OpenPgpUtils.convertKeyIdToHex(keyId); return out; From 8b36d286680ee57b2181e86a3f02ba1278a81166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 31 Aug 2014 23:49:34 +0200 Subject: [PATCH 21/28] Changelog --- src/org/openintents/openpgp/util/OpenPgpApi.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index a248a0e2e..a7c2ad6f9 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -48,7 +48,8 @@ public class OpenPgpApi { * - Introduction of ACTION_DECRYPT_METADATA, RESULT_METADATA, EXTRA_ORIGINAL_FILENAME, and OpenPgpMetadata parcel * - Introduction of internal NFC extras: EXTRA_NFC_SIGNED_HASH, EXTRA_NFC_SIG_CREATION_TIMESTAMP * 5: - * - OpenPgpSignatureResult: new SIGNATURE_KEY_REVOKED and SIGNATURE_KEY_EXPIRED + * - OpenPgpSignatureResult: new consts SIGNATURE_KEY_REVOKED and SIGNATURE_KEY_EXPIRED + * - OpenPgpSignatureResult: ArrayList userIds */ public static final int API_VERSION = 5; From 3bcf7266c3944c5aad417ae339eaf4420783877d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 2 Sep 2014 16:11:07 +0200 Subject: [PATCH 22/28] Update README --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da8361e88..ac54aa296 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ -# OpenPGP Remote API library +# OpenPGP API library + +The OpenPGP API provides methods to do common OpenPGP operations, such as sign, encrypt, decrypt, verify, and more without user interaction from background threads. This is done by connecting your client application to a remote service provided by OpenKeychain or other OpenPGP providers. + +For usage instructions, please consult our Wiki page about the [OpenPGP API](https://github.com/open-keychain/open-keychain/wiki/OpenPGP-API). + +License +======= + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. -For usage instructions, please consult our Wiki page about the [OpenPGP Remote API](https://github.com/open-keychain/open-keychain/wiki/OpenPGP-API). \ No newline at end of file From bba03f2f2ff16550853cbf573f4cbf30b0e0f641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 2 Sep 2014 16:11:46 +0200 Subject: [PATCH 23/28] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac54aa296..c9491400a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OpenPGP API library -The OpenPGP API provides methods to do common OpenPGP operations, such as sign, encrypt, decrypt, verify, and more without user interaction from background threads. This is done by connecting your client application to a remote service provided by OpenKeychain or other OpenPGP providers. +The OpenPGP API provides methods to execute OpenPGP operations, such as sign, encrypt, decrypt, verify, and more without user interaction from background threads. This is done by connecting your client application to a remote service provided by OpenKeychain or other OpenPGP providers. For usage instructions, please consult our Wiki page about the [OpenPGP API](https://github.com/open-keychain/open-keychain/wiki/OpenPGP-API). From 9dd15131e1a5cd67f90574a9513940215a142661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 2 Sep 2014 16:12:35 +0200 Subject: [PATCH 24/28] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9491400a..aefc9ed34 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OpenPGP API library -The OpenPGP API provides methods to execute OpenPGP operations, such as sign, encrypt, decrypt, verify, and more without user interaction from background threads. This is done by connecting your client application to a remote service provided by OpenKeychain or other OpenPGP providers. +The OpenPGP API provides methods to execute OpenPGP operations, such as sign, encrypt, decrypt, verify, and more without user interaction from background threads. This is done by connecting your client application to a remote service provided by [OpenKeychain](http://www.openkeychain.org) or other OpenPGP providers. For usage instructions, please consult our Wiki page about the [OpenPGP API](https://github.com/open-keychain/open-keychain/wiki/OpenPGP-API). From ec234ebf010a268922e8f3c08f21f9efd8cf1cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 4 Sep 2014 01:28:06 +0200 Subject: [PATCH 25/28] Pull from transifex --- res/values-cs/strings.xml | 5 +++++ res/values-de/strings.xml | 5 +++++ res/values-es/strings.xml | 5 +++++ res/values-et/strings.xml | 2 ++ res/values-fi/strings.xml | 2 ++ res/values-fr/strings.xml | 5 +++++ res/values-is/strings.xml | 2 ++ res/values-it/strings.xml | 5 +++++ res/values-ja/strings.xml | 5 +++++ res/values-nl/strings.xml | 2 ++ res/values-pl/strings.xml | 2 ++ res/values-pt/strings.xml | 2 ++ res/values-ru/strings.xml | 5 +++++ res/values-sl/strings.xml | 5 +++++ res/values-tr/strings.xml | 2 ++ res/values-uk/strings.xml | 5 +++++ res/values-zh/strings.xml | 2 ++ 17 files changed, 61 insertions(+) create mode 100644 res/values-cs/strings.xml create mode 100644 res/values-de/strings.xml create mode 100644 res/values-es/strings.xml create mode 100644 res/values-et/strings.xml create mode 100644 res/values-fi/strings.xml create mode 100644 res/values-fr/strings.xml create mode 100644 res/values-is/strings.xml create mode 100644 res/values-it/strings.xml create mode 100644 res/values-ja/strings.xml create mode 100644 res/values-nl/strings.xml create mode 100644 res/values-pl/strings.xml create mode 100644 res/values-pt/strings.xml create mode 100644 res/values-ru/strings.xml create mode 100644 res/values-sl/strings.xml create mode 100644 res/values-tr/strings.xml create mode 100644 res/values-uk/strings.xml create mode 100644 res/values-zh/strings.xml diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml new file mode 100644 index 000000000..c9fe1fab7 --- /dev/null +++ b/res/values-cs/strings.xml @@ -0,0 +1,5 @@ + + + Žádný + Instalovat OpenKeychain pomocí %s + diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml new file mode 100644 index 000000000..91e800adb --- /dev/null +++ b/res/values-de/strings.xml @@ -0,0 +1,5 @@ + + + Keine Auswahl + Installiere OpenKeychain mit %s + diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml new file mode 100644 index 000000000..da8979b45 --- /dev/null +++ b/res/values-es/strings.xml @@ -0,0 +1,5 @@ + + + Ninguno + Instalar OpenKeychain mediante %s + diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml new file mode 100644 index 000000000..c757504ac --- /dev/null +++ b/res/values-et/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml new file mode 100644 index 000000000..c757504ac --- /dev/null +++ b/res/values-fi/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml new file mode 100644 index 000000000..9b36df2df --- /dev/null +++ b/res/values-fr/strings.xml @@ -0,0 +1,5 @@ + + + Aucun + Installer OpenKeychain par %s + diff --git a/res/values-is/strings.xml b/res/values-is/strings.xml new file mode 100644 index 000000000..c757504ac --- /dev/null +++ b/res/values-is/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml new file mode 100644 index 000000000..23e8e8013 --- /dev/null +++ b/res/values-it/strings.xml @@ -0,0 +1,5 @@ + + + Nessuno + Installa OpenKeychain via %s + diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml new file mode 100644 index 000000000..5e337f5ab --- /dev/null +++ b/res/values-ja/strings.xml @@ -0,0 +1,5 @@ + + + 無し + %s 経由でOpenKeychainをインストール + diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml new file mode 100644 index 000000000..c757504ac --- /dev/null +++ b/res/values-nl/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml new file mode 100644 index 000000000..c757504ac --- /dev/null +++ b/res/values-pl/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml new file mode 100644 index 000000000..c757504ac --- /dev/null +++ b/res/values-pt/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml new file mode 100644 index 000000000..e8fd1ddf6 --- /dev/null +++ b/res/values-ru/strings.xml @@ -0,0 +1,5 @@ + + + Нет + Установить OpenKeychain через %s + diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml new file mode 100644 index 000000000..20bf70b0a --- /dev/null +++ b/res/values-sl/strings.xml @@ -0,0 +1,5 @@ + + + Brez + Namesti OpenKeychain prek %s + diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml new file mode 100644 index 000000000..c757504ac --- /dev/null +++ b/res/values-tr/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml new file mode 100644 index 000000000..baf600a9f --- /dev/null +++ b/res/values-uk/strings.xml @@ -0,0 +1,5 @@ + + + Жоден + Встановити OpenKeychain через %s + diff --git a/res/values-zh/strings.xml b/res/values-zh/strings.xml new file mode 100644 index 000000000..c757504ac --- /dev/null +++ b/res/values-zh/strings.xml @@ -0,0 +1,2 @@ + + From f6d678cbe50ac2b68264ba62e87c2978765e78e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 7 Sep 2014 19:23:04 +0200 Subject: [PATCH 26/28] Fix nullpointer with new OpenPgpSignatureResult version --- src/org/openintents/openpgp/OpenPgpSignatureResult.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/openintents/openpgp/OpenPgpSignatureResult.java b/src/org/openintents/openpgp/OpenPgpSignatureResult.java index 3b78abcf8..8ce4d3c06 100644 --- a/src/org/openintents/openpgp/OpenPgpSignatureResult.java +++ b/src/org/openintents/openpgp/OpenPgpSignatureResult.java @@ -156,6 +156,7 @@ public class OpenPgpSignatureResult implements Parcelable { vr.signatureOnly = source.readByte() == 1; vr.primaryUserId = source.readString(); vr.keyId = source.readLong(); + vr.userIds = new ArrayList(); source.readStringList(vr.userIds); // skip over all fields added in future versions of this parcel From 2cebac6a23e55627131947ba4d515c781fb5d31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 7 Sep 2014 20:07:13 +0200 Subject: [PATCH 27/28] Fix for user ids in API --- src/org/openintents/openpgp/OpenPgpSignatureResult.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/openintents/openpgp/OpenPgpSignatureResult.java b/src/org/openintents/openpgp/OpenPgpSignatureResult.java index 8ce4d3c06..dbcd74b64 100644 --- a/src/org/openintents/openpgp/OpenPgpSignatureResult.java +++ b/src/org/openintents/openpgp/OpenPgpSignatureResult.java @@ -137,7 +137,7 @@ public class OpenPgpSignatureResult implements Parcelable { dest.writeString(primaryUserId); dest.writeLong(keyId); // version 2 - dest.writeList(userIds); + dest.writeStringList(userIds); // Go back and write the size int parcelableSize = dest.dataPosition() - startPosition; dest.setDataPosition(sizePosition); From 0be263d5d3effd2df5f976fa4a127017268749cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 8 Sep 2014 14:09:15 +0200 Subject: [PATCH 28/28] Work on Yubikey decryption --- src/org/openintents/openpgp/util/OpenPgpApi.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index a7c2ad6f9..3e18ab0cf 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -174,6 +174,7 @@ public class OpenPgpApi { // internal NFC states public static final String EXTRA_NFC_SIGNED_HASH = "nfc_signed_hash"; public static final String EXTRA_NFC_SIG_CREATION_TIMESTAMP = "nfc_sig_creation_timestamp"; + public static final String EXTRA_NFC_DECRYPTED_SESSION_KEY = "nfc_decrypted_session_key"; // GET_KEY public static final String EXTRA_KEY_ID = "key_id";