Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aTalk Jingle implementation for review #520

Open
wants to merge 42 commits into
base: 4.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
121a3a2
jingle-aTalk implementation
cmeng-git Mar 2, 2022
c88ae33
Allow coexit between jingle_rtp and smack jingle
cmeng-git Apr 3, 2022
099df48
Add missing update
cmeng-git Apr 3, 2022
f32c612
add missing updates
cmeng-git Apr 3, 2022
7c6c812
Cleanup files headers
cmeng-git Apr 3, 2022
5513419
Cleanup files headers
cmeng-git Apr 4, 2022
322c6fd
relocate file
cmeng-git Apr 6, 2022
89f6d9c
add JingleCallManager and JingleCallSessionImpl
cmeng-git Apr 10, 2022
6173dd5
support JingleMessage registerJingleSessionHandler
cmeng-git Apr 13, 2022
e7b6f95
full support JFT and JET
cmeng-git Apr 15, 2022
d59a3c2
cleanup and set subclass same as aTalk
cmeng-git Apr 15, 2022
3a343a7
minor update
cmeng-git May 11, 2022
d8f30e2
update sdp Transfer
cmeng-git May 11, 2022
15094c1
fix NPE in JingleContentImpl#setParent
cmeng-git Jun 8, 2022
f2aa019
Update JingleFileTransferImpl#mState in file sending
cmeng-git Jul 7, 2022
1ea4747
JFT file streaming must be in Async
cmeng-git Jul 17, 2022
98a7332
Allow user cancels active file transfer
cmeng-git Jul 17, 2022
fe60311
Allow user cancel only in active state
cmeng-git Jul 22, 2022
20656d3
change source format
cmeng-git Jul 22, 2022
22b7cae
update smack code style
cmeng-git Aug 2, 2022
9e71367
Unregister sessionHander after received session-terminate response
cmeng-git Aug 9, 2022
ffa9afb
Unregister sessionHander after received session-terminate response
cmeng-git Aug 9, 2022
a8b3b3f
Ignore AEADBadTagException on user cancel file transfer
cmeng-git Aug 11, 2022
4f32c0e
wait for reponse on session-terminate
cmeng-git Aug 16, 2022
836043e
add XEP-0215: External Service Discovery
cmeng-git Nov 3, 2022
6741f62
conversations excludes initiator attribute in session-initiate
cmeng-git Nov 16, 2022
4e1c000
Update JingleContentImpl.java
cmeng-git Nov 17, 2022
6888765
Update JingleOutgoingFileOffer.java
cmeng-git Nov 17, 2022
0b3b064
Strip zone_id in stream host
cmeng-git Nov 22, 2022
032b7ca
Fix Jingle Transport handling errors
cmeng-git Nov 23, 2022
134853f
Fix CandidateActivated element name error
cmeng-git Nov 24, 2022
81c1c31
Jingle transport candidate priority per XEP-0260
cmeng-git Nov 24, 2022
6f7ca90
Add support for OMEMO media file sharing
cmeng-git Jan 16, 2023
fc833b5
Minor code cleanup
cmeng-git Jan 17, 2023
79586b7
Must send <close/> stanza on closing IBBByteStream
cmeng-git Jan 17, 2023
c520ee2
Add omemo media file sharing and jingle session state callback
cmeng-git Jan 22, 2023
e106b2c
Clean source
cmeng-git Feb 14, 2023
84516ae
Merge branch 'smack-jft_jet' into smack-atalk
cmeng-git Feb 24, 2023
4571e6c
Merged smack-jft to smack-atalk repository for easy maintainence
cmeng-git Feb 24, 2023
64f7fc3
Add getAttribute method to support JingleContent build criteria checking
cmeng-git Mar 6, 2023
db721ae
Update Jingle File Transfer
cmeng-git Jun 12, 2023
0294d9d
Jingle.Group.Content does not have an attribute creator
cmeng-git Jun 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
*
* Copyright 2017 Paul Schaub
*
* 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.jivesoftware.smackx.ciphers;

import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import javax.crypto.NoSuchPaddingException;

