Skip to content

Commit 78e2ebe

Browse files
author
gefeili
committed
Merge branch 'main' into pg-synchronize-bc_csharp
2 parents dda1247 + b5bff1b commit 78e2ebe

File tree

54 files changed

+2236
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2236
-287
lines changed

CONTRIBUTING.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Bouncy Castle Contributing Guidelines <!-- omit in toc -->
2+
3+
Thank you for contributing to Bouncy Castle!
4+
5+
In this guide, you get an overview of the contribution workflow from starting a discussion or opening an issue, to creating, reviewing, and merging a pull request.
6+
7+
For an overview of the project, see [README](README.md).
8+
9+
### Start a discussion
10+
If you have a question or problem, you can [search in discussions](https://github.com/bcgit/bc-java/discussions), if someone has already found a solution to your problem.
11+
12+
Or you can [start a new discussion](https://github.com/bcgit/bc-java/discussions/new/choose) and ask your question.
13+
14+
### Create an issue
15+
16+
If you find a problem with Bouncy Castle, [search if an issue already exists](https://github.com/bcgit/bc-java/issues).
17+
18+
> **_NOTE:_** If the issue is a __potential security problem__, please contact us
19+
before posting anything public. See [Security Policy](SECURITY.md).
20+
21+
If a related discussion or issue doesn't exist, and the issue is not security related, you can [open a new issue](https://github.com/bcgit/bc-java/issues/new). An issue can be converted into a discussion if regarded as one.
22+
23+
### Contribute to the code
24+
25+
For substantial, non-trivial contributions, you may be asked to sign a contributor assignment agreement. Optionally, you can also have your name and contact information listed in [Contributors](https://www.bouncycastle.org/contributors.html).
26+
27+
Please note we are unable to accept contributions which cannot be released under the [Bouncy Castle License](https://www.bouncycastle.org/licence.html). Issuing a pull request on our public github mirror is taken as agreement to issuing under the Bouncy Castle License.
28+
29+
#### Create a pull request
30+
31+
> **_NOTE:_** If the issue is a __potential security problem__, please contact us. See [Security Policy](SECURITY.md).
32+
33+
You are welcome to send patches, under the Bouncy Castle License, as pull requests. For more information, see [Creating a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request). For minor updates, you can instead choose to create an issue with short snippets of code. See above.
34+
35+
* For contributions touching multiple files try and split up the pull request, smaller changes are easier to review and test, as well as being less likely to run into merge issues.
36+
* Create a test cases for your change, it may be a simple addition to an existing test. If you do not know how to do this, ask us and we will help you.
37+
* If you run into any merge issues, check out this [git tutorial](https://github.com/skills/resolve-merge-conflicts) to help you resolve merge conflicts and other issues.
38+
39+
For more information, refer to the Bouncy Castle documentation on [Getting Started with Bouncy Castle](https://doc.primekey.com/bouncycastle/introduction#Introduction-GettingStartedwithBouncyCastle).
40+
41+
#### Self-review
42+
43+
Don't forget to self-review. Please follow these simple guidelines:
44+
* Keep the patch limited, only change the parts related to your patch.
45+
* Do not change other lines, such as whitespace, adding line breaks to Java doc, etc. It will make it very hard for us to review the patch.
46+
47+
48+
#### Your pull request is merged
49+
50+
For acceptance, pull requests need to meet specific quality criteria, including tests for anything substantial. Someone on the Bouncy Castle core team will review the pull request when there is time, and let you know if something is missing or suggest improvements. If it is a useful and generic feature it will be integrated in Bouncy Castle to be available in a later release.
51+

LICENSE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (c) 2000-2024 The Legion of the Bouncy Castle Inc. (https://www.bouncycastle.org).
2+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
3+
associated documentation files (the "Software"), to deal in the Software without restriction,
4+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
5+
sub license, and/or sell copies of the Software, and to permit persons to whom the Software is
6+
furnished to do so, subject to the following conditions: The above copyright notice and this
7+
permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
10+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
12+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
13+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**

SECURITY.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
# Reporting a security issue
1+
# Security Policy
22

3-
If you would like to report something you believe to be a security issue
4-
then please use [email protected].
5-
We can provide a PGP key if required.
3+
## Reporting a Vulnerability
4+
5+
If you think that you have found a security vulnerability, please report it to this email address: [[email protected]](mailto:[email protected])
6+
7+
Describe the issue including all details, for example:
8+
* Short summary of the problem
9+
* Steps to reproduce
10+
* Affected API versions
11+
* Logs if available
12+
13+
The Bouncy Castle team will send a response indicating the next steps in handling your report. You may be asked to provide additional information or guidance.
14+
15+
If the issue is confirmed as a vulnerability, we will open a Security Advisory and acknowledge your contributions as part of it. Optionally, you can have your name and contact information listed in [Contributors](https://www.bouncycastle.org/contributors.html) as well.
16+
17+
Please note we endeavor to issue patched releases that deal with security issues as soon as they are made known to us, ideally prior to issuing a Security Advisory where otherwise possible. In some cases, particularly if it relates to a FIPS release, delays due to external processes may delay the issuing of a Security Advisory.

ant/bc+-build.xml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,27 @@
360360
<exclude name="org/bouncycastle/asn1/cmp/**" />
361361
<exclude name="org/bouncycastle/asn1/cms/**" />
362362
<exclude name="org/bouncycastle/asn1/crmf/**" />
363+
<exclude name="org/bouncycastle/asn1/cryptlib/**" />
363364
<exclude name="org/bouncycastle/asn1/dvcs/**" />
364365
<exclude name="org/bouncycastle/asn1/eac/**" />
366+
<exclude name="org/bouncycastle/asn1/edec/**" />
365367
<exclude name="org/bouncycastle/asn1/esf/**" />
366368
<exclude name="org/bouncycastle/asn1/ess/**" />
367369
<exclude name="org/bouncycastle/asn1/est/**" />
370+
<exclude name="org/bouncycastle/asn1/gnu/**" />
371+
<exclude name="org/bouncycastle/asn1/iana/**" />
368372
<exclude name="org/bouncycastle/asn1/icao/**" />
373+
<exclude name="org/bouncycastle/asn1/isara/**" />
369374
<exclude name="org/bouncycastle/asn1/isismtt/**" />
370-
<exclude name="org/bouncycastle/asn1/its/**" />
375+
<exclude name="org/bouncycastle/asn1/iso/**" />
376+
<exclude name="org/bouncycastle/asn1/kisa/**" />
377+
<exclude name="org/bouncycastle/asn1/microsoft/**" />
378+
<exclude name="org/bouncycastle/asn1/misc/**" />
379+
<exclude name="org/bouncycastle/asn1/mozilla/**" />
380+
<exclude name="org/bouncycastle/asn1/nsri/**" />
381+
<exclude name="org/bouncycastle/asn1/ntt/**" />
382+
<exclude name="org/bouncycastle/asn1/oiw/**" />
383+
<exclude name="org/bouncycastle/asn1/rosstandart/**" />
371384
<exclude name="org/bouncycastle/asn1/smime/**" />
372385
<exclude name="org/bouncycastle/asn1/tsp/**" />
373386
<exclude name="org/bouncycastle/bcpg/**" />
@@ -754,14 +767,27 @@
754767
<include name="org/bouncycastle/asn1/cmp/**" />
755768
<include name="org/bouncycastle/asn1/cms/**" />
756769
<include name="org/bouncycastle/asn1/crmf/**" />
770+
<include name="org/bouncycastle/asn1/cryptlib/**" />
757771
<include name="org/bouncycastle/asn1/dvcs/**" />
758772
<include name="org/bouncycastle/asn1/eac/**" />
773+
<include name="org/bouncycastle/asn1/edec/**" />
759774
<include name="org/bouncycastle/asn1/esf/**" />
760775
<include name="org/bouncycastle/asn1/ess/**" />
761776
<include name="org/bouncycastle/asn1/est/**" />
777+
<include name="org/bouncycastle/asn1/gnu/**" />
778+
<include name="org/bouncycastle/asn1/iana/**" />
762779
<include name="org/bouncycastle/asn1/icao/**" />
780+
<include name="org/bouncycastle/asn1/isara/**" />
763781
<include name="org/bouncycastle/asn1/isismtt/**" />
764-
<include name="org/bouncycastle/asn1/its/**" />
782+
<include name="org/bouncycastle/asn1/iso/**" />
783+
<include name="org/bouncycastle/asn1/kisa/**" />
784+
<include name="org/bouncycastle/asn1/microsoft/**" />
785+
<include name="org/bouncycastle/asn1/misc/**" />
786+
<include name="org/bouncycastle/asn1/mozilla/**" />
787+
<include name="org/bouncycastle/asn1/nsri/**" />
788+
<include name="org/bouncycastle/asn1/ntt/**" />
789+
<include name="org/bouncycastle/asn1/oiw/**" />
790+
<include name="org/bouncycastle/asn1/rosstandart/**" />
765791
<include name="org/bouncycastle/asn1/smime/**" />
766792
<include name="org/bouncycastle/asn1/tsp/**" />
767793
<include name="org/bouncycastle/oer/**" />
@@ -860,7 +886,10 @@
860886
<copyStandardFiles toDir="${pg.target.dir}" />
861887

862888
<copy todir="${pg.target.src.dir}" filtering="true">
863-
<fileset dir="${src.dir}" includes="org/bouncycastle/bcpg/**/*.java" />
889+
<fileset dir="${src.dir}">
890+
<include name="org/bouncycastle/bcpg/**/*.java" />
891+
<exclude name="org/bouncycastle/**/test/**/*.java" />
892+
</fileset>
864893
</copy>
865894

866895
<copy todir="${pg.target.src.dir}">

build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ if (JavaVersion.current().isJava8Compatible()) {
3131
}
3232
}
3333

34+
def String deriveOSGIVersion(String prjVersion) {
35+
if (prjVersion.contains("-SNAPSHOT")) {
36+
// Snapshots always extend to fourth level and terminate with time in seconds since epoch.
37+
prjVersion = prjVersion.replace("-SNAPSHOT", "");
38+
while (prjVersion.count(".") < 2) {
39+
prjVersion = prjVersion + ".0";
40+
}
41+
prjVersion = prjVersion + "." + System.currentTimeMillis().intdiv(1000L).intdiv(60).intdiv(60).intdiv(24);
42+
}
43+
return prjVersion
44+
}
45+
46+
ext {
47+
bundle_version = deriveOSGIVersion(version.toString());
48+
}
49+
3450

3551
// this needs to go here, otherwise it can't find config
3652
apply plugin: 'io.spring.nohttp'
@@ -46,7 +62,6 @@ allprojects {
4662
mavenCentral()
4763
}
4864

49-
5065
dependencies {
5166
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
5267
}
@@ -171,6 +186,7 @@ ext {
171186

172187

173188

189+
174190
subprojects {
175191
apply plugin: 'eclipse'
176192

core/src/main/java/org/bouncycastle/asn1/x9/X9IntegerConverter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ public class X9IntegerConverter
1717
* @param c the curve of interest.
1818
* @return the field size in bytes (rounded up).
1919
*/
20-
public int getByteLength(
21-
ECCurve c)
20+
public int getByteLength(ECCurve c)
2221
{
23-
return (c.getFieldSize() + 7) / 8;
22+
return c.getFieldElementEncodingLength();
2423
}
2524

2625
/**
@@ -29,10 +28,9 @@ public int getByteLength(
2928
* @param fe the field element of interest.
3029
* @return the field size in bytes (rounded up).
3130
*/
32-
public int getByteLength(
33-
ECFieldElement fe)
31+
public int getByteLength(ECFieldElement fe)
3432
{
35-
return (fe.getFieldSize() + 7) / 8;
33+
return fe.getEncodedLength();
3634
}
3735

3836
/**

core/src/main/java/org/bouncycastle/crypto/agreement/ECDHBasicAgreement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void init(
4141

4242
public int getFieldSize()
4343
{
44-
return (key.getParameters().getCurve().getFieldSize() + 7) / 8;
44+
return key.getParameters().getCurve().getFieldElementEncodingLength();
4545
}
4646

4747
public BigInteger calculateAgreement(

core/src/main/java/org/bouncycastle/crypto/agreement/ECDHCBasicAgreement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void init(
4545

4646
public int getFieldSize()
4747
{
48-
return (key.getParameters().getCurve().getFieldSize() + 7) / 8;
48+
return key.getParameters().getCurve().getFieldElementEncodingLength();
4949
}
5050

5151
public BigInteger calculateAgreement(

core/src/main/java/org/bouncycastle/crypto/agreement/ECDHCStagedAgreement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void init(
2727

2828
public int getFieldSize()
2929
{
30-
return (key.getParameters().getCurve().getFieldSize() + 7) / 8;
30+
return key.getParameters().getCurve().getFieldElementEncodingLength();
3131
}
3232

3333
public AsymmetricKeyParameter calculateStage(

core/src/main/java/org/bouncycastle/crypto/agreement/ECDHCUnifiedAgreement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void init(
2525

2626
public int getFieldSize()
2727
{
28-
return (privParams.getStaticPrivateKey().getParameters().getCurve().getFieldSize() + 7) / 8;
28+
return privParams.getStaticPrivateKey().getParameters().getCurve().getFieldElementEncodingLength();
2929
}
3030

3131
public byte[] calculateAgreement(CipherParameters pubKey)

0 commit comments

Comments
 (0)