public class Aes128GcmNoPadding extends AesGcmNoPadding {
public static final String NAMESPACE = "urn:xmpp:ciphers:aes-128-gcm-nopadding:0";

public Aes128GcmNoPadding(int MODE) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException,
NoSuchProviderException, InvalidAlgorithmParameterException {
super(128, MODE);
}

public Aes128GcmNoPadding(byte[] keyAndIv, int MODE) throws NoSuchProviderException, InvalidAlgorithmParameterException,
NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException {
super(AesGcmNoPadding.copyOfRange(keyAndIv, 0, 16), // 16 byte key
AesGcmNoPadding.copyOfRange(keyAndIv, 16, keyAndIv.length), MODE); // rest (12 byte) IV
}

@Override
public String getNamespace() {
return NAMESPACE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
*
* Copyright 2017 Paul Schaub
*
* 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.jivesoftware.smackx.ciphers;

import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import javax.crypto.NoSuchPaddingException;

public class Aes256GcmNoPadding extends AesGcmNoPadding {
public static final String NAMESPACE = "urn:xmpp:ciphers:aes-256-gcm-nopadding:0";

public Aes256GcmNoPadding(int MODE) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException,
NoSuchProviderException, InvalidAlgorithmParameterException {
super(256, MODE);
}

public Aes256GcmNoPadding(byte[] keyAndIv, int MODE) throws NoSuchProviderException, InvalidAlgorithmParameterException,
NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException {
super(AesGcmNoPadding.copyOfRange(keyAndIv, 0, 32), // 32 byte key
AesGcmNoPadding.copyOfRange(keyAndIv, 32, keyAndIv.length), MODE); // rest (12 byte) IV
}

@Override
public String getNamespace() {
return NAMESPACE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/**
*
* Copyright 2017 Paul Schaub
*
* 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.jivesoftware.smackx.ciphers;

import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public abstract class AesGcmNoPadding {

public static final String keyType = "AES";
public static final String cipherMode = "AES/GCM/NoPadding";

private final int length;
protected final Cipher cipher;
private final byte[] key, iv, keyAndIv;

AesGcmNoPadding(int bits, int MODE) throws NoSuchAlgorithmException, NoSuchProviderException,
NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeyException {
this.length = bits;
int bytes = bits / 8;

KeyGenerator keyGenerator = KeyGenerator.getInstance(keyType);
keyGenerator.init(bits);
key = keyGenerator.generateKey().getEncoded();

SecureRandom secureRandom = new SecureRandom();
iv = new byte[12];
secureRandom.nextBytes(iv);

keyAndIv = new byte[bytes + 12];
System.arraycopy(key, 0, keyAndIv, 0, bytes);
System.arraycopy(iv, 0, keyAndIv, bytes, 12);

cipher = Cipher.getInstance(cipherMode, "BC");
SecretKey keySpec = new SecretKeySpec(key, keyType);
IvParameterSpec ivSpec = new IvParameterSpec(iv);
cipher.init(MODE, keySpec, ivSpec);
}

public static AesGcmNoPadding createEncryptionKey(String cipherName)
throws NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException,
InvalidAlgorithmParameterException {

switch (cipherName) {
case Aes128GcmNoPadding.NAMESPACE:
return new Aes128GcmNoPadding(Cipher.ENCRYPT_MODE);
case Aes256GcmNoPadding.NAMESPACE:
return new Aes256GcmNoPadding(Cipher.ENCRYPT_MODE);
default: throw new NoSuchAlgorithmException("Invalid cipher.");
}
}

/**
* Create a new AES key.
* @param key key
* @param iv iv
* @param MODE cipher mode (Cipher.ENCRYPT_MODE / Cipher.DECRYPT_MODE)
* @throws NoSuchPaddingException if the requested padding mechanism is not available.
* @throws NoSuchAlgorithmException in case there is no {@link java.security.Provider} registered for the used
* @throws NoSuchProviderException in case there is no suitable {@link java.security.Provider} registered.
* @throws InvalidAlgorithmParameterException in case an invalid algorithms configuration is used.
* @throws InvalidKeyException if the key is invalid.
*/
public AesGcmNoPadding(byte[] key, byte[] iv, int MODE) throws NoSuchPaddingException, NoSuchAlgorithmException,
NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeyException {
assert iv.length == 12;
this.length = key.length * 8;
this.key = key;
this.iv = iv;

keyAndIv = new byte[key.length + iv.length];
System.arraycopy(key, 0, keyAndIv, 0, key.length);
System.arraycopy(iv, 0, keyAndIv, key.length, iv.length);

cipher = Cipher.getInstance(cipherMode, "BC");
SecretKeySpec keySpec = new SecretKeySpec(key, keyType);
IvParameterSpec ivSpec = new IvParameterSpec(iv);
cipher.init(MODE, keySpec, ivSpec);
}

public static AesGcmNoPadding createDecryptionKey(String namespace, byte[] serialized)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchProviderException,
InvalidKeyException, NoSuchPaddingException {

switch (namespace) {
case Aes128GcmNoPadding.NAMESPACE:
return new Aes128GcmNoPadding(serialized, Cipher.DECRYPT_MODE);
case Aes256GcmNoPadding.NAMESPACE:
return new Aes256GcmNoPadding(serialized, Cipher.DECRYPT_MODE);
default: throw new NoSuchAlgorithmException("Invalid cipher.");
}
}

public byte[] getKeyAndIv() {
return keyAndIv.clone();
}

public byte[] getKey() {
return key.clone();
}

public byte[] getIv() {
return iv.clone();
}

public int getLength() {
return length;
}

public Cipher getCipher() {
return cipher;
}

public abstract String getNamespace();

static byte[] copyOfRange(byte[] source, int start, int end) {
byte[] copy = new byte[end - start];
System.arraycopy(source, start, copy, 0, end - start);
return copy;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
*
* Copyright 2017 Paul Schaub
*
* 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.
*/

/**
* Smack's API for XEP-0391: Jingle Encrypted Transfers.
*/
package org.jivesoftware.smackx.ciphers;
Loading